From 29d735d21131f121ea68afd2634306e100ffbe52 Mon Sep 17 00:00:00 2001 From: Arpan Agrawal Date: Sat, 27 Jan 2024 19:12:11 +0530 Subject: [PATCH] [pg15] fix: Add text-vs-name cross-type operators, and unify name_ops 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 --- pg15_tests/passing_java.tsv | 1 + pg15_tests/test_D31292.sh | 3 +- src/postgres/src/include/catalog/pg_amop.dat | 55 ++++++++++++++----- .../src/include/catalog/pg_amproc.dat | 12 ++-- .../src/include/catalog/pg_opclass.dat | 2 +- .../src/include/catalog/pg_opfamily.dat | 3 +- .../expected/yb_select_no_pushdown.out | 2 +- 7 files changed, 55 insertions(+), 23 deletions(-) diff --git a/pg15_tests/passing_java.tsv b/pg15_tests/passing_java.tsv index 5514d96b8afb..05e0041a796a 100644 --- a/pg15_tests/passing_java.tsv +++ b/pg15_tests/passing_java.tsv @@ -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 diff --git a/pg15_tests/test_D31292.sh b/pg15_tests/test_D31292.sh index edff88b94410..890af9588897 100755 --- a/pg15_tests/test_D31292.sh +++ b/pg15_tests/test_D31292.sh @@ -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' + \ No newline at end of file diff --git a/src/postgres/src/include/catalog/pg_amop.dat b/src/postgres/src/include/catalog/pg_amop.dat index e7e7575537f2..e3842a5e0d98 100644 --- a/src/postgres/src/include/catalog/pg_amop.dat +++ b/src/postgres/src/include/catalog/pg_amop.dat @@ -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 diff --git a/src/postgres/src/include/catalog/pg_amproc.dat b/src/postgres/src/include/catalog/pg_amproc.dat index a9fe84177dd7..67a9386fea18 100644 --- a/src/postgres/src/include/catalog/pg_amproc.dat +++ b/src/postgres/src/include/catalog/pg_amproc.dat @@ -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', @@ -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', diff --git a/src/postgres/src/include/catalog/pg_opclass.dat b/src/postgres/src/include/catalog/pg_opclass.dat index cfb8b2e8845c..3294a7714420 100644 --- a/src/postgres/src/include/catalog/pg_opclass.dat +++ b/src/postgres/src/include/catalog/pg_opclass.dat @@ -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' }, diff --git a/src/postgres/src/include/catalog/pg_opfamily.dat b/src/postgres/src/include/catalog/pg_opfamily.dat index f4a57c2bb9dc..25de8946e302 100644 --- a/src/postgres/src/include/catalog/pg_opfamily.dat +++ b/src/postgres/src/include/catalog/pg_opfamily.dat @@ -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', diff --git a/src/postgres/src/test/regress/expected/yb_select_no_pushdown.out b/src/postgres/src/test/regress/expected/yb_select_no_pushdown.out index a7f85ce7c55d..022c31993de8 100644 --- a/src/postgres/src/test/regress/expected/yb_select_no_pushdown.out +++ b/src/postgres/src/test/regress/expected/yb_select_no_pushdown.out @@ -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)