diff --git a/src/common/backend/catalog/builtin_funcs.ini b/src/common/backend/catalog/builtin_funcs.ini index 85013c99f852cf98224564e3f1cd4a7079f3dd1c..82405ce1a07c21315f112876aa93901a2336bb9b 100644 --- a/src/common/backend/catalog/builtin_funcs.ini +++ b/src/common/backend/catalog/builtin_funcs.ini @@ -3665,11 +3665,11 @@ ), AddFuncGroup( "btvarstrequalimage", 1, - AddBuiltinFunc(_0(4608), _1("btvarstrequalimage"), _2(1), _3(true), _4(false), _5(btvarstrequalimage), _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, 2276), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("btvarstrequalimage"), _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)) + AddBuiltinFunc(_0(4608), _1("btvarstrequalimage"), _2(1), _3(true), _4(false), _5(btvarstrequalimage), _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, 2276), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("btvarstrequalimage"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(false), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) ), AddFuncGroup( "btequalimage", 1, - AddBuiltinFunc(_0(4609), _1("btequalimage"), _2(1), _3(true), _4(false), _5(btequalimage), _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, 2276), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("btequalimage"), _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)) + AddBuiltinFunc(_0(4609), _1("btequalimage"), _2(1), _3(true), _4(false), _5(btequalimage), _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, 2276), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("btequalimage"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(false), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) ), AddFuncGroup( "gs_get_active_archiving_standby", 1, @@ -13028,7 +13028,7 @@ AddFuncGroup( ), AddFuncGroup( "gs_hot_standby_space_info", 1, - AddBuiltinFunc(_0(6218), _1("gs_hot_standby_space_info"), _2(0), _3(false), _4(true), _5(gs_hot_standby_space_info), _6(2249), _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(0), _21(6, 28, 28, 28, 28, 28, 28), _22(6, 'o', 'o', 'o', 'o', 'o', 'o'), _23(6, "base_page_file_num", "base_page_total_size", "lsn_info_meta_file_num", "lsn_info_meta_total_size", "block_info_meta_file_num", "block_info_meta_total_size"), _24(NULL), _25("gs_hot_standby_space_info"), _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)) + AddBuiltinFunc(_0(6218), _1("gs_hot_standby_space_info"), _2(0), _3(false), _4(true), _5(gs_hot_standby_space_info), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(1), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('s'), _19(0), _20(0), _21(6, 28, 28, 28, 28, 28, 28), _22(6, 'o', 'o', 'o', 'o', 'o', 'o'), _23(6, "base_page_file_num", "base_page_total_size", "lsn_info_meta_file_num", "lsn_info_meta_total_size", "block_info_meta_file_num", "block_info_meta_total_size"), _24(NULL), _25("gs_hot_standby_space_info"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(false), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) ), AddFuncGroup( "query_node_reform_info", 1, diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_92_957.sql b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_92_957.sql index cca5c92e9a55b9acfa87bfdb3af1e0da95bc5659..ba13972c9a718466199edae61e263051767b2940 100644 --- a/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_92_957.sql +++ b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_92_957.sql @@ -13,7 +13,7 @@ CREATE FUNCTION pg_catalog.gs_stat_walsender( out avg_send_interval xid, out since_last_send_interval xid ) -RETURNS SETOF record LANGUAGE INTERNAL as 'gs_stat_walsender' stable; +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 as 'gs_stat_walsender' stable; -- create gs_stat_walreceiver DROP FUNCTION IF EXISTS pg_catalog.gs_stat_walreceiver(int4) CASCADE; @@ -31,7 +31,7 @@ CREATE FUNCTION pg_catalog.gs_stat_walreceiver( out last_reset_time timestamptz, out cur_time timestamptz ) -RETURNS SETOF record LANGUAGE INTERNAL as 'gs_stat_walreceiver' stable; +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 as 'gs_stat_walreceiver' stable; -- create gs_stat_walrecvwriter DROP FUNCTION IF EXISTS pg_catalog.gs_stat_walrecvwriter(int4) CASCADE; @@ -54,4 +54,115 @@ CREATE FUNCTION pg_catalog.gs_stat_walrecvwriter( out last_reset_time timestamptz, out cur_time timestamptz ) -RETURNS SETOF record LANGUAGE INTERNAL as 'gs_stat_walrecvwriter' stable; \ No newline at end of file +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 as 'gs_stat_walrecvwriter' stable; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select * from pg_conversion where conname = 'gb18030_2022_to_utf8' limit 1) into ans; + if ans = true THEN + comment on conversion gb18030_2022_to_utf8 is 'conversion for GB18030_2022 to UTF8'; + end if; +END$$; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select * from pg_conversion where conname = 'utf8_to_gb18030_2022' limit 1) into ans; + if ans = true THEN + comment on conversion utf8_to_gb18030_2022 is 'conversion for UTF8 to GB18030_2022'; + end if; +END$$; + + +DROP FUNCTION IF EXISTS pg_catalog.gs_hot_standby_space_info() cascade; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6218; +CREATE OR REPLACE FUNCTION pg_catalog.gs_hot_standby_space_info +( OUT base_page_file_num xid, + OUT base_page_total_size xid, + OUT lsn_info_meta_file_num xid, + OUT lsn_info_meta_total_size xid, + OUT block_info_meta_file_num xid, + OUT block_info_meta_total_size xid + ) +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 STABLE as 'gs_hot_standby_space_info'; + +DROP FUNCTION IF EXISTS pg_catalog.btvarstrequalimage(oid) cascade; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4608; +CREATE OR REPLACE FUNCTION pg_catalog.btvarstrequalimage("any") RETURNS boolean LANGUAGE INTERNAL IMMUTABLE STRICT AS 'btvarstrequalimage'; + +DROP FUNCTION IF EXISTS pg_catalog.btequalimage(oid) CASCADE; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4609; +CREATE OR REPLACE FUNCTION pg_catalog.btequalimage("any") RETURNS boolean LANGUAGE INTERNAL IMMUTABLE STRICT AS 'btequalimage'; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select nspname from pg_namespace where nspname='coverage' limit 1) into ans; + if ans = true THEN + DROP table IF EXISTS coverage.proc_coverage; + DROP SEQUENCE IF EXISTS coverage.proc_coverage_coverage_id_seq; + DROP SCHEMA IF EXISTS coverage cascade; + end if; +END$$; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_NAMESPACE, 4994; +CREATE SCHEMA coverage; +COMMENT ON schema coverage IS 'coverage schema'; + +CREATE SEQUENCE coverage.proc_coverage_coverage_id_seq START 1; +CREATE unlogged table coverage.proc_coverage( + coverage_id bigint NOT NULL DEFAULT nextval('coverage.proc_coverage_coverage_id_seq'::regclass), + pro_oid oid NOT NULL, + pro_name text NOT NULL, + db_name text NOT NULL, + pro_querys text NOT NULL, + pro_canbreak bool[] NOT NULL, + coverage int[] NOT NULL +) WITH (orientation=row, compression=no); +REVOKE ALL on table coverage.proc_coverage FROM public; + +DROP FUNCTION IF EXISTS pg_catalog.generate_procoverage_report(int8, int8) CASCADE; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 5734; +CREATE OR REPLACE FUNCTION pg_catalog.generate_procoverage_report(int8, int8) RETURNS text +LANGUAGE INTERNAL STRICT as 'generate_procoverage_report'; + +-- add this. dropped by 92_906 +DO $gs_slow_query_info$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select relname from pg_class where relname='gs_slow_query_info' and relnamespace=4988 limit 1) into ans; + if ans = true THEN + CREATE OR REPLACE FUNCTION dbe_perf.global_slow_query_info_bytime(text, TIMESTAMP, TIMESTAMP, int) + RETURNS setof dbe_perf.gs_slow_query_info + AS $$ +DECLARE + row_data dbe_perf.gs_slow_query_info%rowtype; + row_name record; + query_str text; + query_str_nodes text; + query_str_cn text; + BEGIN + IF $1 IN ('start_time', 'finish_time') THEN + ELSE + raise WARNING 'Illegal character entered for function, colname must be start_time or finish_time'; + return; + END IF; + --Get all the node names + query_str_nodes := 'SELECT node_name FROM pgxc_node WHERE node_type=''C'' AND nodeis_active = true'; + query_str_cn := 'SELECT * FROM dbe_perf.gs_slow_query_info where '||$1||'>'''''||$2||''''' and '||$1||'<'''''||$3||''''' limit '||$4; + FOR row_name IN EXECUTE(query_str_nodes) LOOP + query_str := 'EXECUTE DIRECT ON (' || row_name.node_name || ') ''' || query_str_cn||''';'; + FOR row_data IN EXECUTE(query_str) LOOP + return next row_data; + END LOOP; + END LOOP; + return; + END; $$ + LANGUAGE 'plpgsql' NOT FENCED; + end if; +END$gs_slow_query_info$; diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_92_957.sql b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_92_957.sql index cca5c92e9a55b9acfa87bfdb3af1e0da95bc5659..ba13972c9a718466199edae61e263051767b2940 100644 --- a/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_92_957.sql +++ b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_92_957.sql @@ -13,7 +13,7 @@ CREATE FUNCTION pg_catalog.gs_stat_walsender( out avg_send_interval xid, out since_last_send_interval xid ) -RETURNS SETOF record LANGUAGE INTERNAL as 'gs_stat_walsender' stable; +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 as 'gs_stat_walsender' stable; -- create gs_stat_walreceiver DROP FUNCTION IF EXISTS pg_catalog.gs_stat_walreceiver(int4) CASCADE; @@ -31,7 +31,7 @@ CREATE FUNCTION pg_catalog.gs_stat_walreceiver( out last_reset_time timestamptz, out cur_time timestamptz ) -RETURNS SETOF record LANGUAGE INTERNAL as 'gs_stat_walreceiver' stable; +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 as 'gs_stat_walreceiver' stable; -- create gs_stat_walrecvwriter DROP FUNCTION IF EXISTS pg_catalog.gs_stat_walrecvwriter(int4) CASCADE; @@ -54,4 +54,115 @@ CREATE FUNCTION pg_catalog.gs_stat_walrecvwriter( out last_reset_time timestamptz, out cur_time timestamptz ) -RETURNS SETOF record LANGUAGE INTERNAL as 'gs_stat_walrecvwriter' stable; \ No newline at end of file +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 as 'gs_stat_walrecvwriter' stable; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select * from pg_conversion where conname = 'gb18030_2022_to_utf8' limit 1) into ans; + if ans = true THEN + comment on conversion gb18030_2022_to_utf8 is 'conversion for GB18030_2022 to UTF8'; + end if; +END$$; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select * from pg_conversion where conname = 'utf8_to_gb18030_2022' limit 1) into ans; + if ans = true THEN + comment on conversion utf8_to_gb18030_2022 is 'conversion for UTF8 to GB18030_2022'; + end if; +END$$; + + +DROP FUNCTION IF EXISTS pg_catalog.gs_hot_standby_space_info() cascade; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6218; +CREATE OR REPLACE FUNCTION pg_catalog.gs_hot_standby_space_info +( OUT base_page_file_num xid, + OUT base_page_total_size xid, + OUT lsn_info_meta_file_num xid, + OUT lsn_info_meta_total_size xid, + OUT block_info_meta_file_num xid, + OUT block_info_meta_total_size xid + ) +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 STABLE as 'gs_hot_standby_space_info'; + +DROP FUNCTION IF EXISTS pg_catalog.btvarstrequalimage(oid) cascade; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4608; +CREATE OR REPLACE FUNCTION pg_catalog.btvarstrequalimage("any") RETURNS boolean LANGUAGE INTERNAL IMMUTABLE STRICT AS 'btvarstrequalimage'; + +DROP FUNCTION IF EXISTS pg_catalog.btequalimage(oid) CASCADE; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4609; +CREATE OR REPLACE FUNCTION pg_catalog.btequalimage("any") RETURNS boolean LANGUAGE INTERNAL IMMUTABLE STRICT AS 'btequalimage'; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select nspname from pg_namespace where nspname='coverage' limit 1) into ans; + if ans = true THEN + DROP table IF EXISTS coverage.proc_coverage; + DROP SEQUENCE IF EXISTS coverage.proc_coverage_coverage_id_seq; + DROP SCHEMA IF EXISTS coverage cascade; + end if; +END$$; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_NAMESPACE, 4994; +CREATE SCHEMA coverage; +COMMENT ON schema coverage IS 'coverage schema'; + +CREATE SEQUENCE coverage.proc_coverage_coverage_id_seq START 1; +CREATE unlogged table coverage.proc_coverage( + coverage_id bigint NOT NULL DEFAULT nextval('coverage.proc_coverage_coverage_id_seq'::regclass), + pro_oid oid NOT NULL, + pro_name text NOT NULL, + db_name text NOT NULL, + pro_querys text NOT NULL, + pro_canbreak bool[] NOT NULL, + coverage int[] NOT NULL +) WITH (orientation=row, compression=no); +REVOKE ALL on table coverage.proc_coverage FROM public; + +DROP FUNCTION IF EXISTS pg_catalog.generate_procoverage_report(int8, int8) CASCADE; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 5734; +CREATE OR REPLACE FUNCTION pg_catalog.generate_procoverage_report(int8, int8) RETURNS text +LANGUAGE INTERNAL STRICT as 'generate_procoverage_report'; + +-- add this. dropped by 92_906 +DO $gs_slow_query_info$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select relname from pg_class where relname='gs_slow_query_info' and relnamespace=4988 limit 1) into ans; + if ans = true THEN + CREATE OR REPLACE FUNCTION dbe_perf.global_slow_query_info_bytime(text, TIMESTAMP, TIMESTAMP, int) + RETURNS setof dbe_perf.gs_slow_query_info + AS $$ +DECLARE + row_data dbe_perf.gs_slow_query_info%rowtype; + row_name record; + query_str text; + query_str_nodes text; + query_str_cn text; + BEGIN + IF $1 IN ('start_time', 'finish_time') THEN + ELSE + raise WARNING 'Illegal character entered for function, colname must be start_time or finish_time'; + return; + END IF; + --Get all the node names + query_str_nodes := 'SELECT node_name FROM pgxc_node WHERE node_type=''C'' AND nodeis_active = true'; + query_str_cn := 'SELECT * FROM dbe_perf.gs_slow_query_info where '||$1||'>'''''||$2||''''' and '||$1||'<'''''||$3||''''' limit '||$4; + FOR row_name IN EXECUTE(query_str_nodes) LOOP + query_str := 'EXECUTE DIRECT ON (' || row_name.node_name || ') ''' || query_str_cn||''';'; + FOR row_data IN EXECUTE(query_str) LOOP + return next row_data; + END LOOP; + END LOOP; + return; + END; $$ + LANGUAGE 'plpgsql' NOT FENCED; + end if; +END$gs_slow_query_info$; diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_957.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_957.sql index b23c9d1e54f8aa8eb6bc1a817d99a43f43fb60be..ba13972c9a718466199edae61e263051767b2940 100644 --- a/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_957.sql +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_957.sql @@ -54,4 +54,115 @@ CREATE FUNCTION pg_catalog.gs_stat_walrecvwriter( out last_reset_time timestamptz, out cur_time timestamptz ) -RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 as 'gs_stat_walrecvwriter' stable; \ No newline at end of file +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 as 'gs_stat_walrecvwriter' stable; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select * from pg_conversion where conname = 'gb18030_2022_to_utf8' limit 1) into ans; + if ans = true THEN + comment on conversion gb18030_2022_to_utf8 is 'conversion for GB18030_2022 to UTF8'; + end if; +END$$; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select * from pg_conversion where conname = 'utf8_to_gb18030_2022' limit 1) into ans; + if ans = true THEN + comment on conversion utf8_to_gb18030_2022 is 'conversion for UTF8 to GB18030_2022'; + end if; +END$$; + + +DROP FUNCTION IF EXISTS pg_catalog.gs_hot_standby_space_info() cascade; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6218; +CREATE OR REPLACE FUNCTION pg_catalog.gs_hot_standby_space_info +( OUT base_page_file_num xid, + OUT base_page_total_size xid, + OUT lsn_info_meta_file_num xid, + OUT lsn_info_meta_total_size xid, + OUT block_info_meta_file_num xid, + OUT block_info_meta_total_size xid + ) +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 STABLE as 'gs_hot_standby_space_info'; + +DROP FUNCTION IF EXISTS pg_catalog.btvarstrequalimage(oid) cascade; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4608; +CREATE OR REPLACE FUNCTION pg_catalog.btvarstrequalimage("any") RETURNS boolean LANGUAGE INTERNAL IMMUTABLE STRICT AS 'btvarstrequalimage'; + +DROP FUNCTION IF EXISTS pg_catalog.btequalimage(oid) CASCADE; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4609; +CREATE OR REPLACE FUNCTION pg_catalog.btequalimage("any") RETURNS boolean LANGUAGE INTERNAL IMMUTABLE STRICT AS 'btequalimage'; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select nspname from pg_namespace where nspname='coverage' limit 1) into ans; + if ans = true THEN + DROP table IF EXISTS coverage.proc_coverage; + DROP SEQUENCE IF EXISTS coverage.proc_coverage_coverage_id_seq; + DROP SCHEMA IF EXISTS coverage cascade; + end if; +END$$; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_NAMESPACE, 4994; +CREATE SCHEMA coverage; +COMMENT ON schema coverage IS 'coverage schema'; + +CREATE SEQUENCE coverage.proc_coverage_coverage_id_seq START 1; +CREATE unlogged table coverage.proc_coverage( + coverage_id bigint NOT NULL DEFAULT nextval('coverage.proc_coverage_coverage_id_seq'::regclass), + pro_oid oid NOT NULL, + pro_name text NOT NULL, + db_name text NOT NULL, + pro_querys text NOT NULL, + pro_canbreak bool[] NOT NULL, + coverage int[] NOT NULL +) WITH (orientation=row, compression=no); +REVOKE ALL on table coverage.proc_coverage FROM public; + +DROP FUNCTION IF EXISTS pg_catalog.generate_procoverage_report(int8, int8) CASCADE; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 5734; +CREATE OR REPLACE FUNCTION pg_catalog.generate_procoverage_report(int8, int8) RETURNS text +LANGUAGE INTERNAL STRICT as 'generate_procoverage_report'; + +-- add this. dropped by 92_906 +DO $gs_slow_query_info$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select relname from pg_class where relname='gs_slow_query_info' and relnamespace=4988 limit 1) into ans; + if ans = true THEN + CREATE OR REPLACE FUNCTION dbe_perf.global_slow_query_info_bytime(text, TIMESTAMP, TIMESTAMP, int) + RETURNS setof dbe_perf.gs_slow_query_info + AS $$ +DECLARE + row_data dbe_perf.gs_slow_query_info%rowtype; + row_name record; + query_str text; + query_str_nodes text; + query_str_cn text; + BEGIN + IF $1 IN ('start_time', 'finish_time') THEN + ELSE + raise WARNING 'Illegal character entered for function, colname must be start_time or finish_time'; + return; + END IF; + --Get all the node names + query_str_nodes := 'SELECT node_name FROM pgxc_node WHERE node_type=''C'' AND nodeis_active = true'; + query_str_cn := 'SELECT * FROM dbe_perf.gs_slow_query_info where '||$1||'>'''''||$2||''''' and '||$1||'<'''''||$3||''''' limit '||$4; + FOR row_name IN EXECUTE(query_str_nodes) LOOP + query_str := 'EXECUTE DIRECT ON (' || row_name.node_name || ') ''' || query_str_cn||''';'; + FOR row_data IN EXECUTE(query_str) LOOP + return next row_data; + END LOOP; + END LOOP; + return; + END; $$ + LANGUAGE 'plpgsql' NOT FENCED; + end if; +END$gs_slow_query_info$; diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_957.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_957.sql index b23c9d1e54f8aa8eb6bc1a817d99a43f43fb60be..ba13972c9a718466199edae61e263051767b2940 100644 --- a/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_957.sql +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_957.sql @@ -54,4 +54,115 @@ CREATE FUNCTION pg_catalog.gs_stat_walrecvwriter( out last_reset_time timestamptz, out cur_time timestamptz ) -RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 as 'gs_stat_walrecvwriter' stable; \ No newline at end of file +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 as 'gs_stat_walrecvwriter' stable; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select * from pg_conversion where conname = 'gb18030_2022_to_utf8' limit 1) into ans; + if ans = true THEN + comment on conversion gb18030_2022_to_utf8 is 'conversion for GB18030_2022 to UTF8'; + end if; +END$$; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select * from pg_conversion where conname = 'utf8_to_gb18030_2022' limit 1) into ans; + if ans = true THEN + comment on conversion utf8_to_gb18030_2022 is 'conversion for UTF8 to GB18030_2022'; + end if; +END$$; + + +DROP FUNCTION IF EXISTS pg_catalog.gs_hot_standby_space_info() cascade; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6218; +CREATE OR REPLACE FUNCTION pg_catalog.gs_hot_standby_space_info +( OUT base_page_file_num xid, + OUT base_page_total_size xid, + OUT lsn_info_meta_file_num xid, + OUT lsn_info_meta_total_size xid, + OUT block_info_meta_file_num xid, + OUT block_info_meta_total_size xid + ) +RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 STABLE as 'gs_hot_standby_space_info'; + +DROP FUNCTION IF EXISTS pg_catalog.btvarstrequalimage(oid) cascade; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4608; +CREATE OR REPLACE FUNCTION pg_catalog.btvarstrequalimage("any") RETURNS boolean LANGUAGE INTERNAL IMMUTABLE STRICT AS 'btvarstrequalimage'; + +DROP FUNCTION IF EXISTS pg_catalog.btequalimage(oid) CASCADE; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4609; +CREATE OR REPLACE FUNCTION pg_catalog.btequalimage("any") RETURNS boolean LANGUAGE INTERNAL IMMUTABLE STRICT AS 'btequalimage'; + +DO $$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select nspname from pg_namespace where nspname='coverage' limit 1) into ans; + if ans = true THEN + DROP table IF EXISTS coverage.proc_coverage; + DROP SEQUENCE IF EXISTS coverage.proc_coverage_coverage_id_seq; + DROP SCHEMA IF EXISTS coverage cascade; + end if; +END$$; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_NAMESPACE, 4994; +CREATE SCHEMA coverage; +COMMENT ON schema coverage IS 'coverage schema'; + +CREATE SEQUENCE coverage.proc_coverage_coverage_id_seq START 1; +CREATE unlogged table coverage.proc_coverage( + coverage_id bigint NOT NULL DEFAULT nextval('coverage.proc_coverage_coverage_id_seq'::regclass), + pro_oid oid NOT NULL, + pro_name text NOT NULL, + db_name text NOT NULL, + pro_querys text NOT NULL, + pro_canbreak bool[] NOT NULL, + coverage int[] NOT NULL +) WITH (orientation=row, compression=no); +REVOKE ALL on table coverage.proc_coverage FROM public; + +DROP FUNCTION IF EXISTS pg_catalog.generate_procoverage_report(int8, int8) CASCADE; +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 5734; +CREATE OR REPLACE FUNCTION pg_catalog.generate_procoverage_report(int8, int8) RETURNS text +LANGUAGE INTERNAL STRICT as 'generate_procoverage_report'; + +-- add this. dropped by 92_906 +DO $gs_slow_query_info$ +DECLARE + ans boolean; +BEGIN +select case when count(*)=1 then true else false end from (select relname from pg_class where relname='gs_slow_query_info' and relnamespace=4988 limit 1) into ans; + if ans = true THEN + CREATE OR REPLACE FUNCTION dbe_perf.global_slow_query_info_bytime(text, TIMESTAMP, TIMESTAMP, int) + RETURNS setof dbe_perf.gs_slow_query_info + AS $$ +DECLARE + row_data dbe_perf.gs_slow_query_info%rowtype; + row_name record; + query_str text; + query_str_nodes text; + query_str_cn text; + BEGIN + IF $1 IN ('start_time', 'finish_time') THEN + ELSE + raise WARNING 'Illegal character entered for function, colname must be start_time or finish_time'; + return; + END IF; + --Get all the node names + query_str_nodes := 'SELECT node_name FROM pgxc_node WHERE node_type=''C'' AND nodeis_active = true'; + query_str_cn := 'SELECT * FROM dbe_perf.gs_slow_query_info where '||$1||'>'''''||$2||''''' and '||$1||'<'''''||$3||''''' limit '||$4; + FOR row_name IN EXECUTE(query_str_nodes) LOOP + query_str := 'EXECUTE DIRECT ON (' || row_name.node_name || ') ''' || query_str_cn||''';'; + FOR row_data IN EXECUTE(query_str) LOOP + return next row_data; + END LOOP; + END LOOP; + return; + END; $$ + LANGUAGE 'plpgsql' NOT FENCED; + end if; +END$gs_slow_query_info$;