diff --git a/pkg/cmd/roachtest/pgjdbc_blacklist.go b/pkg/cmd/roachtest/pgjdbc_blacklist.go index 4317b95a00a8..fcb826100fff 100644 --- a/pkg/cmd/roachtest/pgjdbc_blacklist.go +++ b/pkg/cmd/roachtest/pgjdbc_blacklist.go @@ -1279,8 +1279,6 @@ var pgjdbcBlackList19_2 = blacklist{ "org.postgresql.test.jdbc4.DatabaseMetaDataTest.testGetFunctionsWithBlankPatterns": "unknown", "org.postgresql.test.jdbc4.DatabaseMetaDataTest.testGetFunctionsWithSpecificTypes": "17511", "org.postgresql.test.jdbc4.IsValidTest.testIsValidRemoteClose": "35897", - "org.postgresql.test.jdbc4.JsonbTest.testJsonbNonPreparedStatement": "40855", - "org.postgresql.test.jdbc4.JsonbTest.testJsonbPreparedStatement": "40855", "org.postgresql.test.jdbc4.PGCopyInputStreamTest.testReadBytesCorrectlyHandlesEof": "unknown", "org.postgresql.test.jdbc4.PGCopyInputStreamTest.testReadBytesCorrectlyReadsDataInChunks": "unknown", "org.postgresql.test.jdbc4.PGCopyInputStreamTest.testStreamCanBeClosedAfterReadUp": "unknown", diff --git a/pkg/sql/parser/parse_test.go b/pkg/sql/parser/parse_test.go index 7a2a659dee89..f28b93fc075f 100644 --- a/pkg/sql/parser/parse_test.go +++ b/pkg/sql/parser/parse_test.go @@ -2107,6 +2107,13 @@ func TestParse2(t *testing.T) { {`CREATE TABLE a (b INT) PARTITION BY RANGE (b) (PARTITION p1 VALUES FROM (MINVALUE) TO (1), PARTITION p2 VALUES FROM (2, MAXVALUE) TO (4, 4), PARTITION p3 VALUES FROM (4, 4) TO (MAXVALUE))`, `CREATE TABLE a (b INT8) PARTITION BY RANGE (b) (PARTITION p1 VALUES FROM (minvalue) TO (1), PARTITION p2 VALUES FROM (2, maxvalue) TO (4, 4), PARTITION p3 VALUES FROM (4, 4) TO (maxvalue))`}, + + // Check that JSONB operators have higher precedence than '='. + {`SELECT '{}'::JSONB ? 'a' = false`, `SELECT ('{}'::JSONB ? 'a') = false`}, + {`SELECT '{}'::JSONB ?| 'a' = false`, `SELECT ('{}'::JSONB ?| 'a') = false`}, + {`SELECT '{}'::JSONB ?& 'a' = false`, `SELECT ('{}'::JSONB ?& 'a') = false`}, + {`SELECT '{}'::JSONB @> '{}'::JSONB = false`, `SELECT ('{}'::JSONB @> '{}'::JSONB) = false`}, + {`SELECT '{}'::JSONB <@ '{}'::JSONB = false`, `SELECT ('{}'::JSONB <@ '{}'::JSONB) = false`}, } for _, d := range testData { t.Run(d.sql, func(t *testing.T) { diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index 94115495973a..542d03728963 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -1017,9 +1017,10 @@ func newNameFromStr(s string) *tree.Name { %left AND %right NOT %nonassoc IS ISNULL NOTNULL // IS sets precedence for IS NULL, etc -%nonassoc '<' '>' '=' LESS_EQUALS GREATER_EQUALS NOT_EQUALS CONTAINS CONTAINED_BY '?' JSON_SOME_EXISTS JSON_ALL_EXISTS +%nonassoc '<' '>' '=' LESS_EQUALS GREATER_EQUALS NOT_EQUALS %nonassoc '~' BETWEEN IN LIKE ILIKE SIMILAR NOT_REGMATCH REGIMATCH NOT_REGIMATCH NOT_LA %nonassoc ESCAPE // ESCAPE must be just above LIKE/ILIKE/SIMILAR +%nonassoc CONTAINS CONTAINED_BY '?' JSON_SOME_EXISTS JSON_ALL_EXISTS %nonassoc OVERLAPS %left POSTFIXOP // dummy for postfix OP rules // To support target_elem without AS, we must give IDENT an explicit priority