From 7b7fc4ecf0f3ecac6b8aba5f1da63864e442341e Mon Sep 17 00:00:00 2001 From: ashnah Date: Thu, 21 Apr 2022 15:46:16 +0800 Subject: [PATCH] fix problem: pg_proc.provariadic is invalid after initdb --- src/common/backend/utils/cache/catcache.cpp | 4 ++- src/common/backend/utils/init/globals.cpp | 2 +- .../rollback_catalog_maindb_92_607.sql | 2 +- .../rollback_catalog_maindb_92_612.sql | 22 +++++++++++++++ .../rollback_catalog_otherdb_92_607.sql | 2 +- .../rollback_catalog_otherdb_92_612.sql | 22 +++++++++++++++ .../upgrade_catalog_maindb_92_607.sql | 2 +- .../upgrade_catalog_maindb_92_612.sql | 22 +++++++++++++++ .../upgrade_catalog_otherdb_92_607.sql | 2 +- .../upgrade_catalog_otherdb_92_612.sql | 22 +++++++++++++++ src/test/regress/expected/json_and_jsonb.out | 12 ++++----- src/test/regress/input/pg_proc_test.source | 1 + src/test/regress/output/pg_proc_test.source | 27 +++++++++++++++++++ src/test/regress/parallel_schedule0 | 2 ++ 14 files changed, 132 insertions(+), 12 deletions(-) create mode 100644 src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_612.sql create mode 100644 src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_612.sql create mode 100644 src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_612.sql create mode 100644 src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_612.sql create mode 100644 src/test/regress/input/pg_proc_test.source create mode 100644 src/test/regress/output/pg_proc_test.source diff --git a/src/common/backend/utils/cache/catcache.cpp b/src/common/backend/utils/cache/catcache.cpp index 815bfdb41..0bdc6b678 100644 --- a/src/common/backend/utils/cache/catcache.cpp +++ b/src/common/backend/utils/cache/catcache.cpp @@ -1992,7 +1992,9 @@ HeapTuple CreateHeapTuple4BuiltinFunc(const Builtin_func* func, TupleDesc desc) } } } - + if (IsBootstrapProcessingMode()) { + variadicType = func->provariadic; + } /* construct the spcified struct */ parameterTypes = buildoidvector(func->proargtypes.values, func->proargtypes.count); defargpos = buildint2vector(func->prodefaultargpos->values, func->prodefaultargpos->count); diff --git a/src/common/backend/utils/init/globals.cpp b/src/common/backend/utils/init/globals.cpp index ffa9499bb..c9442bfd0 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 = 92611; +const uint32 GRAND_VERSION_NUM = 92612; const uint32 PREDPUSH_SAME_LEVEL_VERSION_NUM = 92522; const uint32 UPSERT_WHERE_VERSION_NUM = 92514; diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_607.sql b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_607.sql index d6fd0ae9c..4f713e190 100644 --- a/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_607.sql +++ b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_607.sql @@ -34,4 +34,4 @@ BEGIN end if; exit; END LOOP; -END$$; \ No newline at end of file +END$$; diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_612.sql b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_612.sql new file mode 100644 index 000000000..fe2339e57 --- /dev/null +++ b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_612.sql @@ -0,0 +1,22 @@ +update pg_proc set provariadic = 0 where oid = 3058; +update pg_proc set provariadic = 0 where oid = 3059; +update pg_proc set provariadic = 0 where oid = 3239; +update pg_proc set provariadic = 0 where oid = 3261; +update pg_proc set provariadic = 0 where oid = 3262; +update pg_proc set provariadic = 0 where oid = 3264; +update pg_proc set provariadic = 0 where oid = 3425; +update pg_proc set provariadic = 0 where oid = 3426; +update pg_proc set provariadic = 0 where oid = 3539; +update pg_proc set provariadic = 0 where oid = 4216; +update pg_proc set provariadic = 0 where oid = 4217; +update pg_proc set provariadic = 0 where oid = 4218; +update pg_proc set provariadic = 0 where oid = 4219; +update pg_proc set provariadic = 0 where oid = 4978; +update pg_proc set provariadic = 0 where oid = 7101; +update pg_proc set provariadic = 0 where oid = 7102; +update pg_proc set provariadic = 0 where oid = 7103; +update pg_proc set provariadic = 0 where oid = 7105; +update pg_proc set provariadic = 0 where oid = 7106; +update pg_proc set provariadic = 0 where oid = 7107; +update pg_proc set provariadic = 0 where oid = 7108; +update pg_proc set provariadic = 0 where oid = 7109; diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_607.sql b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_607.sql index d6fd0ae9c..4f713e190 100644 --- a/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_607.sql +++ b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_607.sql @@ -34,4 +34,4 @@ BEGIN end if; exit; END LOOP; -END$$; \ No newline at end of file +END$$; diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_612.sql b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_612.sql new file mode 100644 index 000000000..fe2339e57 --- /dev/null +++ b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_612.sql @@ -0,0 +1,22 @@ +update pg_proc set provariadic = 0 where oid = 3058; +update pg_proc set provariadic = 0 where oid = 3059; +update pg_proc set provariadic = 0 where oid = 3239; +update pg_proc set provariadic = 0 where oid = 3261; +update pg_proc set provariadic = 0 where oid = 3262; +update pg_proc set provariadic = 0 where oid = 3264; +update pg_proc set provariadic = 0 where oid = 3425; +update pg_proc set provariadic = 0 where oid = 3426; +update pg_proc set provariadic = 0 where oid = 3539; +update pg_proc set provariadic = 0 where oid = 4216; +update pg_proc set provariadic = 0 where oid = 4217; +update pg_proc set provariadic = 0 where oid = 4218; +update pg_proc set provariadic = 0 where oid = 4219; +update pg_proc set provariadic = 0 where oid = 4978; +update pg_proc set provariadic = 0 where oid = 7101; +update pg_proc set provariadic = 0 where oid = 7102; +update pg_proc set provariadic = 0 where oid = 7103; +update pg_proc set provariadic = 0 where oid = 7105; +update pg_proc set provariadic = 0 where oid = 7106; +update pg_proc set provariadic = 0 where oid = 7107; +update pg_proc set provariadic = 0 where oid = 7108; +update pg_proc set provariadic = 0 where oid = 7109; diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_607.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_607.sql index cdf4edd53..aac48a5b2 100644 --- a/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_607.sql +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_607.sql @@ -28,4 +28,4 @@ CREATE OR REPLACE FUNCTION pg_catalog.pg_get_replica_identity_index(regclass) returns oid LANGUAGE internal STABLE STRICT NOT FENCED -AS $function$pg_get_replica_identity_index$function$; \ No newline at end of file +AS $function$pg_get_replica_identity_index$function$; diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_612.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_612.sql new file mode 100644 index 000000000..f42f9fa2d --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_612.sql @@ -0,0 +1,22 @@ +update pg_proc set provariadic = 2276 where oid = 3058; +update pg_proc set provariadic = 2276 where oid = 3059; +update pg_proc set provariadic = 2276 where oid = 3239; +update pg_proc set provariadic = 2276 where oid = 3261; +update pg_proc set provariadic = 25 where oid = 3262; +update pg_proc set provariadic = 25 where oid = 3264; +update pg_proc set provariadic = 25 where oid = 3425; +update pg_proc set provariadic = 25 where oid = 3426; +update pg_proc set provariadic = 2276 where oid = 3539; +update pg_proc set provariadic = 25 where oid = 4216; +update pg_proc set provariadic = 25 where oid = 4217; +update pg_proc set provariadic = 25 where oid = 4218; +update pg_proc set provariadic = 25 where oid = 4219; +update pg_proc set provariadic = 25 where oid = 4978; +update pg_proc set provariadic = 2276 where oid = 7101; +update pg_proc set provariadic = 2276 where oid = 7102; +update pg_proc set provariadic = 2276 where oid = 7103; +update pg_proc set provariadic = 2276 where oid = 7105; +update pg_proc set provariadic = 2276 where oid = 7106; +update pg_proc set provariadic = 2276 where oid = 7107; +update pg_proc set provariadic = 2276 where oid = 7108; +update pg_proc set provariadic = 2276 where oid = 7109; diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_607.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_607.sql index cdf4edd53..aac48a5b2 100644 --- a/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_607.sql +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_607.sql @@ -28,4 +28,4 @@ CREATE OR REPLACE FUNCTION pg_catalog.pg_get_replica_identity_index(regclass) returns oid LANGUAGE internal STABLE STRICT NOT FENCED -AS $function$pg_get_replica_identity_index$function$; \ No newline at end of file +AS $function$pg_get_replica_identity_index$function$; diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_612.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_612.sql new file mode 100644 index 000000000..f42f9fa2d --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_612.sql @@ -0,0 +1,22 @@ +update pg_proc set provariadic = 2276 where oid = 3058; +update pg_proc set provariadic = 2276 where oid = 3059; +update pg_proc set provariadic = 2276 where oid = 3239; +update pg_proc set provariadic = 2276 where oid = 3261; +update pg_proc set provariadic = 25 where oid = 3262; +update pg_proc set provariadic = 25 where oid = 3264; +update pg_proc set provariadic = 25 where oid = 3425; +update pg_proc set provariadic = 25 where oid = 3426; +update pg_proc set provariadic = 2276 where oid = 3539; +update pg_proc set provariadic = 25 where oid = 4216; +update pg_proc set provariadic = 25 where oid = 4217; +update pg_proc set provariadic = 25 where oid = 4218; +update pg_proc set provariadic = 25 where oid = 4219; +update pg_proc set provariadic = 25 where oid = 4978; +update pg_proc set provariadic = 2276 where oid = 7101; +update pg_proc set provariadic = 2276 where oid = 7102; +update pg_proc set provariadic = 2276 where oid = 7103; +update pg_proc set provariadic = 2276 where oid = 7105; +update pg_proc set provariadic = 2276 where oid = 7106; +update pg_proc set provariadic = 2276 where oid = 7107; +update pg_proc set provariadic = 2276 where oid = 7108; +update pg_proc set provariadic = 2276 where oid = 7109; diff --git a/src/test/regress/expected/json_and_jsonb.out b/src/test/regress/expected/json_and_jsonb.out index c378637bf..d5ebea1ac 100644 --- a/src/test/regress/expected/json_and_jsonb.out +++ b/src/test/regress/expected/json_and_jsonb.out @@ -24,14 +24,14 @@ select oid,* from pg_proc where proname like '%json%' order by oid; 3155 | row_to_json | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | s | 1 | 0 | 114 | 2249 | | | | | row_to_json | | | | | f | | f | f | | 0 | f | | | 2249 | 3156 | row_to_json | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | s | 2 | 0 | 114 | 2249 16 | | | | | row_to_json_pretty | | | | | f | | f | f | | 0 | f | | | 2249 16 | 3238 | json_build_array | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | f | f | i | 0 | 0 | 114 | | | | | | json_build_array_noargs | | | | | f | f | f | f | | 0 | f | | | | - 3239 | json_build_array | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | f | f | i | 1 | 0 | 114 | 2276 | {2276} | {v} | | | json_build_array | | | | | f | f | f | f | | 0 | f | | | 2276 | + 3239 | json_build_array | 11 | 10 | 12 | 1 | 0 | 2276 | - | f | f | f | f | f | f | i | 1 | 0 | 114 | 2276 | {2276} | {v} | | | json_build_array | | | | | f | f | f | f | | 0 | f | | | 2276 | 3258 | json_each | 11 | 10 | 12 | 1 | 100 | 0 | - | f | f | f | f | t | t | i | 1 | 0 | 2249 | 114 | {114,25,114} | {i,o,o} | {from_json,key,value} | | json_each | | | | | f | f | f | f | | 0 | f | | | 114 25 114 | 3259 | json_each_text | 11 | 10 | 12 | 1 | 100 | 0 | - | f | f | f | f | t | t | i | 1 | 0 | 2249 | 114 | {114,25,25} | {i,o,o} | {from_json,key,value} | | json_each_text | | | | | f | f | f | f | | 0 | f | | | 114 25 25 | 3260 | json_build_object | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | f | f | i | 0 | 0 | 114 | | | | | | json_build_object_noargs | | | | | f | f | f | f | | 0 | f | | | | - 3261 | json_build_object | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | f | f | i | 1 | 0 | 114 | 2276 | {2276} | {v} | | | json_build_object | | | | | f | f | f | f | | 0 | f | | | 2276 | - 3262 | json_extract_path | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 114 | 114 1009 | {114,1009} | {i,v} | | | json_extract_path | | | | | f | f | f | f | | 0 | f | | | 114 1009 | + 3261 | json_build_object | 11 | 10 | 12 | 1 | 0 | 2276 | - | f | f | f | f | f | f | i | 1 | 0 | 114 | 2276 | {2276} | {v} | | | json_build_object | | | | | f | f | f | f | | 0 | f | | | 2276 | + 3262 | json_extract_path | 11 | 10 | 12 | 1 | 0 | 25 | - | f | f | f | f | t | f | i | 2 | 0 | 114 | 114 1009 | {114,1009} | {i,v} | | | json_extract_path | | | | | f | f | f | f | | 0 | f | | | 114 1009 | 3263 | json_extract_path_op | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 114 | 114 1009 | | | | | json_extract_path | | | | | f | f | f | f | | 0 | f | | | 114 1009 | - 3264 | json_extract_path_text | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 25 | 114 1009 | {114,1009} | {i,v} | | | json_extract_path_text | | | | | f | f | f | f | | 0 | f | | | 114 1009 | + 3264 | json_extract_path_text | 11 | 10 | 12 | 1 | 0 | 25 | - | f | f | f | f | t | f | i | 2 | 0 | 25 | 114 1009 | {114,1009} | {i,v} | | | json_extract_path_text | | | | | f | f | f | f | | 0 | f | | | 114 1009 | 3270 | json_typeof | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 1 | 0 | 25 | 114 | | | | | json_typeof | | | | | f | f | f | f | | 0 | f | | | 114 | 3318 | json_extract_path_text_op | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 25 | 114 1009 | | | | | json_extract_path_text | | | | | f | f | f | f | | 0 | f | | | 114 1009 | 3319 | jsonb_extract_path_op | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 3802 | 3802 1009 | | | | | jsonb_extract_path | | | | | f | f | f | f | | 0 | f | | | 3802 1009 | @@ -59,8 +59,8 @@ select oid,* from pg_proc where proname like '%json%' order by oid; 3422 | jsonb_exists | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 16 | 3802 25 | | | | | jsonb_exists | | | | | f | f | f | f | | 0 | f | | | 3802 25 | 3423 | jsonb_exists_all | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 16 | 3802 1009 | | | | | jsonb_exists_all | | | | | f | f | f | f | | 0 | f | | | 3802 1009 | 3424 | jsonb_exists_any | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 16 | 3802 1009 | | | | | jsonb_exists_any | | | | | f | f | f | f | | 0 | f | | | 3802 1009 | - 3425 | jsonb_extract_path | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 3802 | 3802 1009 | {3802,1009} | {i,v} | | | jsonb_extract_path | | | | | f | f | f | f | | 0 | f | | | 3802 1009 | - 3426 | jsonb_extract_path_text | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 25 | 3802 1009 | {3802,1009} | {i,v} | | | jsonb_extract_path_text | | | | | f | f | f | f | | 0 | f | | | 3802 1009 | + 3425 | jsonb_extract_path | 11 | 10 | 12 | 1 | 0 | 25 | - | f | f | f | f | t | f | i | 2 | 0 | 3802 | 3802 1009 | {3802,1009} | {i,v} | | | jsonb_extract_path | | | | | f | f | f | f | | 0 | f | | | 3802 1009 | + 3426 | jsonb_extract_path_text | 11 | 10 | 12 | 1 | 0 | 25 | - | f | f | f | f | t | f | i | 2 | 0 | 25 | 3802 1009 | {3802,1009} | {i,v} | | | jsonb_extract_path_text | | | | | f | f | f | f | | 0 | f | | | 3802 1009 | 3427 | jsonb_extract_path_text_op | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 25 | 3802 1009 | | | | | jsonb_extract_path_text | | | | | f | f | f | f | | 0 | f | | | 3802 1009 | 3428 | jsonb_ge | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 16 | 3802 3802 | | | | | jsonb_ge | | | | | f | f | f | f | | 0 | f | | | 3802 3802 | 3429 | jsonb_gt | 11 | 10 | 12 | 1 | 0 | 0 | - | f | f | f | f | t | f | i | 2 | 0 | 16 | 3802 3802 | | | | | jsonb_gt | | | | | f | f | f | f | | 0 | f | | | 3802 3802 | diff --git a/src/test/regress/input/pg_proc_test.source b/src/test/regress/input/pg_proc_test.source new file mode 100644 index 000000000..bba1d7968 --- /dev/null +++ b/src/test/regress/input/pg_proc_test.source @@ -0,0 +1 @@ +select provariadic,oid, proname from pg_proc where arraycontains(proargmodes::char[],ARRAY['v'::char]) order by oid; \ No newline at end of file diff --git a/src/test/regress/output/pg_proc_test.source b/src/test/regress/output/pg_proc_test.source new file mode 100644 index 000000000..4e67a589a --- /dev/null +++ b/src/test/regress/output/pg_proc_test.source @@ -0,0 +1,27 @@ +select provariadic,oid, proname from pg_proc where arraycontains(proargmodes::char[],ARRAY['v'::char]) order by oid; + provariadic | oid | proname +-------------+------+------------------------------------- + 2276 | 3058 | concat + 2276 | 3059 | concat_ws + 2276 | 3239 | json_build_array + 2276 | 3261 | json_build_object + 25 | 3262 | json_extract_path + 25 | 3264 | json_extract_path_text + 25 | 3425 | jsonb_extract_path + 25 | 3426 | jsonb_extract_path_text + 2276 | 3539 | format + 25 | 4216 | pg_logical_slot_get_changes + 25 | 4217 | pg_logical_slot_get_binary_changes + 25 | 4218 | pg_logical_slot_peek_changes + 25 | 4219 | pg_logical_slot_peek_binary_changes + 25 | 4978 | pg_logical_get_area_changes + 2276 | 7101 | db4ai_predict_by_bool + 2276 | 7102 | db4ai_predict_by_int32 + 2276 | 7103 | db4ai_predict_by_int64 + 2276 | 7105 | db4ai_predict_by_float4 + 2276 | 7106 | db4ai_predict_by_float8 + 2276 | 7107 | db4ai_predict_by_numeric + 2276 | 7108 | db4ai_predict_by_text + 2276 | 7109 | db4ai_predict_by_float8_array +(22 rows) + diff --git a/src/test/regress/parallel_schedule0 b/src/test/regress/parallel_schedule0 index 854f32bc2..8f598cdb0 100644 --- a/src/test/regress/parallel_schedule0 +++ b/src/test/regress/parallel_schedule0 @@ -10,6 +10,8 @@ test: hw_grant_package gsc_func gsc_db test: uppercase_attribute_name decode_compatible_with_o test: replace_func_with_two_args trunc_func_for_date nlssort_pinyin updatable_views +test: pg_proc_test + # parse xlog and page test: parse_page test: parse_xlog