Skip to content

Commit

Permalink
[pg15] fix: Add text-vs-name cross-type operators, and unify name_ops…
Browse files Browse the repository at this point in the history
… with text_ops for LSM AM

Summary: PG in commit 2ece7c07dc9a14667c64f107686573590b7e45c3 merged name_ops opfamily into text_ops, allowing cross-type comparisons. Do the same for YB by merging lsm/name_ops opfamily into lsm/text_ops.

Test Plan:
Jenkins: rebase: pg15

The below query correctly takes the index scan path with this change:

```
EXPLAIN (COSTS FALSE) SELECT relname, relkind FROM pg_class WHERE relname LIKE 'pushdown_c%';
```
As a result, the test below now passes.
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPushdown'

Reviewers: jason

Reviewed By: jason

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D31979
  • Loading branch information
arpang committed Jan 28, 2024
1 parent cf176f4 commit 29d735d
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 23 deletions.
1 change: 1 addition & 0 deletions pg15_tests/passing_java.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ org.yb.pgsql.TestPgRegressGin
org.yb.pgsql.TestPgRegressHashInQueries
org.yb.pgsql.TestPgRegressMisc#testPgRegressMiscSerial2
org.yb.pgsql.TestPgRegressNonTxnCopy
org.yb.pgsql.TestPgRegressPushdown#testPgRegressPushdown
org.yb.pgsql.TestPgRegressSecondaryIndexScan
org.yb.pgsql.TestPgRegressTabletSplit
org.yb.pgsql.TestPgRegressTypesNumeric
Expand Down
3 changes: 2 additions & 1 deletion pg15_tests/test_D31292.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ grep_in_java_test \

failing_java_test 'TestPgRegressPgMiscIndependent'
grep_in_java_test \
'failed tests: [yb_pg_alter_generic, yb_pg_dbsize, yb_pg_identity, yb_pg_index_including, yb_pg_misc, yb_pg_sequence]' \
'failed tests: [yb_pg_dbsize, yb_pg_identity, yb_pg_index_including, yb_pg_misc, yb_pg_sequence]' \
'TestPgRegressPgMiscIndependent'

55 changes: 41 additions & 14 deletions src/postgres/src/include/catalog/pg_amop.dat
Original file line number Diff line number Diff line change
Expand Up @@ -3514,40 +3514,67 @@
amoprighttype => 'char', amopstrategy => '5', amopopr => '>(char,char)',
amopmethod => 'lsm' },

# lsm name_ops
# lsm text_ops

