From 9a0b705a033ed970d26e51f88ab30ba66a03a337 Mon Sep 17 00:00:00 2001 From: gentle_hu Date: Mon, 7 Mar 2022 11:14:43 +0800 Subject: [PATCH] fix oid of _jsonb in upgrade --- src/common/backend/utils/init/globals.cpp | 2 +- .../upgrade-post_catalog_maindb_92_604.sql | 15 +++++++++++++++ .../upgrade-post_catalog_otherdb_92_604.sql | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_604.sql create mode 100644 src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_604.sql diff --git a/src/common/backend/utils/init/globals.cpp b/src/common/backend/utils/init/globals.cpp index 3ae475e13..558c4b4ca 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 = 92603; +const uint32 GRAND_VERSION_NUM = 92604; const uint32 PREDPUSH_SAME_LEVEL_VERSION_NUM = 92522; const uint32 UPSERT_WHERE_VERSION_NUM = 92514; diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_604.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_604.sql new file mode 100644 index 000000000..1de4e7ccf --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_604.sql @@ -0,0 +1,15 @@ +do $$ +DECLARE ans boolean; +BEGIN + select case when oid = 3807 then true else false end into ans from pg_type where typname = '_jsonb'; + if ans = false then + DROP TYPE IF EXISTS pg_catalog.jsonb; + DROP TYPE IF EXISTS pg_catalog._jsonb; + SET LOCAL inplace_upgrade_next_system_object_oids = IUO_TYPE, 3802, 3807, b; + CREATE TYPE pg_catalog.jsonb; + CREATE TYPE pg_catalog.jsonb (input=jsonb_in, output=jsonb_out, RECEIVE = jsonb_recv, SEND = jsonb_send, STORAGE=EXTENDED, category='C'); + COMMENT ON TYPE pg_catalog.jsonb IS 'json binary'; + COMMENT ON TYPE pg_catalog._jsonb IS 'json binary'; + end if; +END +$$; diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_604.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_604.sql new file mode 100644 index 000000000..1de4e7ccf --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_604.sql @@ -0,0 +1,15 @@ +do $$ +DECLARE ans boolean; +BEGIN + select case when oid = 3807 then true else false end into ans from pg_type where typname = '_jsonb'; + if ans = false then + DROP TYPE IF EXISTS pg_catalog.jsonb; + DROP TYPE IF EXISTS pg_catalog._jsonb; + SET LOCAL inplace_upgrade_next_system_object_oids = IUO_TYPE, 3802, 3807, b; + CREATE TYPE pg_catalog.jsonb; + CREATE TYPE pg_catalog.jsonb (input=jsonb_in, output=jsonb_out, RECEIVE = jsonb_recv, SEND = jsonb_send, STORAGE=EXTENDED, category='C'); + COMMENT ON TYPE pg_catalog.jsonb IS 'json binary'; + COMMENT ON TYPE pg_catalog._jsonb IS 'json binary'; + end if; +END +$$;