diff --git a/batch.go b/batch.go index 3a9bcdda..453ef5c5 100644 --- a/batch.go +++ b/batch.go @@ -4,14 +4,13 @@ import ( "context" "github.com/jackc/pgconn" - "github.com/jackc/pgtype" errors "golang.org/x/xerrors" ) type batchItem struct { query string arguments []interface{} - parameterOIDs []pgtype.OID + parameterOIDs []uint32 resultFormatCodes []int16 } @@ -24,7 +23,7 @@ type Batch struct { // Queue queues a query to batch b. query can be an SQL query or the name of a prepared statement. parameterOIDs and // resultFormatCodes should be nil if query is a prepared statement. Otherwise, parameterOIDs are required if there are // parameters and resultFormatCodes are required if there is a result. -func (b *Batch) Queue(query string, arguments []interface{}, parameterOIDs []pgtype.OID, resultFormatCodes []int16) { +func (b *Batch) Queue(query string, arguments []interface{}, parameterOIDs []uint32, resultFormatCodes []int16) { b.items = append(b.items, &batchItem{ query: query, arguments: arguments, diff --git a/batch_test.go b/batch_test.go index 82f692ba..d8ebf53e 100644 --- a/batch_test.go +++ b/batch_test.go @@ -26,17 +26,17 @@ func TestConnSendBatch(t *testing.T) { batch := &pgx.Batch{} batch.Queue("insert into ledger(description, amount) values($1, $2)", []interface{}{"q1", 1}, - []pgtype.OID{pgtype.VarcharOID, pgtype.Int4OID}, + []uint32{pgtype.VarcharOID, pgtype.Int4OID}, nil, ) batch.Queue("insert into ledger(description, amount) values($1, $2)", []interface{}{"q2", 2}, - []pgtype.OID{pgtype.VarcharOID, pgtype.Int4OID}, + []uint32{pgtype.VarcharOID, pgtype.Int4OID}, nil, ) batch.Queue("insert into ledger(description, amount) values($1, $2)", []interface{}{"q3", 3}, - []pgtype.OID{pgtype.VarcharOID, pgtype.Int4OID}, + []uint32{pgtype.VarcharOID, pgtype.Int4OID}, nil, ) batch.Queue("select id, description, amount from ledger order by id", @@ -374,7 +374,7 @@ func TestConnSendBatchQueryRowInsert(t *testing.T) { ) batch.Queue("insert into ledger(description, amount) values($1, $2),($1, $2)", []interface{}{"q1", 1}, - []pgtype.OID{pgtype.VarcharOID, pgtype.Int4OID}, + []uint32{pgtype.VarcharOID, pgtype.Int4OID}, nil, ) @@ -420,7 +420,7 @@ func TestConnSendBatchQueryPartialReadInsert(t *testing.T) { ) batch.Queue("insert into ledger(description, amount) values($1, $2),($1, $2)", []interface{}{"q1", 1}, - []pgtype.OID{pgtype.VarcharOID, pgtype.Int4OID}, + []uint32{pgtype.VarcharOID, pgtype.Int4OID}, nil, ) @@ -467,7 +467,7 @@ func TestTxSendBatch(t *testing.T) { batch := &pgx.Batch{} batch.Queue("insert into ledger1(description) values($1) returning id", []interface{}{"q1"}, - []pgtype.OID{pgtype.VarcharOID}, + []uint32{pgtype.VarcharOID}, []int16{pgx.BinaryFormatCode}, ) @@ -483,13 +483,13 @@ func TestTxSendBatch(t *testing.T) { batch = &pgx.Batch{} batch.Queue("insert into ledger2(id,amount) values($1, $2)", []interface{}{id, 2}, - []pgtype.OID{pgtype.Int4OID, pgtype.Int4OID}, + []uint32{pgtype.Int4OID, pgtype.Int4OID}, nil, ) batch.Queue("select amount from ledger2 where id = $1", []interface{}{id}, - []pgtype.OID{pgtype.Int4OID}, + []uint32{pgtype.Int4OID}, nil, ) @@ -542,7 +542,7 @@ func TestTxSendBatchRollback(t *testing.T) { batch := &pgx.Batch{} batch.Queue("insert into ledger1(description) values($1) returning id", []interface{}{"q1"}, - []pgtype.OID{pgtype.VarcharOID}, + []uint32{pgtype.VarcharOID}, []int16{pgx.BinaryFormatCode}, ) diff --git a/conn.go b/conn.go index d89fe575..81a4c6e2 100644 --- a/conn.go +++ b/conn.go @@ -66,7 +66,7 @@ type PreparedStatement struct { Name string SQL string FieldDescriptions []pgproto3.FieldDescription - ParameterOIDs []pgtype.OID + ParameterOIDs []uint32 } // Identifier a PostgreSQL identifier or name. Identifiers can be composed of @@ -230,12 +230,12 @@ func (c *Conn) Prepare(ctx context.Context, name, sql string) (ps *PreparedState ps = &PreparedStatement{ Name: psd.Name, SQL: psd.SQL, - ParameterOIDs: make([]pgtype.OID, len(psd.ParamOIDs)), + ParameterOIDs: make([]uint32, len(psd.ParamOIDs)), FieldDescriptions: psd.Fields, } for i := range ps.ParameterOIDs { - ps.ParameterOIDs[i] = pgtype.OID(psd.ParamOIDs[i]) + ps.ParameterOIDs[i] = uint32(psd.ParamOIDs[i]) } if name != "" { @@ -363,15 +363,15 @@ func (c *Conn) Ping(ctx context.Context) error { return err } -func connInfoFromRows(rows Rows, err error) (map[string]pgtype.OID, error) { +func connInfoFromRows(rows Rows, err error) (map[string]uint32, error) { if err != nil { return nil, err } defer rows.Close() - nameOIDs := make(map[string]pgtype.OID, 256) + nameOIDs := make(map[string]uint32, 256) for rows.Next() { - var oid pgtype.OID + var oid uint32 var name pgtype.Text if err = rows.Scan(&oid, &name); err != nil { return nil, err @@ -480,7 +480,7 @@ func (c *Conn) execPrepared(ctx context.Context, ps *PreparedStatement, argument } for i := range ps.FieldDescriptions { - if dt, ok := c.ConnInfo.DataTypeForOID(pgtype.OID(ps.FieldDescriptions[i].DataTypeOID)); ok { + if dt, ok := c.ConnInfo.DataTypeForOID(uint32(ps.FieldDescriptions[i].DataTypeOID)); ok { if _, ok := dt.Value.(pgtype.BinaryDecoder); ok { c.eqb.AppendResultFormat(BinaryFormatCode) } else { @@ -518,7 +518,7 @@ type QuerySimpleProtocol bool type QueryResultFormats []int16 // QueryResultFormatsByOID controls the result format (text=0, binary=1) of a query by the result column OID. -type QueryResultFormatsByOID map[pgtype.OID]int16 +type QueryResultFormatsByOID map[uint32]int16 // Query executes sql with args. If there is an error the returned Rows will be returned in an error state. So it is // allowed to ignore the error returned from Query and handle it in Rows. @@ -585,12 +585,12 @@ optionLoop: ps = &PreparedStatement{ Name: psd.Name, SQL: psd.SQL, - ParameterOIDs: make([]pgtype.OID, len(psd.ParamOIDs)), + ParameterOIDs: make([]uint32, len(psd.ParamOIDs)), FieldDescriptions: psd.Fields, } for i := range ps.ParameterOIDs { - ps.ParameterOIDs[i] = pgtype.OID(psd.ParamOIDs[i]) + ps.ParameterOIDs[i] = uint32(psd.ParamOIDs[i]) } } rows.sql = ps.SQL @@ -612,13 +612,13 @@ optionLoop: if resultFormatsByOID != nil { resultFormats = make([]int16, len(ps.FieldDescriptions)) for i := range resultFormats { - resultFormats[i] = resultFormatsByOID[pgtype.OID(ps.FieldDescriptions[i].DataTypeOID)] + resultFormats[i] = resultFormatsByOID[uint32(ps.FieldDescriptions[i].DataTypeOID)] } } if resultFormats == nil { for i := range ps.FieldDescriptions { - if dt, ok := c.ConnInfo.DataTypeForOID(pgtype.OID(ps.FieldDescriptions[i].DataTypeOID)); ok { + if dt, ok := c.ConnInfo.DataTypeForOID(uint32(ps.FieldDescriptions[i].DataTypeOID)); ok { if _, ok := dt.Value.(pgtype.BinaryDecoder); ok { c.eqb.AppendResultFormat(BinaryFormatCode) } else { @@ -651,7 +651,7 @@ func (c *Conn) SendBatch(ctx context.Context, b *Batch) BatchResults { for _, bi := range b.items { c.eqb.Reset() - var parameterOIDs []pgtype.OID + var parameterOIDs []uint32 ps := c.preparedStatements[bi.query] if ps != nil { @@ -678,7 +678,7 @@ func (c *Conn) SendBatch(ctx context.Context, b *Batch) BatchResults { if resultFormats == nil { for i := range ps.FieldDescriptions { - if dt, ok := c.ConnInfo.DataTypeForOID(pgtype.OID(ps.FieldDescriptions[i].DataTypeOID)); ok { + if dt, ok := c.ConnInfo.DataTypeForOID(uint32(ps.FieldDescriptions[i].DataTypeOID)); ok { if _, ok := dt.Value.(pgtype.BinaryDecoder); ok { c.eqb.AppendResultFormat(BinaryFormatCode) } else { diff --git a/conn_test.go b/conn_test.go index 0d25cb8d..f1128416 100644 --- a/conn_test.go +++ b/conn_test.go @@ -764,7 +764,7 @@ func TestConnInitConnInfo(t *testing.T) { defer closeConn(t, conn) // spot check that the standard postgres type names aren't qualified - nameOIDs := map[string]pgtype.OID{ + nameOIDs := map[string]uint32{ "_int8": pgtype.Int8ArrayOID, "int8": pgtype.Int8OID, "json": pgtype.JSONOID, @@ -829,7 +829,7 @@ func TestDomainType(t *testing.T) { t.Fatalf("Expected n to be 42, but was %v", n) } - var uint64OID pgtype.OID + var uint64OID uint32 err = conn.QueryRow(context.Background(), "select t.oid from pg_type t where t.typname='uint64';").Scan(&uint64OID) if err != nil { t.Fatalf("did not find uint64 OID, %v", err) diff --git a/copy_from.go b/copy_from.go index ec56b11f..44bb9f3e 100644 --- a/copy_from.go +++ b/copy_from.go @@ -7,7 +7,6 @@ import ( "io" "github.com/jackc/pgio" - "github.com/jackc/pgtype" errors "golang.org/x/xerrors" ) @@ -130,7 +129,7 @@ func (ct *copyFrom) buildCopyBuf(buf []byte, ps *PreparedStatement) (bool, []byt buf = pgio.AppendInt16(buf, int16(len(ct.columnNames))) for i, val := range values { - buf, err = encodePreparedStatementArgument(ct.conn.ConnInfo, buf, pgtype.OID(ps.FieldDescriptions[i].DataTypeOID), val) + buf, err = encodePreparedStatementArgument(ct.conn.ConnInfo, buf, uint32(ps.FieldDescriptions[i].DataTypeOID), val) if err != nil { return false, nil, err } diff --git a/extended_query_builder.go b/extended_query_builder.go index 7807ad1b..db9a0d73 100644 --- a/extended_query_builder.go +++ b/extended_query_builder.go @@ -17,7 +17,7 @@ type extendedQueryBuilder struct { resetCount int } -func (eqb *extendedQueryBuilder) AppendParam(ci *pgtype.ConnInfo, oid pgtype.OID, arg interface{}) error { +func (eqb *extendedQueryBuilder) AppendParam(ci *pgtype.ConnInfo, oid uint32, arg interface{}) error { f := chooseParameterFormatCode(ci, oid, arg) eqb.paramFormats = append(eqb.paramFormats, f) @@ -62,7 +62,7 @@ func (eqb *extendedQueryBuilder) Reset() { } -func (eqb *extendedQueryBuilder) encodeExtendedParamValue(ci *pgtype.ConnInfo, oid pgtype.OID, arg interface{}) ([]byte, error) { +func (eqb *extendedQueryBuilder) encodeExtendedParamValue(ci *pgtype.ConnInfo, oid uint32, arg interface{}) ([]byte, error) { if arg == nil { return nil, nil } diff --git a/go.mod b/go.mod index 0dc0c7e8..9ee7e172 100644 --- a/go.mod +++ b/go.mod @@ -4,24 +4,31 @@ go 1.12 require ( github.com/cockroachdb/apd v1.1.0 + github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect github.com/go-stack/stack v1.8.0 // indirect github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb github.com/jackc/pgio v1.0.0 github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711 - github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0 - github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b + github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90 + github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9 + github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect + github.com/kr/pty v1.1.8 // indirect + github.com/lib/pq v1.2.0 // indirect github.com/mattn/go-colorable v0.1.1 // indirect github.com/mattn/go-isatty v0.0.7 // indirect - github.com/rs/zerolog v1.13.0 + github.com/rs/zerolog v1.15.0 github.com/satori/go.uuid v1.2.0 github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 - github.com/sirupsen/logrus v1.4.1 + github.com/sirupsen/logrus v1.4.2 + github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.4.0 go.uber.org/atomic v1.4.0 // indirect - go.uber.org/zap v1.9.1 + go.uber.org/zap v1.10.0 golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 // indirect + golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 // indirect golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // indirect golang.org/x/text v0.3.2 // indirect + golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f // indirect golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec ) diff --git a/go.sum b/go.sum index bc0afd33..4b937b9e 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,8 @@ github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -26,20 +29,28 @@ github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711 h1:vZp4 github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0 h1:mX93v750WifMD1htCt7vqeolcnpaG1gz8URVGjSzcUM= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= +github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90 h1:aN5Vlwa2Q3QvxHDtZNi1x+GYkQyketBadMjtiug7AbM= +github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= +github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b h1:cIcUpcEP55F/QuZWEtXyqHoWk+IV4TBiLjtBkeq/Q1c= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9 h1:KLBBPU++1T3DHtm1B1QaIHy80Vhu0wNMErIFCNgAL8Y= +github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.0 h1:/5u4a+KGJptBRqGzPvYQL9p0d/tPR4S31+Tnzj9lEO4= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= @@ -49,21 +60,28 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0 h1:hSNcYHyxDWycfePW7pUI8swuFkcSMPKh3E63Pokg1Hk= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/rs/zerolog v1.15.0 h1:uPRuwkWF4J6fGsJ2R0Gn2jB1EQiav9k3S6CSdygQJXY= +github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 h1:pntxY8Ary0t43dCZ5dqY4YTJCObLY1kIXl0uzMv+7DE= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= @@ -72,12 +90,18 @@ go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a h1:Igim7XhdOpBnWPuYJ70XcNpq8q3BCACtVgNfoJxOV7g= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 h1:7KByu05hhLed2MO29w7p1XfZvZ13m8mub3shuVftRs0= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -85,6 +109,7 @@ golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e h1:nFYrTHrdrAOpShe27kaFHjsqYSEQ0KWqdWLu3xuZJts= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= @@ -92,6 +117,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373 h1:PPwnA7z1Pjf7XYaBP9GL1VAMZmcIWyFz7QCMSIIa3Bg= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522 h1:bhOzK9QyoD0ogCnFro1m2mz41+Ib0oOhfJnBp5MR4K4= diff --git a/large_objects.go b/large_objects.go index f58577fa..768c782c 100644 --- a/large_objects.go +++ b/large_objects.go @@ -4,7 +4,6 @@ import ( "context" "io" - "github.com/jackc/pgtype" errors "golang.org/x/xerrors" ) @@ -24,7 +23,7 @@ const ( ) // Create creates a new large object. If oid is zero, the server assigns an unused OID. -func (o *LargeObjects) Create(ctx context.Context, oid pgtype.OID) (pgtype.OID, error) { +func (o *LargeObjects) Create(ctx context.Context, oid uint32) (uint32, error) { _, err := o.tx.Prepare(ctx, "lo_create", "select lo_create($1)") if err != nil { return 0, err @@ -36,7 +35,7 @@ func (o *LargeObjects) Create(ctx context.Context, oid pgtype.OID) (pgtype.OID, // Open opens an existing large object with the given mode. ctx will also be used for all operations on the opened large // object. -func (o *LargeObjects) Open(ctx context.Context, oid pgtype.OID, mode LargeObjectMode) (*LargeObject, error) { +func (o *LargeObjects) Open(ctx context.Context, oid uint32, mode LargeObjectMode) (*LargeObject, error) { _, err := o.tx.Prepare(ctx, "lo_open", "select lo_open($1, $2)") if err != nil { return nil, err @@ -51,7 +50,7 @@ func (o *LargeObjects) Open(ctx context.Context, oid pgtype.OID, mode LargeObjec } // Unlink removes a large object from the database. -func (o *LargeObjects) Unlink(ctx context.Context, oid pgtype.OID) error { +func (o *LargeObjects) Unlink(ctx context.Context, oid uint32) error { _, err := o.tx.Prepare(ctx, "lo_unlink", "select lo_unlink($1)") if err != nil { return err diff --git a/pgmock/pgmock.go b/pgmock/pgmock.go index 366c3c9c..d1827d96 100644 --- a/pgmock/pgmock.go +++ b/pgmock/pgmock.go @@ -252,7 +252,7 @@ where ( } rowVals := []struct { - oid pgtype.OID + oid uint32 name string }{ {16, "bool"}, diff --git a/query_test.go b/query_test.go index a7e98ed3..91cc744a 100644 --- a/query_test.go +++ b/query_test.go @@ -505,7 +505,7 @@ func TestQueryRowCoreTypes(t *testing.T) { f64 float64 b bool t time.Time - oid pgtype.OID + oid uint32 } var actual, zero allTypes @@ -523,7 +523,7 @@ func TestQueryRowCoreTypes(t *testing.T) { {"select $1::timestamptz", []interface{}{time.Unix(123, 5000)}, []interface{}{&actual.t}, allTypes{t: time.Unix(123, 5000)}}, {"select $1::timestamp", []interface{}{time.Date(2010, 1, 2, 3, 4, 5, 0, time.UTC)}, []interface{}{&actual.t}, allTypes{t: time.Date(2010, 1, 2, 3, 4, 5, 0, time.UTC)}}, {"select $1::date", []interface{}{time.Date(1987, 1, 2, 0, 0, 0, 0, time.UTC)}, []interface{}{&actual.t}, allTypes{t: time.Date(1987, 1, 2, 0, 0, 0, 0, time.UTC)}}, - {"select $1::oid", []interface{}{pgtype.OID(42)}, []interface{}{&actual.oid}, allTypes{oid: 42}}, + {"select $1::oid", []interface{}{uint32(42)}, []interface{}{&actual.oid}, allTypes{oid: 42}}, } for i, tt := range tests { diff --git a/rows.go b/rows.go index 97f152fe..ce100e97 100644 --- a/rows.go +++ b/rows.go @@ -189,7 +189,7 @@ func (rows *connRows) Scan(dest ...interface{}) error { continue } - err := rows.connInfo.Scan(pgtype.OID(fd.DataTypeOID), fd.Format, buf, d) + err := rows.connInfo.Scan(uint32(fd.DataTypeOID), fd.Format, buf, d) if err != nil { rows.fatal(scanArgError{col: i, err: err}) return err @@ -214,7 +214,7 @@ func (rows *connRows) Values() ([]interface{}, error) { continue } - if dt, ok := rows.connInfo.DataTypeForOID(pgtype.OID(fd.DataTypeOID)); ok { + if dt, ok := rows.connInfo.DataTypeForOID(uint32(fd.DataTypeOID)); ok { value := reflect.New(reflect.ValueOf(dt.Value).Elem().Type()).Interface().(pgtype.Value) switch fd.Format { diff --git a/stdlib/sql.go b/stdlib/sql.go index 701d6b2e..fb2732cf 100644 --- a/stdlib/sql.go +++ b/stdlib/sql.go @@ -312,7 +312,7 @@ func (r *Rows) Columns() []string { // ColumnTypeDatabaseTypeName return the database system type name. func (r *Rows) ColumnTypeDatabaseTypeName(index int) string { - if dt, ok := r.conn.conn.ConnInfo.DataTypeForOID(pgtype.OID(r.rows.FieldDescriptions()[index].DataTypeOID)); ok { + if dt, ok := r.conn.conn.ConnInfo.DataTypeForOID(uint32(r.rows.FieldDescriptions()[index].DataTypeOID)); ok { return strings.ToUpper(dt.Name) } diff --git a/values.go b/values.go index d6a5b9fb..570dc793 100644 --- a/values.go +++ b/values.go @@ -124,7 +124,7 @@ func convertSimpleArgument(ci *pgtype.ConnInfo, arg interface{}) (interface{}, e return nil, SerializationError(fmt.Sprintf("Cannot encode %T in simple protocol - %T must implement driver.Valuer, pgtype.TextEncoder, or be a native type", arg, arg)) } -func encodePreparedStatementArgument(ci *pgtype.ConnInfo, buf []byte, oid pgtype.OID, arg interface{}) ([]byte, error) { +func encodePreparedStatementArgument(ci *pgtype.ConnInfo, buf []byte, oid uint32, arg interface{}) ([]byte, error) { if arg == nil { return pgio.AppendInt32(buf, -1), nil } @@ -209,7 +209,7 @@ func encodePreparedStatementArgument(ci *pgtype.ConnInfo, buf []byte, oid pgtype // chooseParameterFormatCode determines the correct format code for an // argument to a prepared statement. It defaults to TextFormatCode if no // determination can be made. -func chooseParameterFormatCode(ci *pgtype.ConnInfo, oid pgtype.OID, arg interface{}) int16 { +func chooseParameterFormatCode(ci *pgtype.ConnInfo, oid uint32, arg interface{}) int16 { switch arg.(type) { case pgtype.BinaryEncoder: return BinaryFormatCode