@@ -28,6 +28,7 @@ import (
2828)
2929
3030func TestReconnect (t * testing.T ) {
31+ pqtest .SkipCockroach (t ) // Doesn't implement pg_terminate_backend()
3132 t .Parallel ()
3233 db := pqtest .MustDB (t )
3334 tx := pqtest .Begin (t , db )
@@ -655,6 +656,7 @@ func TestErrorOnQueryRowSimpleQuery(t *testing.T) {
655656
656657// Test the QueryRow bug workarounds in stmt.exec() and simpleQuery()
657658func TestQueryRowBugWorkaround (t * testing.T ) {
659+ pqtest .SkipCockroach (t ) // check_function_bodies=false doesn't really work
658660 db := pqtest .MustDB (t )
659661
660662 pqtest .Exec (t , db , "create temp table notnulltemp (a varchar(10) not null)" )
@@ -805,7 +807,7 @@ func TestExecNoData(t *testing.T) { // See #186
805807
806808 // Exec() a query which returns results
807809 pqtest .Exec (t , db , "values (1), (2), (3)" )
808- pqtest .Exec (t , db , "values ($1), ($2), ($3)" , 1 , 2 , 3 )
810+ pqtest .Exec (t , db , "values ($1::int ), ($2::int ), ($3::int )" , 1 , 2 , 3 )
809811
810812 // Query() a query which doesn't return any results
811813 tx := pqtest .Begin (t , db )
@@ -816,11 +818,13 @@ func TestExecNoData(t *testing.T) { // See #186
816818 t .Errorf ("\n have: %#v\n want: %#v" , have , want )
817819 }
818820
819- // Get NoData from a parameterized query.
820- pqtest .Exec (t , tx , `create rule nodata as on insert to foo do instead nothing` )
821- have = pqtest .QueryRow [any ](t , tx , `insert into foo values ($1)` , 1 )
822- if ! reflect .DeepEqual (have , want ) {
823- t .Errorf ("\n have: %#v\n want: %#v" , have , want )
821+ if ! pqtest .Cockroach () { // "unimplemented: this syntax (0A000)"
822+ // Get NoData from a parameterized query.
823+ pqtest .Exec (t , tx , `create rule nodata as on insert to foo do instead nothing` )
824+ have = pqtest .QueryRow [any ](t , tx , `insert into foo values ($1)` , 1 )
825+ if ! reflect .DeepEqual (have , want ) {
826+ t .Errorf ("\n have: %#v\n want: %#v" , have , want )
827+ }
824828 }
825829}
826830
@@ -841,11 +845,18 @@ func TestIssue282(t *testing.T) {
841845}
842846
843847func TestFloatPrecision (t * testing.T ) { // See #196
848+ // encode() sends float32 as a float64, which adds extra precision: 0.10000122338533401
849+ // This is done by driver.DefaultParameterConverter(); we can maybe fix it,
850+ // but it's really a cockroach bug.
851+ // https://github.com/cockroachdb/cockroach/issues/73743
852+ // https://github.com/cockroachdb/cockroach/issues/84326
853+ pqtest .SkipCockroach (t )
854+
844855 t .Parallel ()
845856 db := pqtest .MustDB (t )
846857
847- have := pqtest .Query [bool ](t , db , `select '0.10000122'::float4 = $1 as f4, '35.03554004971999'::float8 = $2 as f8` ,
848- float32 (0.10000122 ), float64 (35.03554004971999 ))[ 0 ]
858+ have := pqtest .QueryRow [bool ](t , db , `select '0.10000122'::float4 = $1::float4 as f4, '35.03554004971999'::float8 = $2 as f8` ,
859+ float32 (0.10000122 ), float64 (35.03554004971999 ))
849860 want := map [string ]bool {"f4" : true , "f8" : true }
850861 if ! reflect .DeepEqual (have , want ) {
851862 t .Errorf ("\n have: %#v\n want: %#v" , have , want )
@@ -1106,7 +1117,7 @@ func TestStmtQueryContext(t *testing.T) {
11061117 func () (context.Context , context.CancelFunc ) {
11071118 return context .WithTimeout (context .Background (), 50 * time .Millisecond )
11081119 },
1109- `pq: canceling statement due to user request (57014)` ,
1120+ `or: pq: canceling statement due to user request (57014)|pq: query execution canceled (57014)` ,
11101121 },
11111122 {"select pg_sleep(0.05)" ,
11121123 func () (context.Context , context.CancelFunc ) {
@@ -1150,7 +1161,7 @@ func TestStmtExecContext(t *testing.T) {
11501161 func () (context.Context , context.CancelFunc ) {
11511162 return context .WithTimeout (context .Background (), 50 * time .Millisecond )
11521163 },
1153- `pq: canceling statement due to user request (57014)` ,
1164+ `or: pq: canceling statement due to user request (57014)|pq: query execution canceled (57014)` ,
11541165 },
11551166 {"select pg_sleep(0.05)" ,
11561167 func () (context.Context , context.CancelFunc ) {
@@ -1361,6 +1372,12 @@ func TestTxOptions(t *testing.T) {
13611372 // go18_test.go:306: read/[write,only] not set: true != off for level serializable
13621373 // go18_test.go:296: wrong isolation level: read committed != serializable
13631374 pqtest .SkipPgpool (t )
1375+ // TODO: fails with:
1376+ // conn_test.go:1724: wrong isolation level: read committed != read uncommitted
1377+ // conn_test.go:1724: wrong isolation level: read committed != read uncommitted
1378+ // conn_test.go:1724: wrong isolation level: serializable != repeatable read
1379+ // conn_test.go:1724: wrong isolation level: serializable != repeatable read
1380+ pqtest .SkipCockroach (t )
13641381
13651382 db := pqtest .MustDB (t )
13661383 ctx := context .Background ()
@@ -1424,7 +1441,8 @@ func TestTxOptions(t *testing.T) {
14241441
14251442func TestPing (t * testing.T ) {
14261443 t .Parallel ()
1427- pqtest .SkipPgpool (t ) // TODO: hangs forever?
1444+ pqtest .SkipPgpool (t ) // TODO: hangs forever?
1445+ pqtest .SkipCockroach (t ) // Doesn't implement pg_terminate_backend()
14281446
14291447 ctx , cancel := context .WithCancel (context .Background ())
14301448 defer cancel ()
@@ -1534,19 +1552,19 @@ func TestAuth(t *testing.T) {
15341552 tests := []struct {
15351553 conn , wantErr string
15361554 }{
1537- {"user=pqgomd5" , `password authentication failed for user "pqgomd5"` },
1538- {"user=pqgopassword" , `empty password returned by client` },
1539- {"user=pqgoscram" , `password authentication failed for user "pqgoscram"` },
1555+ {"user=pqgomd5" , `re: password authentication failed for user "? pqgomd5"? ` },
1556+ {"user=pqgopassword" , `or: empty password returned by client|password authentication failed for user pqgopassword ` },
1557+ {"user=pqgoscram" , `re: password authentication failed for user "? pqgoscram"? ` },
15401558
1541- {"user=pqgomd5 password=wrong" , `password authentication failed for user "pqgomd5"` },
1542- {"user=pqgopassword password=wrong" , `password authentication failed for user "pqgopassword"` },
1543- {"user=pqgoscram password=wrong" , `password authentication failed for user "pqgoscram"` },
1559+ {"user=pqgomd5 password=wrong" , `re: password authentication failed for user "? pqgomd5"? ` },
1560+ {"user=pqgopassword password=wrong" , `re: password authentication failed for user "? pqgopassword"? ` },
1561+ {"user=pqgoscram password=wrong" , `re: password authentication failed for user "? pqgoscram"? ` },
15441562
15451563 {"user=pqgomd5 password=wordpass" , `` },
15461564 {"user=pqgopassword password=wordpass" , `` },
15471565 {"user=pqgoscram password=wordpass" , `` },
15481566
1549- {"user=pqgounknown password=wordpass" , `role "pqgounknown" does not exist` },
1567+ {"user=pqgounknown password=wordpass" , `or: role "pqgounknown" does not exist|password authentication failed for user pqgounknown ` },
15501568 }
15511569
15521570 for _ , tt := range tests {
@@ -1603,6 +1621,10 @@ func TestBytea(t *testing.T) {
16031621}
16041622
16051623func TestJSONRawMessage (t * testing.T ) {
1624+ if pqtest .ForceBinaryParameters () {
1625+ // "expected JSONB version 1 (08P01)" – looks like it always expects jsonb (instead of json)?
1626+ pqtest .SkipCockroach (t ) // TODO: can probably fix
1627+ }
16061628 db := pqtest .MustDB (t )
16071629
16081630 pqtest .Exec (t , db , `create temp table tbl (j json)` )
@@ -1611,10 +1633,11 @@ func TestJSONRawMessage(t *testing.T) {
16111633 // not converted to a PostgreSQL array. This was a bug in CheckNamedValue
16121634 // where named byte slice types would hit the reflect.Slice case and get
16131635 // incorrectly converted to a PostgreSQL array.
1614- data := json .RawMessage (`{"key":"value"}` )
1636+ data := json .RawMessage (`{"key": "value"}` )
16151637 pqtest .Exec (t , db , `insert into tbl values ($1)` , data )
16161638
16171639 have := pqtest .QueryRow [json.RawMessage ](t , db , `select j from tbl` )
1640+ have ["j" ] = bytes .ReplaceAll (have ["j" ], []byte (`":"` ), []byte (`": "` )) // Cockroach adds a space
16181641 want := map [string ]json.RawMessage {"j" : data }
16191642 if ! reflect .DeepEqual (have , want ) {
16201643 t .Errorf ("\n have: %#v\n want: %#v" , have , want )
0 commit comments