diff --git a/src/common/backend/catalog/builtin_funcs.ini b/src/common/backend/catalog/builtin_funcs.ini index 87af140c1..8e324e561 100755 --- a/src/common/backend/catalog/builtin_funcs.ini +++ b/src/common/backend/catalog/builtin_funcs.ini @@ -685,6 +685,10 @@ "boolsend", 1, AddBuiltinFunc(_0(2437), _1("boolsend"), _2(1), _3(true), _4(false), _5(boolsend), _6(17), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 16), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("boolsend"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("I/O"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) ), + AddFuncGroup( + "boolum", 1, + AddBuiltinFunc(_0(83), _1("boolum"), _2(1), _3(true), _4(false), _5(boolum), _6(16), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 16), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("boolum"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) + ), AddFuncGroup( "box", 3, AddBuiltinFunc(_0(1421), _1("box"), _2(2), _3(true), _4(false), _5(points_box), _6(603), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 600, 600), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("points_box"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("convert points to box"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)), @@ -9206,7 +9210,7 @@ "pg_ts_dict_is_visible", 1, AddBuiltinFunc(_0(3757), _1("pg_ts_dict_is_visible"), _2(1), _3(true), _4(false), _5(pg_ts_dict_is_visible), _6(16), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('s'), _19(0), _20(1, 26), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("pg_ts_dict_is_visible"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("is text search dictionary visible in search path?"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) ), - AddFuncGroup( +AddFuncGroup( "pg_ts_parser_is_visible", 1, AddBuiltinFunc(_0(3756), _1("pg_ts_parser_is_visible"), _2(1), _3(true), _4(false), _5(pg_ts_parser_is_visible), _6(16), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('s'), _19(0), _20(1, 26), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("pg_ts_parser_is_visible"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33("is text search parser visible in search path?"), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) ), diff --git a/src/common/backend/utils/adt/bool.cpp b/src/common/backend/utils/adt/bool.cpp index 9b9038b38..4e0034399 100644 --- a/src/common/backend/utils/adt/bool.cpp +++ b/src/common/backend/utils/adt/bool.cpp @@ -277,3 +277,8 @@ Datum boolor_statefunc(PG_FUNCTION_ARGS) { PG_RETURN_BOOL(PG_GETARG_BOOL(0) || PG_GETARG_BOOL(1)); } + +Datum boolum(PG_FUNCTION_ARGS) +{ + PG_RETURN_BOOL(PG_GETARG_BOOL(0)); +} diff --git a/src/common/backend/utils/init/globals.cpp b/src/common/backend/utils/init/globals.cpp index 47a2fc4b6..8d2baa9d2 100644 --- a/src/common/backend/utils/init/globals.cpp +++ b/src/common/backend/utils/init/globals.cpp @@ -59,7 +59,7 @@ bool open_join_children = true; bool will_shutdown = false; /* hard-wired binary version number */ -const uint32 GRAND_VERSION_NUM = 92834; +const uint32 GRAND_VERSION_NUM = 92835; const uint32 SELECT_INTO_VAR_VERSION_NUM = 92834; const uint32 DOLPHIN_ENABLE_DROP_NUM = 92830; @@ -162,6 +162,8 @@ const uint32 ON_UPDATE_TIMESTAMP_VERSION_NUM = 92664; const uint32 STANDBY_STMTHIST_VERSION_NUM = 92827; const uint32 MAT_VIEW_RECURSIVE_VERSION_NUM = 92833; +const uint32 NEGETIVE_BOOL_VERSION_NUM = 92835; + #ifdef PGXC bool useLocalXid = false; #endif diff --git a/src/include/catalog/pg_operator.data b/src/include/catalog/pg_operator.data index d9df4f699..ce5638f1c 100644 --- a/src/include/catalog/pg_operator.data +++ b/src/include/catalog/pg_operator.data @@ -1909,6 +1909,8 @@ DATA(insert OID = 6563 ("<=" PGNSP PGUID b f f 25 3272 16 6558 6562 textset DESCR("less than or equal"); DATA(insert OID = 6564 (">=" PGNSP PGUID b f f 25 3272 16 6557 6561 textsetge scalargtsel scalargtjoinsel)); DESCR("greater than or equal"); +DATA(insert OID = 6565 ("-" PGNSP PGUID l f f 0 16 16 0 0 boolum - -)); +DESCR("negate"); /* * function prototypes diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_92_835.sql b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_92_835.sql new file mode 100644 index 000000000..91f2d2f31 --- /dev/null +++ b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_92_835.sql @@ -0,0 +1,2 @@ +DROP FUNCTION IF EXISTS pg_catalog.boolum(bool) CASCADE; +DROP OPERATOR IF EXISTS pg_catalog.-(none, bool) CASCADE; \ No newline at end of file diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_92_835.sql b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_92_835.sql new file mode 100644 index 000000000..91f2d2f31 --- /dev/null +++ b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_92_835.sql @@ -0,0 +1,2 @@ +DROP FUNCTION IF EXISTS pg_catalog.boolum(bool) CASCADE; +DROP OPERATOR IF EXISTS pg_catalog.-(none, bool) CASCADE; \ No newline at end of file diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_835.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_835.sql new file mode 100644 index 000000000..15fcaee2e --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_835.sql @@ -0,0 +1,10 @@ +DROP FUNCTION IF EXISTS pg_catalog.boolum(bool) CASCADE; +set LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 83; +CREATE FUNCTION pg_catalog.boolum(bool) RETURNS bool LANGUAGE INTERNAL IMMUTABLE STRICT as 'boolum'; + +DROP OPERATOR IF EXISTS pg_catalog.-(none, bool) CASCADE; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_GENERAL, 6565; +CREATE OPERATOR pg_catalog.-( + RIGHTARG = bool, + PROCEDURE = boolum +); diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_835.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_835.sql new file mode 100644 index 000000000..15fcaee2e --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_835.sql @@ -0,0 +1,10 @@ +DROP FUNCTION IF EXISTS pg_catalog.boolum(bool) CASCADE; +set LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 83; +CREATE FUNCTION pg_catalog.boolum(bool) RETURNS bool LANGUAGE INTERNAL IMMUTABLE STRICT as 'boolum'; + +DROP OPERATOR IF EXISTS pg_catalog.-(none, bool) CASCADE; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_GENERAL, 6565; +CREATE OPERATOR pg_catalog.-( + RIGHTARG = bool, + PROCEDURE = boolum +); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index add1a6f3e..abed78d50 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -408,6 +408,7 @@ extern Datum i1tof8(PG_FUNCTION_ARGS); extern Datum f8toi1(PG_FUNCTION_ARGS); extern Datum int1_bool(PG_FUNCTION_ARGS); extern Datum bool_int1(PG_FUNCTION_ARGS); +extern Datum boolum(PG_FUNCTION_ARGS); extern Datum int4_bpchar(PG_FUNCTION_ARGS); extern Datum int1_bpchar(PG_FUNCTION_ARGS); extern Datum int2_bpchar(PG_FUNCTION_ARGS); diff --git a/src/test/regress/expected/boolean.out b/src/test/regress/expected/boolean.out index 23490fe69..da7bc2f33 100644 --- a/src/test/regress/expected/boolean.out +++ b/src/test/regress/expected/boolean.out @@ -458,6 +458,18 @@ SELECT '' AS "Not True", f1 | f (4 rows) +SELECT -2::bool; + ?column? +---------- + t +(1 row) + +SELECT 1-2::bool; + ?column? +---------- + 0 +(1 row) + -- -- Clean up -- Many tables are retained by the regression test, but these do not seem diff --git a/src/test/regress/sql/boolean.sql b/src/test/regress/sql/boolean.sql index 35cfac6d3..4be3f3f24 100644 --- a/src/test/regress/sql/boolean.sql +++ b/src/test/regress/sql/boolean.sql @@ -202,6 +202,10 @@ SELECT '' AS "Not True", f1 FROM BOOLTBL2 WHERE f1 IS NOT TRUE; +SELECT -2::bool; + +SELECT 1-2::bool; + -- -- Clean up -- Many tables are retained by the regression test, but these do not seem