diff --git a/README.md b/README.md index 98381b01..3a3f1f8b 100644 --- a/README.md +++ b/README.md @@ -98,26 +98,6 @@ There are three areas in particular where pgx can provide a significant performa perform nearly 3x the number of queries per second. 3. Batched queries - Multiple queries can be batched together to minimize network round trips. -## Comparison with Alternatives - -* [pq](http://godoc.org/github.com/lib/pq) -* [go-pg](https://github.com/go-pg/pg) - -For prepared queries with small sets of simple data types, all drivers will have have similar performance. However, if prepared statements aren't being explicitly used, pgx can have a significant performance advantage due to automatic statement preparation. -pgx also can perform better when using PostgreSQL-specific data types or query batching. See -[go_db_bench](https://github.com/jackc/go_db_bench) for some database driver benchmarks. - -### Compatibility with `database/sql` - -pq is exclusively used with `database/sql`. go-pg does not use `database/sql` at all. pgx supports `database/sql` as well as -its own interface. - -### Level of access, ORM - -go-pg is a PostgreSQL client and ORM. It includes many features that traditionally sit above the database driver, such as ORM, struct mapping, soft deletes, schema migrations, and sharding support. - -pgx is "closer to the metal" and such abstractions are beyond the scope of the pgx project, which first and foremost, aims to be a performant driver and toolkit. - ## Testing pgx tests naturally require a PostgreSQL database. It will connect to the database specified in the `PGX_TEST_DATABASE` environment diff --git a/conn.go b/conn.go index 877589a7..8e0707c4 100644 --- a/conn.go +++ b/conn.go @@ -366,30 +366,6 @@ func (c *Conn) Ping(ctx context.Context) error { return err } -func connInfoFromRows(rows Rows, err error) (map[string]uint32, error) { - if err != nil { - return nil, err - } - defer rows.Close() - - nameOIDs := make(map[string]uint32, 256) - for rows.Next() { - var oid uint32 - var name pgtype.Text - if err = rows.Scan(&oid, &name); err != nil { - return nil, err - } - - nameOIDs[name.String] = oid - } - - if err = rows.Err(); err != nil { - return nil, err - } - - return nameOIDs, err -} - // PgConn returns the underlying *pgconn.PgConn. This is an escape hatch method that allows lower level access to the // PostgreSQL connection than pgx exposes. // diff --git a/large_objects.go b/large_objects.go index 5255a3b4..baa92b38 100644 --- a/large_objects.go +++ b/large_objects.go @@ -108,13 +108,13 @@ func (o *LargeObject) Tell() (n int64, err error) { return n, err } -// Trunctes the large object to size. +// Truncate the large object to size. func (o *LargeObject) Truncate(size int64) (err error) { _, err = o.tx.Exec(o.ctx, "select lo_truncate64($1, $2)", o.fd, size) return err } -// Close closees the large object descriptor. +// Close the large object descriptor. func (o *LargeObject) Close() error { _, err := o.tx.Exec(o.ctx, "select lo_close($1)", o.fd) return err diff --git a/stdlib/sql.go b/stdlib/sql.go index 5e2c3a03..b0d92af3 100644 --- a/stdlib/sql.go +++ b/stdlib/sql.go @@ -163,7 +163,7 @@ func RandomizeHostOrderFunc(ctx context.Context, connConfig *pgx.ConnConfig) err return nil } -func OpenDB(config pgx.ConnConfig, opts ...OptionOpenDB) *sql.DB { +func GetConnector(config pgx.ConnConfig, opts ...OptionOpenDB) driver.Connector { c := connector{ ConnConfig: config, BeforeConnect: func(context.Context, *pgx.ConnConfig) error { return nil }, // noop before connect by default @@ -175,7 +175,11 @@ func OpenDB(config pgx.ConnConfig, opts ...OptionOpenDB) *sql.DB { for _, opt := range opts { opt(&c) } + return c +} +func OpenDB(config pgx.ConnConfig, opts ...OptionOpenDB) *sql.DB { + c := GetConnector(config, opts...) return sql.OpenDB(c) }