Skip to content

Commit 8d39b96

Browse files
author
Sumit Jaiswal
committed
Dump Babelfish operator classes for numeric-int comparisons to support index scan
Signed-off-by: Sumit Jaiswal <[email protected]>
1 parent 7199fa7 commit 8d39b96

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/bin/pg_dump/dump_babel_utils.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,13 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe
16111611
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int2_numeric\"" : "sys.int2_numeric") != 0 &&
16121612
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int2\"" : "sys.numeric_int2") != 0 &&
16131613
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int8_numeric\"" : "sys.int8_numeric") != 0 &&
1614-
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int8\"" : "sys.numeric_int8") != 0)
1614+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int8\"" : "sys.numeric_int8") != 0 &&
1615+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int2_numeric_ops\"" : "sys.int2_numeric_ops") != 0 &&
1616+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int2_ops\"" : "sys.numeric_int2_ops") != 0 &&
1617+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int4_numeric_ops\"" : "sys.int4_numeric_ops") != 0 &&
1618+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int4_ops\"" : "sys.numeric_int4_ops") != 0 &&
1619+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int8_numeric_ops\"" : "sys.int8_numeric_ops") != 0 &&
1620+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int8_ops\"" : "sys.numeric_int8_ops") != 0)
16151621
return;
16161622

16171623
query = createPQExpBuffer();
@@ -1640,15 +1646,16 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe
16401646
}
16411647

16421648
if (strcasecmp(opfnamespace, "\"pg_catalog\"") != 0 ||
1643-
strcasecmp(opfname, "integer_ops") != 0)
1649+
(strcasecmp(opfname, "integer_ops") != 0 && strcasecmp(opfname, "numeric_ops") != 0))
16441650
{
16451651
PQclear(res);
16461652
return;
16471653
}
16481654

16491655
PQclear(res);
16501656

1651-
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int_numeric\"" : "sys.int_numeric") == 0)
1657+
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int_numeric\"" : "sys.int_numeric") == 0 ||
1658+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int4_numeric_ops\"" : "sys.int4_numeric_ops") == 0)
16521659
{
16531660
str = quote_all_identifiers ?
16541661
"OPERATOR 1 \"sys\".< (int4, numeric) ,\n "
@@ -1665,7 +1672,8 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe
16651672
"FUNCTION 1 sys.int4_numeric_cmp(int4, numeric) ";
16661673
}
16671674

1668-
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int\"" : "sys.numeric_int") == 0)
1675+
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int\"" : "sys.numeric_int") == 0 ||
1676+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int4_ops\"" : "sys.numeric_int4_ops") == 0)
16691677
{
16701678
str = quote_all_identifiers ?
16711679
"OPERATOR 1 \"sys\".< (numeric, int4) ,\n "
@@ -1682,7 +1690,8 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe
16821690
"FUNCTION 1 sys.numeric_int4_cmp(numeric, int4) ";
16831691
}
16841692

1685-
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int2_numeric\"" : "sys.int2_numeric") == 0)
1693+
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int2_numeric\"" : "sys.int2_numeric") == 0 ||
1694+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int2_numeric_ops\"" : "sys.int2_numeric_ops") == 0)
16861695
{
16871696
str = quote_all_identifiers ?
16881697
"OPERATOR 1 \"sys\".< (int2, numeric) ,\n "
@@ -1699,7 +1708,8 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe
16991708
"FUNCTION 1 sys.int2_numeric_cmp(int2, numeric) ";
17001709
}
17011710

1702-
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int2\"" : "sys.numeric_int2") == 0)
1711+
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int2\"" : "sys.numeric_int2") == 0 ||
1712+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int2_ops\"" : "sys.numeric_int2_ops") == 0)
17031713
{
17041714
str = quote_all_identifiers ?
17051715
"OPERATOR 1 \"sys\".< (numeric, int2) ,\n "
@@ -1716,7 +1726,8 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe
17161726
"FUNCTION 1 sys.numeric_int2_cmp(numeric, int2) ";
17171727
}
17181728

1719-
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int8_numeric\"" : "sys.int8_numeric") == 0)
1729+
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int8_numeric\"" : "sys.int8_numeric") == 0 ||
1730+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"int8_numeric_ops\"" : "sys.int8_numeric_ops") == 0)
17201731
{
17211732
str = quote_all_identifiers ?
17221733
"OPERATOR 1 \"sys\".< (int8, numeric) ,\n "
@@ -1733,7 +1744,8 @@ babelfishDumpOpclassHelper(Archive *fout, const OpclassInfo *opcinfo, PQExpBuffe
17331744
"FUNCTION 1 sys.int8_numeric_cmp(int8, numeric) ";
17341745
}
17351746

1736-
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int8\"" : "sys.numeric_int8") == 0)
1747+
if (pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int8\"" : "sys.numeric_int8") == 0 ||
1748+
pg_strcasecmp(opclass, quote_all_identifiers ? "\"sys\".\"numeric_int8_ops\"" : "sys.numeric_int8_ops") == 0)
17371749
{
17381750
str = quote_all_identifiers ?
17391751
"OPERATOR 1 \"sys\".< (numeric, int8) ,\n "

0 commit comments

Comments
 (0)