From 537536b021542172bc1e8ded2d7c674c57185106 Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Tue, 15 Jul 2025 06:47:27 +0000 Subject: [PATCH 1/3] Dump Babelfish operator classes for numeric-fixeddecimal comparisons to support index scan Signed-off-by: Tanya Gupta --- src/bin/pg_dump/dump_babel_utils.c | 38 +++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_dump/dump_babel_utils.c b/src/bin/pg_dump/dump_babel_utils.c index ec59fd670aa..9eb40ca522b 100644 --- a/src/bin/pg_dump/dump_babel_utils.c +++ b/src/bin/pg_dump/dump_babel_utils.c @@ -1777,7 +1777,9 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int4_numeric_ops\"" : "sys.int4_numeric_ops") != 0 && pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int4_ops\"" : "sys.numeric_int4_ops") != 0 && pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int8_numeric_ops\"" : "sys.int8_numeric_ops") != 0 && - pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int8_ops\"" : "sys.numeric_int8_ops") != 0) + pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int8_ops\"" : "sys.numeric_int8_ops") != 0 && + pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_fixeddecimal_ops\"" : "sys.numeric_fixeddecimal_ops") != 0 && + pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"fixeddecimal_numeric_ops\"" : "sys.fixeddecimal_numeric_ops") != 0) return; query = createPQExpBuffer(); @@ -1922,6 +1924,40 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe "FUNCTION 1 sys.numeric_int8_cmp(numeric, int8) "; } + if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_fixeddecimal_ops\"" : "sys.numeric_fixeddecimal_ops") == 0) + { + str = quote_all_identifiers ? + "OPERATOR 1 \"sys\".< (numeric, fixeddecimal) ,\n " + "OPERATOR 2 \"sys\".<= (numeric, fixeddecimal) ,\n " + "OPERATOR 3 \"sys\".= (numeric, fixeddecimal) ,\n " + "OPERATOR 4 \"sys\".>= (numeric, fixeddecimal) ,\n " + "OPERATOR 5 \"sys\".> (numeric, fixeddecimal) ,\n " + "FUNCTION 1 \"sys\".\"numeric_fixeddecimal_cmp\"(numeric, fixeddecimal) " : + "OPERATOR 1 sys.< (numeric, fixeddecimal) ,\n " + "OPERATOR 2 sys.<= (numeric, fixeddecimal) ,\n " + "OPERATOR 3 sys.= (numeric, fixeddecimal) ,\n " + "OPERATOR 4 sys.>= (numeric, fixeddecimal) ,\n " + "OPERATOR 5 sys.> (numeric, fixeddecimal) ,\n " + "FUNCTION 1 sys.numeric_fixeddecimal_cmp(numeric, fixeddecimal) "; + } + + if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"fixeddecimal_numeric_ops\"" : "sys.fixeddecimal_numeric_ops") == 0) + { + str = quote_all_identifiers ? + "OPERATOR 1 \"sys\".< (fixeddecimal, numeric) ,\n " + "OPERATOR 2 \"sys\".<= (fixeddecimal, numeric) ,\n " + "OPERATOR 3 \"sys\".= (fixeddecimal, numeric) ,\n " + "OPERATOR 4 \"sys\".>= (fixeddecimal, numeric) ,\n " + "OPERATOR 5 \"sys\".> (fixeddecimal, numeric) ,\n " + "FUNCTION 1 \"sys\".\"fixeddecimal_numeric_cmp\"(fixeddecimal, numeric) " : + "OPERATOR 1 sys.< (fixeddecimal, numeric) ,\n " + "OPERATOR 2 sys.<= (fixeddecimal, numeric) ,\n " + "OPERATOR 3 sys.= (fixeddecimal, numeric) ,\n " + "OPERATOR 4 sys.>= (fixeddecimal, numeric) ,\n " + "OPERATOR 5 sys.> (fixeddecimal, numeric) ,\n " + "FUNCTION 1 sys.fixeddecimal_numeric_cmp(fixeddecimal, numeric) "; + } + if(str != NULL) appendPQExpBufferStr(buff, str); From c6ffcb777b685a75b98cf432cce0e25a7579b58f Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Tue, 15 Jul 2025 09:14:25 +0000 Subject: [PATCH 2/3] appeding sys to fixeddecimal for dump-restore Signed-off-by: Tanya Gupta --- src/bin/pg_dump/dump_babel_utils.c | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/bin/pg_dump/dump_babel_utils.c b/src/bin/pg_dump/dump_babel_utils.c index 9eb40ca522b..992cde488c1 100644 --- a/src/bin/pg_dump/dump_babel_utils.c +++ b/src/bin/pg_dump/dump_babel_utils.c @@ -1927,35 +1927,35 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_fixeddecimal_ops\"" : "sys.numeric_fixeddecimal_ops") == 0) { str = quote_all_identifiers ? - "OPERATOR 1 \"sys\".< (numeric, fixeddecimal) ,\n " - "OPERATOR 2 \"sys\".<= (numeric, fixeddecimal) ,\n " - "OPERATOR 3 \"sys\".= (numeric, fixeddecimal) ,\n " - "OPERATOR 4 \"sys\".>= (numeric, fixeddecimal) ,\n " - "OPERATOR 5 \"sys\".> (numeric, fixeddecimal) ,\n " - "FUNCTION 1 \"sys\".\"numeric_fixeddecimal_cmp\"(numeric, fixeddecimal) " : - "OPERATOR 1 sys.< (numeric, fixeddecimal) ,\n " - "OPERATOR 2 sys.<= (numeric, fixeddecimal) ,\n " - "OPERATOR 3 sys.= (numeric, fixeddecimal) ,\n " - "OPERATOR 4 sys.>= (numeric, fixeddecimal) ,\n " - "OPERATOR 5 sys.> (numeric, fixeddecimal) ,\n " - "FUNCTION 1 sys.numeric_fixeddecimal_cmp(numeric, fixeddecimal) "; + "OPERATOR 1 \"sys\".< (numeric, \"sys\".\"fixeddecimal\") ,\n " + "OPERATOR 2 \"sys\".<= (numeric, \"sys\".\"fixeddecimal\") ,\n " + "OPERATOR 3 \"sys\".= (numeric, \"sys\".\"fixeddecimal\") ,\n " + "OPERATOR 4 \"sys\".>= (numeric, \"sys\".\"fixeddecimal\") ,\n " + "OPERATOR 5 \"sys\".> (numeric, \"sys\".\"fixeddecimal\") ,\n " + "FUNCTION 1 \"sys\".\"numeric_fixeddecimal_cmp\"(numeric, \"sys\".\"fixeddecimal\") " : + "OPERATOR 1 sys.< (numeric, sys.fixeddecimal) ,\n " + "OPERATOR 2 sys.<= (numeric, sys.fixeddecimal) ,\n " + "OPERATOR 3 sys.= (numeric, sys.fixeddecimal) ,\n " + "OPERATOR 4 sys.>= (numeric, sys.fixeddecimal) ,\n " + "OPERATOR 5 sys.> (numeric, sys.fixeddecimal) ,\n " + "FUNCTION 1 sys.numeric_fixeddecimal_cmp(numeric, sys.fixeddecimal) "; } if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"fixeddecimal_numeric_ops\"" : "sys.fixeddecimal_numeric_ops") == 0) { str = quote_all_identifiers ? - "OPERATOR 1 \"sys\".< (fixeddecimal, numeric) ,\n " - "OPERATOR 2 \"sys\".<= (fixeddecimal, numeric) ,\n " - "OPERATOR 3 \"sys\".= (fixeddecimal, numeric) ,\n " - "OPERATOR 4 \"sys\".>= (fixeddecimal, numeric) ,\n " - "OPERATOR 5 \"sys\".> (fixeddecimal, numeric) ,\n " - "FUNCTION 1 \"sys\".\"fixeddecimal_numeric_cmp\"(fixeddecimal, numeric) " : - "OPERATOR 1 sys.< (fixeddecimal, numeric) ,\n " - "OPERATOR 2 sys.<= (fixeddecimal, numeric) ,\n " - "OPERATOR 3 sys.= (fixeddecimal, numeric) ,\n " - "OPERATOR 4 sys.>= (fixeddecimal, numeric) ,\n " - "OPERATOR 5 sys.> (fixeddecimal, numeric) ,\n " - "FUNCTION 1 sys.fixeddecimal_numeric_cmp(fixeddecimal, numeric) "; + "OPERATOR 1 \"sys\".< (\"sys\".\"fixeddecimal\", numeric) ,\n " + "OPERATOR 2 \"sys\".<= (\"sys\".\"fixeddecimal\", numeric) ,\n " + "OPERATOR 3 \"sys\".= (\"sys\".\"fixeddecimal\", numeric) ,\n " + "OPERATOR 4 \"sys\".>= (\"sys\".\"fixeddecimal\", numeric) ,\n " + "OPERATOR 5 \"sys\".> (\"sys\".\"fixeddecimal\", numeric) ,\n " + "FUNCTION 1 \"sys\".\"fixeddecimal_numeric_cmp\"(\"sys\".\"fixeddecimal\", numeric) " : + "OPERATOR 1 sys.< (sys.fixeddecimal, numeric) ,\n " + "OPERATOR 2 sys.<= (sys.fixeddecimal, numeric) ,\n " + "OPERATOR 3 sys.= (sys.fixeddecimal, numeric) ,\n " + "OPERATOR 4 sys.>= (sys.fixeddecimal, numeric) ,\n " + "OPERATOR 5 sys.> (sys.fixeddecimal, numeric) ,\n " + "FUNCTION 1 sys.fixeddecimal_numeric_cmp(sys.fixeddecimal, numeric) "; } if(str != NULL) From d614620137fa060261aacf26dee67dcc5dcdb89b Mon Sep 17 00:00:00 2001 From: Tanya Gupta Date: Tue, 15 Jul 2025 09:35:44 +0000 Subject: [PATCH 3/3] renaming the operator class to avoid confusion with existing on fixeddecimal datatypes Signed-off-by: Tanya Gupta --- src/bin/pg_dump/dump_babel_utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bin/pg_dump/dump_babel_utils.c b/src/bin/pg_dump/dump_babel_utils.c index 992cde488c1..f2abdf2f937 100644 --- a/src/bin/pg_dump/dump_babel_utils.c +++ b/src/bin/pg_dump/dump_babel_utils.c @@ -1778,8 +1778,8 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int4_ops\"" : "sys.numeric_int4_ops") != 0 && pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int8_numeric_ops\"" : "sys.int8_numeric_ops") != 0 && pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int8_ops\"" : "sys.numeric_int8_ops") != 0 && - pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_fixeddecimal_ops\"" : "sys.numeric_fixeddecimal_ops") != 0 && - pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"fixeddecimal_numeric_ops\"" : "sys.fixeddecimal_numeric_ops") != 0) + pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_fixeddecimal_cmp_ops\"" : "sys.numeric_fixeddecimal_cmp_ops") != 0 && + pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"fixeddecimal_numeric_cmp_ops\"" : "sys.fixeddecimal_numeric_cmp_ops") != 0) return; query = createPQExpBuffer(); @@ -1924,7 +1924,7 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe "FUNCTION 1 sys.numeric_int8_cmp(numeric, int8) "; } - if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_fixeddecimal_ops\"" : "sys.numeric_fixeddecimal_ops") == 0) + if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_fixeddecimal_cmp_ops\"" : "sys.numeric_fixeddecimal_cmp_ops") == 0) { str = quote_all_identifiers ? "OPERATOR 1 \"sys\".< (numeric, \"sys\".\"fixeddecimal\") ,\n " @@ -1941,7 +1941,7 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe "FUNCTION 1 sys.numeric_fixeddecimal_cmp(numeric, sys.fixeddecimal) "; } - if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"fixeddecimal_numeric_ops\"" : "sys.fixeddecimal_numeric_ops") == 0) + if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"fixeddecimal_numeric_cmp_ops\"" : "sys.fixeddecimal_numeric_cmp_ops") == 0) { str = quote_all_identifiers ? "OPERATOR 1 \"sys\".< (\"sys\".\"fixeddecimal\", numeric) ,\n "