{ amopfamily => 'lsm/name_ops', amoplefttype => 'name',
{ amopfamily => 'lsm/text_ops', amoplefttype => 'text',
amoprighttype => 'text', amopstrategy => '1', amopopr => '<(text,text)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'text',
amoprighttype => 'text', amopstrategy => '2', amopopr => '<=(text,text)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'text',
amoprighttype => 'text', amopstrategy => '3', amopopr => '=(text,text)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'text',
amoprighttype => 'text', amopstrategy => '4', amopopr => '>=(text,text)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'text',
amoprighttype => 'text', amopstrategy => '5', amopopr => '>(text,text)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'name',
amoprighttype => 'name', amopstrategy => '1', amopopr => '<(name,name)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/name_ops', amoplefttype => 'name',
{ amopfamily => 'lsm/text_ops', amoplefttype => 'name',
amoprighttype => 'name', amopstrategy => '2', amopopr => '<=(name,name)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/name_ops', amoplefttype => 'name',
{ amopfamily => 'lsm/text_ops', amoplefttype => 'name',
amoprighttype => 'name', amopstrategy => '3', amopopr => '=(name,name)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/name_ops', amoplefttype => 'name',
{ amopfamily => 'lsm/text_ops', amoplefttype => 'name',
amoprighttype => 'name', amopstrategy => '4', amopopr => '>=(name,name)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/name_ops', amoplefttype => 'name',
{ amopfamily => 'lsm/text_ops', amoplefttype => 'name',
amoprighttype => 'name', amopstrategy => '5', amopopr => '>(name,name)',
amopmethod => 'lsm' },

# lsm text_ops

{ amopfamily => 'lsm/text_ops', amoplefttype => 'name',
amoprighttype => 'text', amopstrategy => '1', amopopr => '<(name,text)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'name',
amoprighttype => 'text', amopstrategy => '2', amopopr => '<=(name,text)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'name',
amoprighttype => 'text', amopstrategy => '3', amopopr => '=(name,text)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'name',
amoprighttype => 'text', amopstrategy => '4', amopopr => '>=(name,text)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'name',
amoprighttype => 'text', amopstrategy => '5', amopopr => '>(name,text)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'text',
amoprighttype => 'text', amopstrategy => '1', amopopr => '<(text,text)',
amoprighttype => 'name', amopstrategy => '1', amopopr => '<(text,name)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'text',
amoprighttype => 'text', amopstrategy => '2', amopopr => '<=(text,text)',
amoprighttype => 'name', amopstrategy => '2', amopopr => '<=(text,name)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'text',
amoprighttype => 'text', amopstrategy => '3', amopopr => '=(text,text)',
amoprighttype => 'name', amopstrategy => '3', amopopr => '=(text,name)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'text',
amoprighttype => 'text', amopstrategy => '4', amopopr => '>=(text,text)',
amoprighttype => 'name', amopstrategy => '4', amopopr => '>=(text,name)',
amopmethod => 'lsm' },
{ amopfamily => 'lsm/text_ops', amoplefttype => 'text',
amoprighttype => 'text', amopstrategy => '5', amopopr => '>(text,text)',
amoprighttype => 'name', amopstrategy => '5', amopopr => '>(text,name)',
amopmethod => 'lsm' },

# lsm bpchar_ops
Expand Down
12 changes: 8 additions & 4 deletions src/postgres/src/include/catalog/pg_amproc.dat
Original file line number Diff line number Diff line change
Expand Up @@ -2117,10 +2117,6 @@
{ amprocfamily => 'lsm/macaddr_ops', amproclefttype => 'macaddr',
amprocrighttype => 'macaddr', amprocnum => '2',
amproc => 'macaddr_sortsupport' },
{ amprocfamily => 'lsm/name_ops', amproclefttype => 'name',
amprocrighttype => 'name', amprocnum => '1', amproc => 'btnamecmp' },
{ amprocfamily => 'lsm/name_ops', amproclefttype => 'name',
amprocrighttype => 'name', amprocnum => '2', amproc => 'btnamesortsupport' },
{ amprocfamily => 'lsm/numeric_ops', amproclefttype => 'numeric',
amprocrighttype => 'numeric', amprocnum => '1', amproc => 'numeric_cmp' },
{ amprocfamily => 'lsm/numeric_ops', amproclefttype => 'numeric',
Expand All @@ -2140,6 +2136,14 @@
amprocrighttype => 'text', amprocnum => '1', amproc => 'bttextcmp' },
{ amprocfamily => 'lsm/text_ops', amproclefttype => 'text',
amprocrighttype => 'text', amprocnum => '2', amproc => 'bttextsortsupport' },
{ amprocfamily => 'lsm/text_ops', amproclefttype => 'name',
amprocrighttype => 'name', amprocnum => '1', amproc => 'btnamecmp' },
{ amprocfamily => 'lsm/text_ops', amproclefttype => 'name',
amprocrighttype => 'name', amprocnum => '2', amproc => 'btnamesortsupport' },
{ amprocfamily => 'lsm/text_ops', amproclefttype => 'name',
amprocrighttype => 'text', amprocnum => '1', amproc => 'btnametextcmp' },
{ amprocfamily => 'lsm/text_ops', amproclefttype => 'text',
amprocrighttype => 'name', amprocnum => '1', amproc => 'bttextnamecmp' },
{ amprocfamily => 'lsm/time_ops', amproclefttype => 'time',
amprocrighttype => 'time', amprocnum => '1', amproc => 'time_cmp' },
{ amprocfamily => 'lsm/time_ops', amproclefttype => 'time',
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src/include/catalog/pg_opclass.dat
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@
{ opcmethod => 'lsm', opcname => 'macaddr8_ops',
opcfamily => 'lsm/macaddr8_ops', opcintype => 'macaddr8' },
{ opcmethod => 'lsm', opcname => 'name_ops',
opcfamily => 'lsm/name_ops', opcintype => 'name' },
opcfamily => 'lsm/text_ops', opcintype => 'name' },
{ oid => '9944', oid_symbol => 'NUMERIC_LSM_OPS_OID',
opcmethod => 'lsm', opcname => 'numeric_ops',
opcfamily => 'lsm/numeric_ops', opcintype => 'numeric' },
Expand Down
3 changes: 1 addition & 2 deletions src/postgres/src/include/catalog/pg_opfamily.dat
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@
opfmethod => 'lsm', opfname => 'macaddr_ops' },
{ oid => '9915',
opfmethod => 'lsm', opfname => 'macaddr8_ops' },
{ oid => '9916', oid_symbol => 'NAME_LSM_FAM_OID',
opfmethod => 'lsm', opfname => 'name_ops' },
# YB_TODO: OID 9916 is unused
{ oid => '9917',
opfmethod => 'lsm', opfname => 'numeric_ops' },
{ oid => '9918', oid_symbol => 'OID_LSM_FAM_OID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ EXPLAIN (COSTS FALSE) SELECT relname, relkind FROM pg_class WHERE relname LIKE '
QUERY PLAN
--------------------------------------------------------------------------------
Index Scan using pg_class_relname_nsp_index on pg_class
Index Cond: ((relname >= 'pushdown'::name) AND (relname < 'pushdowo'::name))
Index Cond: ((relname >= 'pushdown'::text) AND (relname < 'pushdowo'::text))
Filter: (relname ~~ 'pushdown_c%'::text)
(3 rows)

Expand Down

0 comments on commit 29d735d

Please sign in to comment.