forked from huawei/openGauss-server
fix issue of duplicated upgrade sql
This commit is contained in:
parent
25ecba5316
commit
f8a23647d7
|
|
@ -0,0 +1,276 @@
|
|||
--------------------------------------------------------------
|
||||
-- delete pg_amop
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_amop_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_amop where amopfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_amop_temp();
|
||||
DROP FUNCTION Delete_pg_amop_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_amproc
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_amproc_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_amproc where amprocfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_amproc_temp();
|
||||
DROP FUNCTION Delete_pg_amproc_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_opclass
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_opclass_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_opclass where opcfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_opclass_temp();
|
||||
DROP FUNCTION Delete_pg_opclass_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_cast
|
||||
--------------------------------------------------------------
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP CAST IF EXISTS (json AS jsonb) CASCADE;
|
||||
DROP CAST IF EXISTS (jsonb AS json) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_opfamily
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_opfamily_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_opfamily where oid in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_opfamily_temp();
|
||||
DROP FUNCTION Delete_pg_opfamily_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_operator
|
||||
--------------------------------------------------------------
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(json, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(json, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(json, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(json, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>(json, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>>(json, _text) cascade;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(jsonb, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(jsonb, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>>(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.>=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.@>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?|(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?&(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<@(jsonb, jsonb) cascade;
|
||||
end if;
|
||||
END$$;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete builtin funcs
|
||||
--------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_compare_jsonb(text, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_consistent_jsonb(internal, smallint, anyarray, integer, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_consistent_jsonb_hash(internal, smallint, anyarray, integer, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb(internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_hash(internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_query(anyarray, internal, smallint, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_query_hash(anyarray, internal, smallint, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_triconsistent_jsonb(internal, smallint, anyarray, integer, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_triconsistent_jsonb_hash(internal, smallint, anyarray, integer, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_element(json, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_element_text(json, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_elements(from_json json, OUT value json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_elements_text(from_json json, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_length(json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_array() CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_array(VARIADIC "any") CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_object() CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_object(VARIADIC "any") CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_each(from_json json, OUT key text, OUT value json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_each_text(from_json json, OUT key text, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path(json, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_op(json, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_text(json, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_text_op(json, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object(text[], text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object(text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_field(json, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_field_text(json, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_keys(json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_populate_record(anyelement, json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_populate_recordset(anyelement, json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_to_record(json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_to_recordset(json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_json(anyelement) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_typeof(json) CASCADE;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_element(jsonb, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_element_text(jsonb, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_elements(from_json jsonb, OUT value jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_elements_text(from_json jsonb, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_length(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_cmp(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_contained(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_contains(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_each(from_json jsonb, OUT key text, OUT value jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_each_text(from_json jsonb, OUT key text, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_eq(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists_all(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists_any(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path(jsonb, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_op(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_text(jsonb, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_text_op(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_ge(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_gt(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_hash(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_le(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_lt(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_ne(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_field(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_field_text(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_keys(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_populate_record(anyelement, jsonb, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_populate_recordset(anyelement, jsonb, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_typeof(jsonb) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
----------------------------------------------------------------
|
||||
-- recover funcs
|
||||
----------------------------------------------------------------
|
||||
ALTER FUNCTION json_in(cstring) STABLE;
|
||||
ALTER FUNCTION json_send(json) STABLE;
|
||||
ALTER FUNCTION json_recv(internal) STABLE;
|
||||
|
||||
----------------------------------------------------------------
|
||||
-- delete two agg funcs
|
||||
----------------------------------------------------------------
|
||||
drop aggregate if exists pg_catalog.json_object_agg("any", "any");
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_agg_finalfn(internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_agg_transfn(internal, "any", "any") CASCADE;
|
||||
|
||||
drop aggregate if exists pg_catalog.json_agg(anyelement);
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_agg_finalfn(internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_agg_transfn(internal, anyelement) CASCADE;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete type jsonb
|
||||
--------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_in(cstring) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_recv(internal) CASCADE;
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_out(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_send(jsonb) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
DROP TYPE IF EXISTS pg_catalog._jsonb;
|
||||
DROP TYPE IF EXISTS pg_catalog.jsonb;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_decrypt(IN decryptstr text, IN keystr text, IN type text,OUT decrypt_result_str text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_encrypt(IN encryptstr text, IN keystr text, IN type text,OUT encrypt_result_str text) CASCADE;DROP FUNCTION IF EXISTS pg_catalog.gs_decrypt(IN decryptstr text, IN keystr text, IN type text,OUT decrypt_result_str text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_encrypt(IN encryptstr text, IN keystr text, IN type text,OUT encrypt_result_str text) CASCADE;DROP FUNCTION IF EXISTS pg_catalog.gs_decrypt(IN decryptstr text, IN keystr text, IN type text,OUT decrypt_result_str text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_encrypt(IN encryptstr text, IN keystr text, IN type text,OUT encrypt_result_str text) CASCADE;UPDATE pg_catalog.pg_am set amcanunique = FALSE where amname = 'cbtree';
|
||||
CREATE OR REPLACE VIEW pg_catalog.gs_session_cpu_statistics AS
|
||||
SELECT
|
||||
S.datid AS datid,
|
||||
S.usename,
|
||||
S.pid,
|
||||
S.query_start AS start_time,
|
||||
T.min_cpu_time,
|
||||
T.max_cpu_time,
|
||||
T.total_cpu_time,
|
||||
S.query,
|
||||
S.node_group,
|
||||
T.top_cpu_dn
|
||||
FROM pg_stat_activity_ng AS S, pg_stat_get_wlm_realtime_session_info(NULL) AS T
|
||||
WHERE S.pid = T.threadid;
|
||||
|
|
@ -171,265 +171,8 @@ DROP FUNCTION IF EXISTS pg_catalog.array_extendnull(anyarray, integer) CASCADE;
|
|||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_streaming_dr_in_switchover() cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_streaming_dr_get_switchover_barrier() cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_streaming_dr_service_truncation_check() cascade;DROP FUNCTION IF EXISTS pg_catalog.gs_decrypt(IN decryptstr text, IN keystr text, IN type text,OUT decrypt_result_str text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_encrypt(IN encryptstr text, IN keystr text, IN type text,OUT encrypt_result_str text) CASCADE;UPDATE pg_catalog.pg_am set amcanunique = FALSE where amname = 'cbtree';
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_amop
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_amop_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_amop where amopfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_streaming_dr_service_truncation_check() cascade;
|
||||
|
||||
SELECT Delete_pg_amop_temp();
|
||||
DROP FUNCTION Delete_pg_amop_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_amproc
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_amproc_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_amproc where amprocfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_amproc_temp();
|
||||
DROP FUNCTION Delete_pg_amproc_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_opclass
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_opclass_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_opclass where opcfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_opclass_temp();
|
||||
DROP FUNCTION Delete_pg_opclass_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_cast
|
||||
--------------------------------------------------------------
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP CAST IF EXISTS (json AS jsonb) CASCADE;
|
||||
DROP CAST IF EXISTS (jsonb AS json) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_opfamily
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_opfamily_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_opfamily where oid in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_opfamily_temp();
|
||||
DROP FUNCTION Delete_pg_opfamily_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_operator
|
||||
--------------------------------------------------------------
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(json, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(json, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(json, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(json, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>(json, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>>(json, _text) cascade;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(jsonb, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(jsonb, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>>(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.>=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.@>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?|(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?&(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<@(jsonb, jsonb) cascade;
|
||||
end if;
|
||||
END$$;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete builtin funcs
|
||||
--------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_compare_jsonb(text, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_consistent_jsonb(internal, smallint, anyarray, integer, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_consistent_jsonb_hash(internal, smallint, anyarray, integer, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb(internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_hash(internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_query(anyarray, internal, smallint, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_query_hash(anyarray, internal, smallint, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_triconsistent_jsonb(internal, smallint, anyarray, integer, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_triconsistent_jsonb_hash(internal, smallint, anyarray, integer, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_element(json, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_element_text(json, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_elements(from_json json, OUT value json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_elements_text(from_json json, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_length(json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_array() CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_array(VARIADIC "any") CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_object() CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_object(VARIADIC "any") CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_each(from_json json, OUT key text, OUT value json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_each_text(from_json json, OUT key text, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path(json, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_op(json, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_text(json, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_text_op(json, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object(text[], text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object(text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_field(json, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_field_text(json, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_keys(json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_populate_record(anyelement, json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_populate_recordset(anyelement, json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_to_record(json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_to_recordset(json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_json(anyelement) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_typeof(json) CASCADE;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_element(jsonb, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_element_text(jsonb, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_elements(from_json jsonb, OUT value jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_elements_text(from_json jsonb, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_length(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_cmp(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_contained(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_contains(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_each(from_json jsonb, OUT key text, OUT value jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_each_text(from_json jsonb, OUT key text, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_eq(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists_all(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists_any(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path(jsonb, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_op(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_text(jsonb, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_text_op(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_ge(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_gt(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_hash(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_le(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_lt(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_ne(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_field(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_field_text(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_keys(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_populate_record(anyelement, jsonb, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_populate_recordset(anyelement, jsonb, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_typeof(jsonb) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
----------------------------------------------------------------
|
||||
-- recover funcs
|
||||
----------------------------------------------------------------
|
||||
ALTER FUNCTION json_in(cstring) STABLE;
|
||||
ALTER FUNCTION json_send(json) STABLE;
|
||||
ALTER FUNCTION json_recv(internal) STABLE;
|
||||
|
||||
----------------------------------------------------------------
|
||||
-- delete two agg funcs
|
||||
----------------------------------------------------------------
|
||||
drop aggregate if exists pg_catalog.json_object_agg("any", "any");
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_agg_finalfn(internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_agg_transfn(internal, "any", "any") CASCADE;
|
||||
|
||||
drop aggregate if exists pg_catalog.json_agg(anyelement);
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_agg_finalfn(internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_agg_transfn(internal, anyelement) CASCADE;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete type jsonb
|
||||
--------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_in(cstring) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_recv(internal) CASCADE;
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_out(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_send(jsonb) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
|
||||
DROP TYPE IF EXISTS pg_catalog.jsonb;
|
||||
do $$DECLARE ans boolean;
|
||||
BEGIN
|
||||
for ans in select case when count(*)=1 then true else false end as ans from (select nspname from pg_namespace where nspname='dbe_pldebugger' limit 1)
|
||||
|
|
@ -691,25 +434,12 @@ BEGIN
|
|||
END LOOP;
|
||||
END$$;
|
||||
RESET search_path;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;-- ----------------------------------------------------------------
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
-- ----------------------------------------------------------------
|
||||
-- rollback array interface of pg_catalog
|
||||
-- ----------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_trim(anyarray, integer) CASCADE;
|
||||
|
||||
CREATE OR REPLACE VIEW pg_catalog.gs_session_cpu_statistics AS
|
||||
SELECT
|
||||
S.datid AS datid,
|
||||
S.usename,
|
||||
S.pid,
|
||||
S.query_start AS start_time,
|
||||
T.min_cpu_time,
|
||||
T.max_cpu_time,
|
||||
T.total_cpu_time,
|
||||
S.query,
|
||||
S.node_group,
|
||||
T.top_cpu_dn
|
||||
FROM pg_stat_activity_ng AS S, pg_stat_get_wlm_realtime_session_info(NULL) AS T
|
||||
WHERE S.pid = T.threadid;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.copy_summary_create() CASCADE;
|
||||
do $$DECLARE
|
||||
ans boolean;
|
||||
|
|
@ -2396,7 +2126,9 @@ CREATE FUNCTION pg_catalog.global_comm_get_status(OUT node_name text, OUT "rxpck
|
|||
|
||||
GRANT SELECT ON pg_catalog.pg_comm_status TO public;DROP FUNCTION IF EXISTS pg_catalog.dynamic_func_control() cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.nlssort(text, text);DROP FUNCTION IF EXISTS pg_catalog.gs_write_term_log() cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_indexby_length(anyarray, integer) cascade;-- deleting system view
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_indexby_length(anyarray, integer) cascade;
|
||||
|
||||
-- deleting system view
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_publication_tables;
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_stat_subscription;
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_replication_origin_status;
|
||||
|
|
|
|||
|
|
@ -1992,66 +1992,8 @@ DROP FUNCTION IF EXISTS pg_catalog.gs_read_file_from_remote(oid, oid, oid, integ
|
|||
DROP FUNCTION IF EXISTS pg_catalog.gs_read_file_size_from_remote(oid, oid, oid, integer, integer, xid, integer) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_read_segment_block_from_remote(integer, integer, integer, smallint, integer, xid, integer, xid, integer, integer) CASCADE;
|
||||
-- deleting system view
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_publication_tables;
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_stat_subscription;
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_replication_origin_status;
|
||||
|
||||
-- deleting function pg_replication_origin_create
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_create(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_drop
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_drop(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_oid
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_oid(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_session_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_setup(IN node_name text) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_session_reset
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_reset() CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_session_is_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_is_setup() CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_session_progress
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_progress(IN flush boolean) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_xact_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_xact_setup(IN origin_lsn text, IN origin_timestamp timestamp with time zone) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_xact_reset
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_xact_reset() CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_advance
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_advance(IN node_name text, IN lsn text) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_progress
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_progress(IN node_name text, IN flush boolean) CASCADE;
|
||||
|
||||
-- deleting function pg_show_replication_origin_status
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_show_replication_origin_status(OUT local_id oid, OUT external_id text, OUT remote_lsn text, OUT local_lsn text) CASCADE;
|
||||
|
||||
-- deleting function pg_get_publication_tables
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_get_publication_tables(IN pubname text, OUT relid oid) CASCADE;
|
||||
|
||||
-- deleting function pg_stat_get_subscription
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_stat_get_subscription(IN subid oid, OUT subid oid, OUT pid integer, OUT received_lsn text, OUT last_msg_send_time timestamp with time zone, OUT last_msg_receipt_time timestamp with time zone, OUT latest_end_lsn text, OUT latest_end_time timestamp with time zone) CASCADE;
|
||||
|
||||
-- deleting system table pg_subscription
|
||||
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_subscription_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_subscription_subname_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.pg_subscription;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_subscription;
|
||||
|
||||
-- deleting system table pg_replication_origin
|
||||
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_replication_origin_roident_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_replication_origin_roname_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.pg_replication_origin;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_replication_origin;DROP FUNCTION IF EXISTS pg_catalog.gs_explain_model(text) cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_explain_model(text) cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_float8_array(text, VARIADIC "any") cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_bool(text, VARIADIC "any") cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_float4(text, VARIADIC "any") cascade;
|
||||
|
|
@ -2321,19 +2263,6 @@ CREATE OR REPLACE FUNCTION pg_catalog.gs_read_block_from_remote(integer, integer
|
|||
STRICT NOT FENCED NOT SHIPPABLE
|
||||
AS $function$gs_read_block_from_remote$function$;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_remove(anyarray, anyelement) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_replace(anyarray, anyelement, anyelement) CASCADE;
|
||||
DROP AGGREGATE IF EXISTS pg_catalog.last(anyelement) CASCADE;
|
||||
DROP AGGREGATE IF EXISTS pg_catalog.first(anyelement) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.last_transition(anyelement, anyelement) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.first_transition(anyelement, anyelement) CASCADE;
|
||||
|
||||
|
||||
|
||||
DROP AGGREGATE IF EXISTS pg_catalog.max(inet) CASCADE;
|
||||
DROP AGGREGATE IF EXISTS pg_catalog.min(inet) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.network_larger(inet, inet) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.network_smaller(inet, inet) CASCADE;
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_buffercache_pages() CASCADE;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,529 @@
|
|||
SET search_path TO information_schema;
|
||||
|
||||
-- element_types is generated by data_type_privileges
|
||||
DROP VIEW IF EXISTS information_schema.element_types CASCADE;
|
||||
|
||||
-- data_type_privileges is generated by columns
|
||||
DROP VIEW IF EXISTS information_schema.data_type_privileges CASCADE;
|
||||
-- data_type_privileges is generated by table_privileges
|
||||
DROP VIEW IF EXISTS information_schema.role_column_grants CASCADE;
|
||||
-- data_type_privileges is generated by column_privileges
|
||||
DROP VIEW IF EXISTS information_schema.role_table_grants CASCADE;
|
||||
|
||||
-- other views need upgrade for matview
|
||||
DROP VIEW IF EXISTS information_schema.column_domain_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.column_privileges CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.column_udt_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.columns CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.table_privileges CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.tables CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.view_column_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.view_table_usage CASCADE;
|
||||
|
||||
CREATE VIEW information_schema.column_domain_usage AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS domain_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS domain_schema,
|
||||
CAST(t.typname AS sql_identifier) AS domain_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_type t, pg_namespace nt, pg_class c, pg_namespace nc,
|
||||
pg_attribute a
|
||||
|
||||
WHERE t.typnamespace = nt.oid
|
||||
AND c.relnamespace = nc.oid
|
||||
AND a.attrelid = c.oid
|
||||
AND a.atttypid = t.oid
|
||||
AND t.typtype = 'd'
|
||||
AND c.relkind IN ('r', 'v', 'f')
|
||||
AND a.attnum > 0
|
||||
AND NOT a.attisdropped
|
||||
AND pg_has_role(t.typowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.column_privileges AS
|
||||
SELECT CAST(u_grantor.rolname AS sql_identifier) AS grantor,
|
||||
CAST(grantee.rolname AS sql_identifier) AS grantee,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(x.relname AS sql_identifier) AS table_name,
|
||||
CAST(x.attname AS sql_identifier) AS column_name,
|
||||
CAST(x.prtype AS character_data) AS privilege_type,
|
||||
CAST(
|
||||
CASE WHEN
|
||||
-- object owner always has grant options
|
||||
pg_has_role(x.grantee, x.relowner, 'USAGE')
|
||||
OR x.grantable
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_grantable
|
||||
|
||||
FROM (
|
||||
SELECT pr_c.grantor,
|
||||
pr_c.grantee,
|
||||
attname,
|
||||
relname,
|
||||
relnamespace,
|
||||
pr_c.prtype,
|
||||
pr_c.grantable,
|
||||
pr_c.relowner
|
||||
FROM (SELECT oid, relname, relnamespace, relowner, (aclexplode(coalesce(relacl, acldefault('r', relowner)))).*
|
||||
FROM pg_class
|
||||
WHERE relkind IN ('r', 'v', 'f')
|
||||
) pr_c (oid, relname, relnamespace, relowner, grantor, grantee, prtype, grantable),
|
||||
pg_attribute a
|
||||
WHERE a.attrelid = pr_c.oid
|
||||
AND a.attnum > 0
|
||||
AND NOT a.attisdropped
|
||||
UNION
|
||||
SELECT pr_a.grantor,
|
||||
pr_a.grantee,
|
||||
attname,
|
||||
relname,
|
||||
relnamespace,
|
||||
pr_a.prtype,
|
||||
pr_a.grantable,
|
||||
c.relowner
|
||||
FROM (SELECT attrelid, attname, (aclexplode(coalesce(attacl, acldefault('c', relowner)))).*
|
||||
FROM pg_attribute a JOIN pg_class cc ON (a.attrelid = cc.oid)
|
||||
WHERE attnum > 0
|
||||
AND NOT attisdropped
|
||||
) pr_a (attrelid, attname, grantor, grantee, prtype, grantable),
|
||||
pg_class c
|
||||
WHERE pr_a.attrelid = c.oid
|
||||
AND relkind IN ('r', 'v', 'f')
|
||||
) x,
|
||||
pg_namespace nc,
|
||||
pg_authid u_grantor,
|
||||
(
|
||||
SELECT oid, rolname FROM pg_authid
|
||||
UNION ALL
|
||||
SELECT 0::oid, 'PUBLIC'
|
||||
) AS grantee (oid, rolname)
|
||||
|
||||
WHERE x.relnamespace = nc.oid
|
||||
AND x.grantee = grantee.oid
|
||||
AND x.grantor = u_grantor.oid
|
||||
AND x.prtype IN ('INSERT', 'SELECT', 'UPDATE', 'REFERENCES', 'COMMENT')
|
||||
AND (pg_has_role(u_grantor.oid, 'USAGE')
|
||||
OR pg_has_role(grantee.oid, 'USAGE')
|
||||
OR grantee.rolname = 'PUBLIC');
|
||||
|
||||
CREATE VIEW information_schema.column_udt_usage AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(coalesce(nbt.nspname, nt.nspname) AS sql_identifier) AS udt_schema,
|
||||
CAST(coalesce(bt.typname, t.typname) AS sql_identifier) AS udt_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_attribute a, pg_class c, pg_namespace nc,
|
||||
(pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid))
|
||||
LEFT JOIN (pg_type bt JOIN pg_namespace nbt ON (bt.typnamespace = nbt.oid))
|
||||
ON (t.typtype = 'd' AND t.typbasetype = bt.oid)
|
||||
|
||||
WHERE a.attrelid = c.oid
|
||||
AND a.atttypid = t.oid
|
||||
AND nc.oid = c.relnamespace
|
||||
AND a.attnum > 0 AND NOT a.attisdropped AND c.relkind in ('r', 'v', 'f')
|
||||
AND pg_has_role(coalesce(bt.typowner, t.typowner), 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.columns AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name,
|
||||
CAST(a.attnum AS cardinal_number) AS ordinal_position,
|
||||
CAST(pg_get_expr(ad.adbin, ad.adrelid) AS character_data) AS column_default,
|
||||
CAST(CASE WHEN a.attnotnull OR (t.typtype = 'd' AND t.typnotnull) THEN 'NO' ELSE 'YES' END
|
||||
AS yes_or_no)
|
||||
AS is_nullable,
|
||||
|
||||
CAST(
|
||||
CASE WHEN t.typtype = 'd' THEN
|
||||
CASE WHEN bt.typelem <> 0 AND bt.typlen = -1 THEN 'ARRAY'
|
||||
WHEN nbt.nspname = 'pg_catalog' THEN format_type(t.typbasetype, null)
|
||||
ELSE 'USER-DEFINED' END
|
||||
ELSE
|
||||
CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'ARRAY'
|
||||
WHEN nt.nspname = 'pg_catalog' THEN format_type(a.atttypid, null)
|
||||
ELSE 'USER-DEFINED' END
|
||||
END
|
||||
AS character_data)
|
||||
AS data_type,
|
||||
|
||||
CAST(
|
||||
_pg_char_max_length(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS character_maximum_length,
|
||||
|
||||
CAST(
|
||||
_pg_char_octet_length(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS character_octet_length,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_precision(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_precision,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_precision_radix(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_precision_radix,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_scale(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_scale,
|
||||
|
||||
CAST(
|
||||
_pg_datetime_precision(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS datetime_precision,
|
||||
|
||||
CAST(
|
||||
_pg_interval_type(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS character_data)
|
||||
AS interval_type,
|
||||
CAST(null AS cardinal_number) AS interval_precision,
|
||||
|
||||
CAST(null AS sql_identifier) AS character_set_catalog,
|
||||
CAST(null AS sql_identifier) AS character_set_schema,
|
||||
CAST(null AS sql_identifier) AS character_set_name,
|
||||
|
||||
CAST(CASE WHEN nco.nspname IS NOT NULL THEN current_database() END AS sql_identifier) AS collation_catalog,
|
||||
CAST(nco.nspname AS sql_identifier) AS collation_schema,
|
||||
CAST(co.collname AS sql_identifier) AS collation_name,
|
||||
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN current_database() ELSE null END
|
||||
AS sql_identifier) AS domain_catalog,
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN nt.nspname ELSE null END
|
||||
AS sql_identifier) AS domain_schema,
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN t.typname ELSE null END
|
||||
AS sql_identifier) AS domain_name,
|
||||
|
||||
CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(coalesce(nbt.nspname, nt.nspname) AS sql_identifier) AS udt_schema,
|
||||
CAST(coalesce(bt.typname, t.typname) AS sql_identifier) AS udt_name,
|
||||
|
||||
CAST(null AS sql_identifier) AS scope_catalog,
|
||||
CAST(null AS sql_identifier) AS scope_schema,
|
||||
CAST(null AS sql_identifier) AS scope_name,
|
||||
|
||||
CAST(null AS cardinal_number) AS maximum_cardinality,
|
||||
CAST(a.attnum AS sql_identifier) AS dtd_identifier,
|
||||
CAST('NO' AS yes_or_no) AS is_self_referencing,
|
||||
|
||||
CAST('NO' AS yes_or_no) AS is_identity,
|
||||
CAST(null AS character_data) AS identity_generation,
|
||||
CAST(null AS character_data) AS identity_start,
|
||||
CAST(null AS character_data) AS identity_increment,
|
||||
CAST(null AS character_data) AS identity_maximum,
|
||||
CAST(null AS character_data) AS identity_minimum,
|
||||
CAST(null AS yes_or_no) AS identity_cycle,
|
||||
|
||||
CAST('NEVER' AS character_data) AS is_generated,
|
||||
CAST(null AS character_data) AS generation_expression,
|
||||
|
||||
CAST(CASE WHEN c.relkind = 'r'
|
||||
OR (c.relkind = 'v'
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '2' AND is_instead)
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '4' AND is_instead))
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_updatable
|
||||
|
||||
FROM (pg_attribute a LEFT JOIN pg_attrdef ad ON attrelid = adrelid AND attnum = adnum)
|
||||
JOIN (pg_class c JOIN pg_namespace nc ON (c.relnamespace = nc.oid)) ON a.attrelid = c.oid
|
||||
JOIN (pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid)) ON a.atttypid = t.oid
|
||||
LEFT JOIN (pg_type bt JOIN pg_namespace nbt ON (bt.typnamespace = nbt.oid))
|
||||
ON (t.typtype = 'd' AND t.typbasetype = bt.oid)
|
||||
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
|
||||
ON a.attcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
|
||||
|
||||
WHERE (NOT pg_is_other_temp_schema(nc.oid))
|
||||
|
||||
AND a.attnum > 0 AND NOT a.attisdropped AND c.relkind in ('r', 'v', 'f')
|
||||
|
||||
AND (pg_has_role(c.relowner, 'USAGE')
|
||||
OR has_column_privilege(c.oid, a.attnum,
|
||||
'SELECT, INSERT, UPDATE, REFERENCES'));
|
||||
|
||||
CREATE VIEW information_schema.table_privileges AS
|
||||
SELECT CAST(u_grantor.rolname AS sql_identifier) AS grantor,
|
||||
CAST(grantee.rolname AS sql_identifier) AS grantee,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(c.prtype AS character_data) AS privilege_type,
|
||||
CAST(
|
||||
CASE WHEN
|
||||
-- object owner always has grant options
|
||||
pg_has_role(grantee.oid, c.relowner, 'USAGE')
|
||||
OR c.grantable
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_grantable,
|
||||
CAST(CASE WHEN c.prtype = 'SELECT' THEN 'YES' ELSE 'NO' END AS yes_or_no) AS with_hierarchy
|
||||
|
||||
FROM (
|
||||
SELECT oid, relname, relnamespace, relkind, relowner, (aclexplode(coalesce(relacl, acldefault('r', relowner)))).* FROM pg_class
|
||||
) AS c (oid, relname, relnamespace, relkind, relowner, grantor, grantee, prtype, grantable),
|
||||
pg_namespace nc,
|
||||
pg_authid u_grantor,
|
||||
(
|
||||
SELECT oid, rolname FROM pg_authid
|
||||
UNION ALL
|
||||
SELECT 0::oid, 'PUBLIC'
|
||||
) AS grantee (oid, rolname)
|
||||
|
||||
WHERE c.relnamespace = nc.oid
|
||||
AND c.relkind IN ('r', 'v')
|
||||
AND c.grantee = grantee.oid
|
||||
AND c.grantor = u_grantor.oid
|
||||
AND c.prtype IN ('INSERT', 'SELECT', 'UPDATE', 'DELETE', 'TRUNCATE', 'REFERENCES', 'TRIGGER' ,
|
||||
'ALTER', 'DROP', 'COMMENT', 'INDEX', 'VACUUM')
|
||||
AND (pg_has_role(u_grantor.oid, 'USAGE')
|
||||
OR pg_has_role(grantee.oid, 'USAGE')
|
||||
OR grantee.rolname = 'PUBLIC');
|
||||
|
||||
CREATE VIEW information_schema.tables AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
|
||||
CAST(
|
||||
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY'
|
||||
WHEN c.relkind = 'r' THEN 'BASE TABLE'
|
||||
WHEN c.relkind = 'v' THEN 'VIEW'
|
||||
WHEN c.relkind = 'f' THEN 'FOREIGN TABLE'
|
||||
ELSE null END
|
||||
AS character_data) AS table_type,
|
||||
|
||||
CAST(null AS sql_identifier) AS self_referencing_column_name,
|
||||
CAST(null AS character_data) AS reference_generation,
|
||||
|
||||
CAST(CASE WHEN t.typname IS NOT NULL THEN current_database() ELSE null END AS sql_identifier) AS user_defined_type_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS user_defined_type_schema,
|
||||
CAST(t.typname AS sql_identifier) AS user_defined_type_name,
|
||||
|
||||
CAST(CASE WHEN c.relkind = 'r'
|
||||
OR (c.relkind = 'v'
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '3' AND is_instead))
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_insertable_into,
|
||||
|
||||
CAST(CASE WHEN t.typname IS NOT NULL THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_typed,
|
||||
CAST(null AS character_data) AS commit_action
|
||||
|
||||
FROM pg_namespace nc JOIN pg_class c ON (nc.oid = c.relnamespace)
|
||||
LEFT JOIN (pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid)) ON (c.reloftype = t.oid)
|
||||
|
||||
WHERE c.relkind IN ('r', 'v', 'f')
|
||||
AND (NOT pg_is_other_temp_schema(nc.oid))
|
||||
AND (pg_has_role(c.relowner, 'USAGE')
|
||||
OR has_table_privilege(c.oid, 'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER')
|
||||
OR has_any_column_privilege(c.oid, 'SELECT, INSERT, UPDATE, REFERENCES') );
|
||||
|
||||
CREATE VIEW information_schema.view_column_usage AS
|
||||
SELECT DISTINCT
|
||||
CAST(current_database() AS sql_identifier) AS view_catalog,
|
||||
CAST(nv.nspname AS sql_identifier) AS view_schema,
|
||||
CAST(v.relname AS sql_identifier) AS view_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(t.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_namespace nv, pg_class v, pg_depend dv,
|
||||
pg_depend dt, pg_class t, pg_namespace nt,
|
||||
pg_attribute a
|
||||
|
||||
WHERE nv.oid = v.relnamespace
|
||||
AND v.relkind = 'v'
|
||||
AND v.oid = dv.refobjid
|
||||
AND dv.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dv.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dv.deptype = 'i'
|
||||
AND dv.objid = dt.objid
|
||||
AND dv.refobjid <> dt.refobjid
|
||||
AND dt.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dt.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dt.refobjid = t.oid
|
||||
AND t.relnamespace = nt.oid
|
||||
AND t.relkind IN ('r', 'v', 'f')
|
||||
AND t.oid = a.attrelid
|
||||
AND dt.refobjsubid = a.attnum
|
||||
AND pg_has_role(t.relowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.view_table_usage AS
|
||||
SELECT DISTINCT
|
||||
CAST(current_database() AS sql_identifier) AS view_catalog,
|
||||
CAST(nv.nspname AS sql_identifier) AS view_schema,
|
||||
CAST(v.relname AS sql_identifier) AS view_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(t.relname AS sql_identifier) AS table_name
|
||||
|
||||
FROM pg_namespace nv, pg_class v, pg_depend dv,
|
||||
pg_depend dt, pg_class t, pg_namespace nt
|
||||
|
||||
WHERE nv.oid = v.relnamespace
|
||||
AND v.relkind = 'v'
|
||||
AND v.oid = dv.refobjid
|
||||
AND dv.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dv.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dv.deptype = 'i'
|
||||
AND dv.objid = dt.objid
|
||||
AND dv.refobjid <> dt.refobjid
|
||||
AND dt.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dt.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dt.refobjid = t.oid
|
||||
AND t.relnamespace = nt.oid
|
||||
AND t.relkind IN ('r', 'v', 'f')
|
||||
AND pg_has_role(t.relowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.data_type_privileges AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS object_catalog,
|
||||
CAST(x.objschema AS sql_identifier) AS object_schema,
|
||||
CAST(x.objname AS sql_identifier) AS object_name,
|
||||
CAST(x.objtype AS character_data) AS object_type,
|
||||
CAST(x.objdtdid AS sql_identifier) AS dtd_identifier
|
||||
|
||||
FROM
|
||||
(
|
||||
SELECT udt_schema, udt_name, 'USER-DEFINED TYPE'::text, dtd_identifier FROM attributes
|
||||
UNION ALL
|
||||
SELECT table_schema, table_name, 'TABLE'::text, dtd_identifier FROM columns
|
||||
UNION ALL
|
||||
SELECT domain_schema, domain_name, 'DOMAIN'::text, dtd_identifier FROM domains
|
||||
UNION ALL
|
||||
SELECT specific_schema, specific_name, 'ROUTINE'::text, dtd_identifier FROM parameters
|
||||
UNION ALL
|
||||
SELECT specific_schema, specific_name, 'ROUTINE'::text, dtd_identifier FROM routines
|
||||
) AS x (objschema, objname, objtype, objdtdid);
|
||||
|
||||
CREATE VIEW information_schema.role_column_grants AS
|
||||
SELECT grantor,
|
||||
grantee,
|
||||
table_catalog,
|
||||
table_schema,
|
||||
table_name,
|
||||
column_name,
|
||||
privilege_type,
|
||||
is_grantable
|
||||
FROM column_privileges
|
||||
WHERE grantor IN (SELECT role_name FROM enabled_roles)
|
||||
OR grantee IN (SELECT role_name FROM enabled_roles);
|
||||
|
||||
CREATE VIEW information_schema.role_table_grants AS
|
||||
SELECT grantor,
|
||||
grantee,
|
||||
table_catalog,
|
||||
table_schema,
|
||||
table_name,
|
||||
privilege_type,
|
||||
is_grantable,
|
||||
with_hierarchy
|
||||
FROM table_privileges
|
||||
WHERE grantor IN (SELECT role_name FROM enabled_roles)
|
||||
OR grantee IN (SELECT role_name FROM enabled_roles);
|
||||
|
||||
CREATE VIEW information_schema.element_types AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS object_catalog,
|
||||
CAST(n.nspname AS sql_identifier) AS object_schema,
|
||||
CAST(x.objname AS sql_identifier) AS object_name,
|
||||
CAST(x.objtype AS character_data) AS object_type,
|
||||
CAST(x.objdtdid AS sql_identifier) AS collection_type_identifier,
|
||||
CAST(
|
||||
CASE WHEN nbt.nspname = 'pg_catalog' THEN format_type(bt.oid, null)
|
||||
ELSE 'USER-DEFINED' END AS character_data) AS data_type,
|
||||
|
||||
CAST(null AS cardinal_number) AS character_maximum_length,
|
||||
CAST(null AS cardinal_number) AS character_octet_length,
|
||||
CAST(null AS sql_identifier) AS character_set_catalog,
|
||||
CAST(null AS sql_identifier) AS character_set_schema,
|
||||
CAST(null AS sql_identifier) AS character_set_name,
|
||||
CAST(CASE WHEN nco.nspname IS NOT NULL THEN current_database() END AS sql_identifier) AS collation_catalog,
|
||||
CAST(nco.nspname AS sql_identifier) AS collation_schema,
|
||||
CAST(co.collname AS sql_identifier) AS collation_name,
|
||||
CAST(null AS cardinal_number) AS numeric_precision,
|
||||
CAST(null AS cardinal_number) AS numeric_precision_radix,
|
||||
CAST(null AS cardinal_number) AS numeric_scale,
|
||||
CAST(null AS cardinal_number) AS datetime_precision,
|
||||
CAST(null AS character_data) AS interval_type,
|
||||
CAST(null AS cardinal_number) AS interval_precision,
|
||||
|
||||
CAST(null AS character_data) AS domain_default, -- XXX maybe a bug in the standard
|
||||
|
||||
CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(nbt.nspname AS sql_identifier) AS udt_schema,
|
||||
CAST(bt.typname AS sql_identifier) AS udt_name,
|
||||
|
||||
CAST(null AS sql_identifier) AS scope_catalog,
|
||||
CAST(null AS sql_identifier) AS scope_schema,
|
||||
CAST(null AS sql_identifier) AS scope_name,
|
||||
|
||||
CAST(null AS cardinal_number) AS maximum_cardinality,
|
||||
CAST('a' || CAST(x.objdtdid AS text) AS sql_identifier) AS dtd_identifier
|
||||
|
||||
FROM pg_namespace n, pg_type at, pg_namespace nbt, pg_type bt,
|
||||
(
|
||||
/* columns, attributes */
|
||||
SELECT c.relnamespace, CAST(c.relname AS sql_identifier),
|
||||
CASE WHEN c.relkind = 'c' THEN 'USER-DEFINED TYPE'::text ELSE 'TABLE'::text END,
|
||||
a.attnum, a.atttypid, a.attcollation
|
||||
FROM pg_class c, pg_attribute a
|
||||
WHERE c.oid = a.attrelid
|
||||
AND c.relkind IN ('r', 'v', 'f', 'c')
|
||||
AND attnum > 0 AND NOT attisdropped
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* domains */
|
||||
SELECT t.typnamespace, CAST(t.typname AS sql_identifier),
|
||||
'DOMAIN'::text, 1, t.typbasetype, t.typcollation
|
||||
FROM pg_type t
|
||||
WHERE t.typtype = 'd'
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* parameters */
|
||||
SELECT pronamespace, CAST(proname || '_' || CAST(oid AS text) AS sql_identifier),
|
||||
'ROUTINE'::text, (ss.x).n, (ss.x).x, 0
|
||||
FROM (SELECT p.pronamespace, p.proname, p.oid,
|
||||
_pg_expandarray(coalesce(p.proallargtypes, p.proargtypes::oid[])) AS x
|
||||
FROM pg_proc p) AS ss
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* result types */
|
||||
SELECT p.pronamespace, CAST(p.proname || '_' || CAST(p.oid AS text) AS sql_identifier),
|
||||
'ROUTINE'::text, 0, p.prorettype, 0
|
||||
FROM pg_proc p
|
||||
|
||||
) AS x (objschema, objname, objtype, objdtdid, objtypeid, objcollation)
|
||||
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
|
||||
ON x.objcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
|
||||
|
||||
WHERE n.oid = x.objschema
|
||||
AND at.oid = x.objtypeid
|
||||
AND (at.typelem <> 0 AND at.typlen = -1)
|
||||
AND at.typelem = bt.oid
|
||||
AND nbt.oid = bt.typnamespace
|
||||
|
||||
AND (n.nspname, x.objname, x.objtype, CAST(x.objdtdid AS sql_identifier)) IN
|
||||
( SELECT object_schema, object_name, object_type, dtd_identifier
|
||||
FROM data_type_privileges );
|
||||
|
||||
|
||||
GRANT SELECT ON information_schema.element_types TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.data_type_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.role_column_grants TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.role_table_grants TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_domain_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_udt_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.columns TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.table_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.tables TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.view_column_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.view_table_usage TO PUBLIC;
|
||||
|
||||
RESET search_path;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
-- --------------------------------------------------------------
|
||||
-- rollback pg_catalog.pg_collation
|
||||
-- --------------------------------------------------------------
|
||||
delete from pg_catalog.pg_collation where collname='zh_CN' and collnamespace=11 and collencoding=36 and collcollate='zh_CN.gb18030' and collctype='zh_CN.gb18030';
|
||||
delete from pg_catalog.pg_collation where collname='zh_CN.gb18030' and collnamespace=11 and collencoding=36 and collcollate='zh_CN.gb18030' and collctype='zh_CN.gb18030';
|
||||
|
|
@ -1,550 +1,4 @@
|
|||
SET search_path TO information_schema;
|
||||
|
||||
-- element_types is generated by data_type_privileges
|
||||
DROP VIEW IF EXISTS information_schema.element_types CASCADE;
|
||||
|
||||
-- data_type_privileges is generated by columns
|
||||
DROP VIEW IF EXISTS information_schema.data_type_privileges CASCADE;
|
||||
-- data_type_privileges is generated by table_privileges
|
||||
DROP VIEW IF EXISTS information_schema.role_column_grants CASCADE;
|
||||
-- data_type_privileges is generated by column_privileges
|
||||
DROP VIEW IF EXISTS information_schema.role_table_grants CASCADE;
|
||||
|
||||
-- other views need upgrade for matview
|
||||
DROP VIEW IF EXISTS information_schema.column_domain_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.column_privileges CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.column_udt_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.columns CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.table_privileges CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.tables CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.view_column_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.view_table_usage CASCADE;
|
||||
|
||||
CREATE VIEW information_schema.column_domain_usage AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS domain_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS domain_schema,
|
||||
CAST(t.typname AS sql_identifier) AS domain_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_type t, pg_namespace nt, pg_class c, pg_namespace nc,
|
||||
pg_attribute a
|
||||
|
||||
WHERE t.typnamespace = nt.oid
|
||||
AND c.relnamespace = nc.oid
|
||||
AND a.attrelid = c.oid
|
||||
AND a.atttypid = t.oid
|
||||
AND t.typtype = 'd'
|
||||
AND c.relkind IN ('r', 'v', 'f')
|
||||
AND a.attnum > 0
|
||||
AND NOT a.attisdropped
|
||||
AND pg_has_role(t.typowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.column_privileges AS
|
||||
SELECT CAST(u_grantor.rolname AS sql_identifier) AS grantor,
|
||||
CAST(grantee.rolname AS sql_identifier) AS grantee,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(x.relname AS sql_identifier) AS table_name,
|
||||
CAST(x.attname AS sql_identifier) AS column_name,
|
||||
CAST(x.prtype AS character_data) AS privilege_type,
|
||||
CAST(
|
||||
CASE WHEN
|
||||
-- object owner always has grant options
|
||||
pg_has_role(x.grantee, x.relowner, 'USAGE')
|
||||
OR x.grantable
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_grantable
|
||||
|
||||
FROM (
|
||||
SELECT pr_c.grantor,
|
||||
pr_c.grantee,
|
||||
attname,
|
||||
relname,
|
||||
relnamespace,
|
||||
pr_c.prtype,
|
||||
pr_c.grantable,
|
||||
pr_c.relowner
|
||||
FROM (SELECT oid, relname, relnamespace, relowner, (aclexplode(coalesce(relacl, acldefault('r', relowner)))).*
|
||||
FROM pg_class
|
||||
WHERE relkind IN ('r', 'v', 'f')
|
||||
) pr_c (oid, relname, relnamespace, relowner, grantor, grantee, prtype, grantable),
|
||||
pg_attribute a
|
||||
WHERE a.attrelid = pr_c.oid
|
||||
AND a.attnum > 0
|
||||
AND NOT a.attisdropped
|
||||
UNION
|
||||
SELECT pr_a.grantor,
|
||||
pr_a.grantee,
|
||||
attname,
|
||||
relname,
|
||||
relnamespace,
|
||||
pr_a.prtype,
|
||||
pr_a.grantable,
|
||||
c.relowner
|
||||
FROM (SELECT attrelid, attname, (aclexplode(coalesce(attacl, acldefault('c', relowner)))).*
|
||||
FROM pg_attribute a JOIN pg_class cc ON (a.attrelid = cc.oid)
|
||||
WHERE attnum > 0
|
||||
AND NOT attisdropped
|
||||
) pr_a (attrelid, attname, grantor, grantee, prtype, grantable),
|
||||
pg_class c
|
||||
WHERE pr_a.attrelid = c.oid
|
||||
AND relkind IN ('r', 'v', 'f')
|
||||
) x,
|
||||
pg_namespace nc,
|
||||
pg_authid u_grantor,
|
||||
(
|
||||
SELECT oid, rolname FROM pg_authid
|
||||
UNION ALL
|
||||
SELECT 0::oid, 'PUBLIC'
|
||||
) AS grantee (oid, rolname)
|
||||
|
||||
WHERE x.relnamespace = nc.oid
|
||||
AND x.grantee = grantee.oid
|
||||
AND x.grantor = u_grantor.oid
|
||||
AND x.prtype IN ('INSERT', 'SELECT', 'UPDATE', 'REFERENCES', 'COMMENT')
|
||||
AND (pg_has_role(u_grantor.oid, 'USAGE')
|
||||
OR pg_has_role(grantee.oid, 'USAGE')
|
||||
OR grantee.rolname = 'PUBLIC');
|
||||
|
||||
CREATE VIEW information_schema.column_udt_usage AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(coalesce(nbt.nspname, nt.nspname) AS sql_identifier) AS udt_schema,
|
||||
CAST(coalesce(bt.typname, t.typname) AS sql_identifier) AS udt_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_attribute a, pg_class c, pg_namespace nc,
|
||||
(pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid))
|
||||
LEFT JOIN (pg_type bt JOIN pg_namespace nbt ON (bt.typnamespace = nbt.oid))
|
||||
ON (t.typtype = 'd' AND t.typbasetype = bt.oid)
|
||||
|
||||
WHERE a.attrelid = c.oid
|
||||
AND a.atttypid = t.oid
|
||||
AND nc.oid = c.relnamespace
|
||||
AND a.attnum > 0 AND NOT a.attisdropped AND c.relkind in ('r', 'v', 'f')
|
||||
AND pg_has_role(coalesce(bt.typowner, t.typowner), 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.columns AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name,
|
||||
CAST(a.attnum AS cardinal_number) AS ordinal_position,
|
||||
CAST(pg_get_expr(ad.adbin, ad.adrelid) AS character_data) AS column_default,
|
||||
CAST(CASE WHEN a.attnotnull OR (t.typtype = 'd' AND t.typnotnull) THEN 'NO' ELSE 'YES' END
|
||||
AS yes_or_no)
|
||||
AS is_nullable,
|
||||
|
||||
CAST(
|
||||
CASE WHEN t.typtype = 'd' THEN
|
||||
CASE WHEN bt.typelem <> 0 AND bt.typlen = -1 THEN 'ARRAY'
|
||||
WHEN nbt.nspname = 'pg_catalog' THEN format_type(t.typbasetype, null)
|
||||
ELSE 'USER-DEFINED' END
|
||||
ELSE
|
||||
CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'ARRAY'
|
||||
WHEN nt.nspname = 'pg_catalog' THEN format_type(a.atttypid, null)
|
||||
ELSE 'USER-DEFINED' END
|
||||
END
|
||||
AS character_data)
|
||||
AS data_type,
|
||||
|
||||
CAST(
|
||||
_pg_char_max_length(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS character_maximum_length,
|
||||
|
||||
CAST(
|
||||
_pg_char_octet_length(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS character_octet_length,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_precision(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_precision,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_precision_radix(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_precision_radix,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_scale(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_scale,
|
||||
|
||||
CAST(
|
||||
_pg_datetime_precision(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS datetime_precision,
|
||||
|
||||
CAST(
|
||||
_pg_interval_type(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS character_data)
|
||||
AS interval_type,
|
||||
CAST(null AS cardinal_number) AS interval_precision,
|
||||
|
||||
CAST(null AS sql_identifier) AS character_set_catalog,
|
||||
CAST(null AS sql_identifier) AS character_set_schema,
|
||||
CAST(null AS sql_identifier) AS character_set_name,
|
||||
|
||||
CAST(CASE WHEN nco.nspname IS NOT NULL THEN current_database() END AS sql_identifier) AS collation_catalog,
|
||||
CAST(nco.nspname AS sql_identifier) AS collation_schema,
|
||||
CAST(co.collname AS sql_identifier) AS collation_name,
|
||||
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN current_database() ELSE null END
|
||||
AS sql_identifier) AS domain_catalog,
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN nt.nspname ELSE null END
|
||||
AS sql_identifier) AS domain_schema,
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN t.typname ELSE null END
|
||||
AS sql_identifier) AS domain_name,
|
||||
|
||||
CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(coalesce(nbt.nspname, nt.nspname) AS sql_identifier) AS udt_schema,
|
||||
CAST(coalesce(bt.typname, t.typname) AS sql_identifier) AS udt_name,
|
||||
|
||||
CAST(null AS sql_identifier) AS scope_catalog,
|
||||
CAST(null AS sql_identifier) AS scope_schema,
|
||||
CAST(null AS sql_identifier) AS scope_name,
|
||||
|
||||
CAST(null AS cardinal_number) AS maximum_cardinality,
|
||||
CAST(a.attnum AS sql_identifier) AS dtd_identifier,
|
||||
CAST('NO' AS yes_or_no) AS is_self_referencing,
|
||||
|
||||
CAST('NO' AS yes_or_no) AS is_identity,
|
||||
CAST(null AS character_data) AS identity_generation,
|
||||
CAST(null AS character_data) AS identity_start,
|
||||
CAST(null AS character_data) AS identity_increment,
|
||||
CAST(null AS character_data) AS identity_maximum,
|
||||
CAST(null AS character_data) AS identity_minimum,
|
||||
CAST(null AS yes_or_no) AS identity_cycle,
|
||||
|
||||
CAST('NEVER' AS character_data) AS is_generated,
|
||||
CAST(null AS character_data) AS generation_expression,
|
||||
|
||||
CAST(CASE WHEN c.relkind = 'r'
|
||||
OR (c.relkind = 'v'
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '2' AND is_instead)
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '4' AND is_instead))
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_updatable
|
||||
|
||||
FROM (pg_attribute a LEFT JOIN pg_attrdef ad ON attrelid = adrelid AND attnum = adnum)
|
||||
JOIN (pg_class c JOIN pg_namespace nc ON (c.relnamespace = nc.oid)) ON a.attrelid = c.oid
|
||||
JOIN (pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid)) ON a.atttypid = t.oid
|
||||
LEFT JOIN (pg_type bt JOIN pg_namespace nbt ON (bt.typnamespace = nbt.oid))
|
||||
ON (t.typtype = 'd' AND t.typbasetype = bt.oid)
|
||||
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
|
||||
ON a.attcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
|
||||
|
||||
WHERE (NOT pg_is_other_temp_schema(nc.oid))
|
||||
|
||||
AND a.attnum > 0 AND NOT a.attisdropped AND c.relkind in ('r', 'v', 'f')
|
||||
|
||||
AND (pg_has_role(c.relowner, 'USAGE')
|
||||
OR has_column_privilege(c.oid, a.attnum,
|
||||
'SELECT, INSERT, UPDATE, REFERENCES'));
|
||||
|
||||
CREATE VIEW information_schema.table_privileges AS
|
||||
SELECT CAST(u_grantor.rolname AS sql_identifier) AS grantor,
|
||||
CAST(grantee.rolname AS sql_identifier) AS grantee,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(c.prtype AS character_data) AS privilege_type,
|
||||
CAST(
|
||||
CASE WHEN
|
||||
-- object owner always has grant options
|
||||
pg_has_role(grantee.oid, c.relowner, 'USAGE')
|
||||
OR c.grantable
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_grantable,
|
||||
CAST(CASE WHEN c.prtype = 'SELECT' THEN 'YES' ELSE 'NO' END AS yes_or_no) AS with_hierarchy
|
||||
|
||||
FROM (
|
||||
SELECT oid, relname, relnamespace, relkind, relowner, (aclexplode(coalesce(relacl, acldefault('r', relowner)))).* FROM pg_class
|
||||
) AS c (oid, relname, relnamespace, relkind, relowner, grantor, grantee, prtype, grantable),
|
||||
pg_namespace nc,
|
||||
pg_authid u_grantor,
|
||||
(
|
||||
SELECT oid, rolname FROM pg_authid
|
||||
UNION ALL
|
||||
SELECT 0::oid, 'PUBLIC'
|
||||
) AS grantee (oid, rolname)
|
||||
|
||||
WHERE c.relnamespace = nc.oid
|
||||
AND c.relkind IN ('r', 'v')
|
||||
AND c.grantee = grantee.oid
|
||||
AND c.grantor = u_grantor.oid
|
||||
AND c.prtype IN ('INSERT', 'SELECT', 'UPDATE', 'DELETE', 'TRUNCATE', 'REFERENCES', 'TRIGGER' ,
|
||||
'ALTER', 'DROP', 'COMMENT', 'INDEX', 'VACUUM')
|
||||
AND (pg_has_role(u_grantor.oid, 'USAGE')
|
||||
OR pg_has_role(grantee.oid, 'USAGE')
|
||||
OR grantee.rolname = 'PUBLIC');
|
||||
|
||||
CREATE VIEW information_schema.tables AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
|
||||
CAST(
|
||||
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY'
|
||||
WHEN c.relkind = 'r' THEN 'BASE TABLE'
|
||||
WHEN c.relkind = 'v' THEN 'VIEW'
|
||||
WHEN c.relkind = 'f' THEN 'FOREIGN TABLE'
|
||||
ELSE null END
|
||||
AS character_data) AS table_type,
|
||||
|
||||
CAST(null AS sql_identifier) AS self_referencing_column_name,
|
||||
CAST(null AS character_data) AS reference_generation,
|
||||
|
||||
CAST(CASE WHEN t.typname IS NOT NULL THEN current_database() ELSE null END AS sql_identifier) AS user_defined_type_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS user_defined_type_schema,
|
||||
CAST(t.typname AS sql_identifier) AS user_defined_type_name,
|
||||
|
||||
CAST(CASE WHEN c.relkind = 'r'
|
||||
OR (c.relkind = 'v'
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '3' AND is_instead))
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_insertable_into,
|
||||
|
||||
CAST(CASE WHEN t.typname IS NOT NULL THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_typed,
|
||||
CAST(null AS character_data) AS commit_action
|
||||
|
||||
FROM pg_namespace nc JOIN pg_class c ON (nc.oid = c.relnamespace)
|
||||
LEFT JOIN (pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid)) ON (c.reloftype = t.oid)
|
||||
|
||||
WHERE c.relkind IN ('r', 'v', 'f')
|
||||
AND (NOT pg_is_other_temp_schema(nc.oid))
|
||||
AND (pg_has_role(c.relowner, 'USAGE')
|
||||
OR has_table_privilege(c.oid, 'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER')
|
||||
OR has_any_column_privilege(c.oid, 'SELECT, INSERT, UPDATE, REFERENCES') );
|
||||
|
||||
CREATE VIEW information_schema.view_column_usage AS
|
||||
SELECT DISTINCT
|
||||
CAST(current_database() AS sql_identifier) AS view_catalog,
|
||||
CAST(nv.nspname AS sql_identifier) AS view_schema,
|
||||
CAST(v.relname AS sql_identifier) AS view_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(t.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_namespace nv, pg_class v, pg_depend dv,
|
||||
pg_depend dt, pg_class t, pg_namespace nt,
|
||||
pg_attribute a
|
||||
|
||||
WHERE nv.oid = v.relnamespace
|
||||
AND v.relkind = 'v'
|
||||
AND v.oid = dv.refobjid
|
||||
AND dv.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dv.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dv.deptype = 'i'
|
||||
AND dv.objid = dt.objid
|
||||
AND dv.refobjid <> dt.refobjid
|
||||
AND dt.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dt.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dt.refobjid = t.oid
|
||||
AND t.relnamespace = nt.oid
|
||||
AND t.relkind IN ('r', 'v', 'f')
|
||||
AND t.oid = a.attrelid
|
||||
AND dt.refobjsubid = a.attnum
|
||||
AND pg_has_role(t.relowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.view_table_usage AS
|
||||
SELECT DISTINCT
|
||||
CAST(current_database() AS sql_identifier) AS view_catalog,
|
||||
CAST(nv.nspname AS sql_identifier) AS view_schema,
|
||||
CAST(v.relname AS sql_identifier) AS view_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(t.relname AS sql_identifier) AS table_name
|
||||
|
||||
FROM pg_namespace nv, pg_class v, pg_depend dv,
|
||||
pg_depend dt, pg_class t, pg_namespace nt
|
||||
|
||||
WHERE nv.oid = v.relnamespace
|
||||
AND v.relkind = 'v'
|
||||
AND v.oid = dv.refobjid
|
||||
AND dv.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dv.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dv.deptype = 'i'
|
||||
AND dv.objid = dt.objid
|
||||
AND dv.refobjid <> dt.refobjid
|
||||
AND dt.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dt.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dt.refobjid = t.oid
|
||||
AND t.relnamespace = nt.oid
|
||||
AND t.relkind IN ('r', 'v', 'f')
|
||||
AND pg_has_role(t.relowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.data_type_privileges AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS object_catalog,
|
||||
CAST(x.objschema AS sql_identifier) AS object_schema,
|
||||
CAST(x.objname AS sql_identifier) AS object_name,
|
||||
CAST(x.objtype AS character_data) AS object_type,
|
||||
CAST(x.objdtdid AS sql_identifier) AS dtd_identifier
|
||||
|
||||
FROM
|
||||
(
|
||||
SELECT udt_schema, udt_name, 'USER-DEFINED TYPE'::text, dtd_identifier FROM attributes
|
||||
UNION ALL
|
||||
SELECT table_schema, table_name, 'TABLE'::text, dtd_identifier FROM columns
|
||||
UNION ALL
|
||||
SELECT domain_schema, domain_name, 'DOMAIN'::text, dtd_identifier FROM domains
|
||||
UNION ALL
|
||||
SELECT specific_schema, specific_name, 'ROUTINE'::text, dtd_identifier FROM parameters
|
||||
UNION ALL
|
||||
SELECT specific_schema, specific_name, 'ROUTINE'::text, dtd_identifier FROM routines
|
||||
) AS x (objschema, objname, objtype, objdtdid);
|
||||
|
||||
CREATE VIEW information_schema.role_column_grants AS
|
||||
SELECT grantor,
|
||||
grantee,
|
||||
table_catalog,
|
||||
table_schema,
|
||||
table_name,
|
||||
column_name,
|
||||
privilege_type,
|
||||
is_grantable
|
||||
FROM column_privileges
|
||||
WHERE grantor IN (SELECT role_name FROM enabled_roles)
|
||||
OR grantee IN (SELECT role_name FROM enabled_roles);
|
||||
|
||||
CREATE VIEW information_schema.role_table_grants AS
|
||||
SELECT grantor,
|
||||
grantee,
|
||||
table_catalog,
|
||||
table_schema,
|
||||
table_name,
|
||||
privilege_type,
|
||||
is_grantable,
|
||||
with_hierarchy
|
||||
FROM table_privileges
|
||||
WHERE grantor IN (SELECT role_name FROM enabled_roles)
|
||||
OR grantee IN (SELECT role_name FROM enabled_roles);
|
||||
|
||||
CREATE VIEW information_schema.element_types AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS object_catalog,
|
||||
CAST(n.nspname AS sql_identifier) AS object_schema,
|
||||
CAST(x.objname AS sql_identifier) AS object_name,
|
||||
CAST(x.objtype AS character_data) AS object_type,
|
||||
CAST(x.objdtdid AS sql_identifier) AS collection_type_identifier,
|
||||
CAST(
|
||||
CASE WHEN nbt.nspname = 'pg_catalog' THEN format_type(bt.oid, null)
|
||||
ELSE 'USER-DEFINED' END AS character_data) AS data_type,
|
||||
|
||||
CAST(null AS cardinal_number) AS character_maximum_length,
|
||||
CAST(null AS cardinal_number) AS character_octet_length,
|
||||
CAST(null AS sql_identifier) AS character_set_catalog,
|
||||
CAST(null AS sql_identifier) AS character_set_schema,
|
||||
CAST(null AS sql_identifier) AS character_set_name,
|
||||
CAST(CASE WHEN nco.nspname IS NOT NULL THEN current_database() END AS sql_identifier) AS collation_catalog,
|
||||
CAST(nco.nspname AS sql_identifier) AS collation_schema,
|
||||
CAST(co.collname AS sql_identifier) AS collation_name,
|
||||
CAST(null AS cardinal_number) AS numeric_precision,
|
||||
CAST(null AS cardinal_number) AS numeric_precision_radix,
|
||||
CAST(null AS cardinal_number) AS numeric_scale,
|
||||
CAST(null AS cardinal_number) AS datetime_precision,
|
||||
CAST(null AS character_data) AS interval_type,
|
||||
CAST(null AS cardinal_number) AS interval_precision,
|
||||
|
||||
CAST(null AS character_data) AS domain_default, -- XXX maybe a bug in the standard
|
||||
|
||||
CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(nbt.nspname AS sql_identifier) AS udt_schema,
|
||||
CAST(bt.typname AS sql_identifier) AS udt_name,
|
||||
|
||||
CAST(null AS sql_identifier) AS scope_catalog,
|
||||
CAST(null AS sql_identifier) AS scope_schema,
|
||||
CAST(null AS sql_identifier) AS scope_name,
|
||||
|
||||
CAST(null AS cardinal_number) AS maximum_cardinality,
|
||||
CAST('a' || CAST(x.objdtdid AS text) AS sql_identifier) AS dtd_identifier
|
||||
|
||||
FROM pg_namespace n, pg_type at, pg_namespace nbt, pg_type bt,
|
||||
(
|
||||
/* columns, attributes */
|
||||
SELECT c.relnamespace, CAST(c.relname AS sql_identifier),
|
||||
CASE WHEN c.relkind = 'c' THEN 'USER-DEFINED TYPE'::text ELSE 'TABLE'::text END,
|
||||
a.attnum, a.atttypid, a.attcollation
|
||||
FROM pg_class c, pg_attribute a
|
||||
WHERE c.oid = a.attrelid
|
||||
AND c.relkind IN ('r', 'v', 'f', 'c')
|
||||
AND attnum > 0 AND NOT attisdropped
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* domains */
|
||||
SELECT t.typnamespace, CAST(t.typname AS sql_identifier),
|
||||
'DOMAIN'::text, 1, t.typbasetype, t.typcollation
|
||||
FROM pg_type t
|
||||
WHERE t.typtype = 'd'
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* parameters */
|
||||
SELECT pronamespace, CAST(proname || '_' || CAST(oid AS text) AS sql_identifier),
|
||||
'ROUTINE'::text, (ss.x).n, (ss.x).x, 0
|
||||
FROM (SELECT p.pronamespace, p.proname, p.oid,
|
||||
_pg_expandarray(coalesce(p.proallargtypes, p.proargtypes::oid[])) AS x
|
||||
FROM pg_proc p) AS ss
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* result types */
|
||||
SELECT p.pronamespace, CAST(p.proname || '_' || CAST(p.oid AS text) AS sql_identifier),
|
||||
'ROUTINE'::text, 0, p.prorettype, 0
|
||||
FROM pg_proc p
|
||||
|
||||
) AS x (objschema, objname, objtype, objdtdid, objtypeid, objcollation)
|
||||
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
|
||||
ON x.objcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
|
||||
|
||||
WHERE n.oid = x.objschema
|
||||
AND at.oid = x.objtypeid
|
||||
AND (at.typelem <> 0 AND at.typlen = -1)
|
||||
AND at.typelem = bt.oid
|
||||
AND nbt.oid = bt.typnamespace
|
||||
|
||||
AND (n.nspname, x.objname, x.objtype, CAST(x.objdtdid AS sql_identifier)) IN
|
||||
( SELECT object_schema, object_name, object_type, dtd_identifier
|
||||
FROM data_type_privileges );
|
||||
|
||||
|
||||
GRANT SELECT ON information_schema.element_types TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.data_type_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.role_column_grants TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.role_table_grants TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_domain_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_udt_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.columns TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.table_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.tables TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.view_column_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.view_table_usage TO PUBLIC;
|
||||
|
||||
RESET search_path;
|
||||
-- --------------------------------------------------------------
|
||||
-- rollback pg_catalog.pg_buffercache_pages
|
||||
-- --------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_buffercache_pages() CASCADE;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4130;
|
||||
CREATE OR REPLACE FUNCTION pg_catalog.pg_buffercache_pages
|
||||
(out bufferid pg_catalog.int4,
|
||||
out relfilenode pg_catalog.oid,
|
||||
out bucketid pg_catalog.int2,
|
||||
out storage_type pg_catalog.int2,
|
||||
out reltablespace pg_catalog.oid,
|
||||
out reldatabase pg_catalog.oid,
|
||||
out relforknumber pg_catalog.int2,
|
||||
out relblocknumber pg_catalog.int8,
|
||||
out isdirty pg_catalog.bool,
|
||||
out usage_count pg_catalog.int2)
|
||||
RETURNS SETOF record LANGUAGE INTERNAL STABLE STRICT as 'pg_buffercache_pages';CREATE OR REPLACE VIEW pg_catalog.pg_statio_all_sequences AS
|
||||
CREATE OR REPLACE VIEW pg_catalog.pg_statio_all_sequences AS
|
||||
SELECT
|
||||
C.oid AS relid,
|
||||
N.nspname AS schemaname,
|
||||
|
|
@ -824,21 +278,18 @@ SELECT pg_catalog.delete_pg_shdepend_temp(1059);
|
|||
|
||||
DROP FUNCTION pg_catalog.delete_pg_authid_temp();
|
||||
DROP FUNCTION pg_catalog.delete_pg_shdepend_temp();
|
||||
-- ----------------------------------------------------------------
|
||||
-- rollback pg_catalog.pg_collatio
|
||||
-- ----------------------------------------------------------------
|
||||
delete from pg_catalog.pg_collation where collname='zh_CN' and collnamespace=11 and collencoding=36 and collcollate='zh_CN.gb18030' and collctype='zh_CN.gb18030';
|
||||
delete from pg_catalog.pg_collation where collname='zh_CN.gb18030' and collnamespace=11 and collencoding=36 and collcollate='zh_CN.gb18030' and collctype='zh_CN.gb18030';-- deleting system table pg_publication
|
||||
|
||||
-- deleting system table pg_publication
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_pubname_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.pg_publication;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_publication;
|
||||
|
||||
-- deleting system table pg_publication_rel
|
||||
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_rel_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_rel_map_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.pg_publication_rel;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_publication_rel;DROP FUNCTION IF EXISTS pg_catalog.pg_read_binary_file_blocks(IN inputpath text, IN startblocknum int8, IN count int8) CASCADE;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_publication_rel;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_read_binary_file_blocks(IN inputpath text, IN startblocknum int8, IN count int8) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_read_block_from_remote(int4, int4, int4, int2, int2, int4, xid, int4, xid, boolean) CASCADE;
|
||||
|
|
|
|||
|
|
@ -108,19 +108,8 @@ BEGIN
|
|||
end if;
|
||||
end if;
|
||||
END$$;
|
||||
-- deleting system table pg_publication
|
||||
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_pubname_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.pg_publication;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_publication;
|
||||
|
||||
-- deleting system table pg_publication_rel
|
||||
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_rel_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_rel_map_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.pg_publication_rel;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_publication_rel;do $$DECLARE
|
||||
do $$DECLARE
|
||||
ans boolean;
|
||||
func boolean;
|
||||
user_name text;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,276 @@
|
|||
--------------------------------------------------------------
|
||||
-- delete pg_amop
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_amop_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_amop where amopfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_amop_temp();
|
||||
DROP FUNCTION Delete_pg_amop_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_amproc
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_amproc_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_amproc where amprocfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_amproc_temp();
|
||||
DROP FUNCTION Delete_pg_amproc_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_opclass
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_opclass_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_opclass where opcfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_opclass_temp();
|
||||
DROP FUNCTION Delete_pg_opclass_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_cast
|
||||
--------------------------------------------------------------
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP CAST IF EXISTS (json AS jsonb) CASCADE;
|
||||
DROP CAST IF EXISTS (jsonb AS json) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_opfamily
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_opfamily_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_opfamily where oid in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_opfamily_temp();
|
||||
DROP FUNCTION Delete_pg_opfamily_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_operator
|
||||
--------------------------------------------------------------
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(json, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(json, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(json, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(json, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>(json, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>>(json, _text) cascade;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(jsonb, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(jsonb, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>>(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.>=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.@>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?|(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?&(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<@(jsonb, jsonb) cascade;
|
||||
end if;
|
||||
END$$;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete builtin funcs
|
||||
--------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_compare_jsonb(text, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_consistent_jsonb(internal, smallint, anyarray, integer, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_consistent_jsonb_hash(internal, smallint, anyarray, integer, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb(internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_hash(internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_query(anyarray, internal, smallint, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_query_hash(anyarray, internal, smallint, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_triconsistent_jsonb(internal, smallint, anyarray, integer, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_triconsistent_jsonb_hash(internal, smallint, anyarray, integer, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_element(json, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_element_text(json, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_elements(from_json json, OUT value json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_elements_text(from_json json, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_length(json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_array() CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_array(VARIADIC "any") CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_object() CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_object(VARIADIC "any") CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_each(from_json json, OUT key text, OUT value json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_each_text(from_json json, OUT key text, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path(json, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_op(json, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_text(json, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_text_op(json, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object(text[], text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object(text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_field(json, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_field_text(json, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_keys(json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_populate_record(anyelement, json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_populate_recordset(anyelement, json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_to_record(json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_to_recordset(json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_json(anyelement) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_typeof(json) CASCADE;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_element(jsonb, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_element_text(jsonb, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_elements(from_json jsonb, OUT value jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_elements_text(from_json jsonb, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_length(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_cmp(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_contained(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_contains(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_each(from_json jsonb, OUT key text, OUT value jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_each_text(from_json jsonb, OUT key text, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_eq(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists_all(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists_any(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path(jsonb, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_op(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_text(jsonb, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_text_op(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_ge(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_gt(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_hash(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_le(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_lt(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_ne(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_field(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_field_text(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_keys(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_populate_record(anyelement, jsonb, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_populate_recordset(anyelement, jsonb, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_typeof(jsonb) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
----------------------------------------------------------------
|
||||
-- recover funcs
|
||||
----------------------------------------------------------------
|
||||
ALTER FUNCTION json_in(cstring) STABLE;
|
||||
ALTER FUNCTION json_send(json) STABLE;
|
||||
ALTER FUNCTION json_recv(internal) STABLE;
|
||||
|
||||
----------------------------------------------------------------
|
||||
-- delete two agg funcs
|
||||
----------------------------------------------------------------
|
||||
drop aggregate if exists pg_catalog.json_object_agg("any", "any");
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_agg_finalfn(internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_agg_transfn(internal, "any", "any") CASCADE;
|
||||
|
||||
drop aggregate if exists pg_catalog.json_agg(anyelement);
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_agg_finalfn(internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_agg_transfn(internal, anyelement) CASCADE;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete type jsonb
|
||||
--------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_in(cstring) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_recv(internal) CASCADE;
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_out(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_send(jsonb) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
DROP TYPE IF EXISTS pg_catalog._jsonb;
|
||||
DROP TYPE IF EXISTS pg_catalog.jsonb;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_decrypt(IN decryptstr text, IN keystr text, IN type text,OUT decrypt_result_str text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_encrypt(IN encryptstr text, IN keystr text, IN type text,OUT encrypt_result_str text) CASCADE;DROP FUNCTION IF EXISTS pg_catalog.gs_decrypt(IN decryptstr text, IN keystr text, IN type text,OUT decrypt_result_str text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_encrypt(IN encryptstr text, IN keystr text, IN type text,OUT encrypt_result_str text) CASCADE;DROP FUNCTION IF EXISTS pg_catalog.gs_decrypt(IN decryptstr text, IN keystr text, IN type text,OUT decrypt_result_str text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_encrypt(IN encryptstr text, IN keystr text, IN type text,OUT encrypt_result_str text) CASCADE;UPDATE pg_catalog.pg_am set amcanunique = FALSE where amname = 'cbtree';
|
||||
CREATE OR REPLACE VIEW pg_catalog.gs_session_cpu_statistics AS
|
||||
SELECT
|
||||
S.datid AS datid,
|
||||
S.usename,
|
||||
S.pid,
|
||||
S.query_start AS start_time,
|
||||
T.min_cpu_time,
|
||||
T.max_cpu_time,
|
||||
T.total_cpu_time,
|
||||
S.query,
|
||||
S.node_group,
|
||||
T.top_cpu_dn
|
||||
FROM pg_stat_activity_ng AS S, pg_stat_get_wlm_realtime_session_info(NULL) AS T
|
||||
WHERE S.pid = T.threadid;
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
REVOKE SELECT ON pg_catalog.pg_total_user_resource_info_oid FROM public;
|
||||
REVOKE SELECT ON pg_catalog.pg_total_user_resource_info FROM public;-- ----------------------------------------------------------------
|
||||
REVOKE SELECT ON pg_catalog.pg_total_user_resource_info FROM public;
|
||||
-- ----------------------------------------------------------------
|
||||
-- rollback gs_paxos_stat_replication
|
||||
-- ----------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_paxos_stat_replication(OUT local_role text, OUT peer_role text, OUT local_dcf_role text, OUT peer_dcf_role text, OUT peer_state text, OUT sender_write_location text, OUT sender_commit_location text, OUT sender_flush_location text, OUT sender_replay_location text, OUT receiver_write_location text, OUT receiver_commit_location text, OUT receiver_flush_location text, OUT receiver_replay_location text, OUT sync_percent text, OUT dcf_run_mode int4, OUT channel text) CASCADE;
|
||||
|
|
@ -171,265 +172,8 @@ DROP FUNCTION IF EXISTS pg_catalog.array_extendnull(anyarray, integer) CASCADE;
|
|||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_streaming_dr_in_switchover() cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_streaming_dr_get_switchover_barrier() cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_streaming_dr_service_truncation_check() cascade;DROP FUNCTION IF EXISTS pg_catalog.gs_decrypt(IN decryptstr text, IN keystr text, IN type text,OUT decrypt_result_str text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_encrypt(IN encryptstr text, IN keystr text, IN type text,OUT encrypt_result_str text) CASCADE;UPDATE pg_catalog.pg_am set amcanunique = FALSE where amname = 'cbtree';
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_amop
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_amop_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_amop where amopfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_streaming_dr_service_truncation_check() cascade;
|
||||
|
||||
SELECT Delete_pg_amop_temp();
|
||||
DROP FUNCTION Delete_pg_amop_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_amproc
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_amproc_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_amproc where amprocfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_amproc_temp();
|
||||
DROP FUNCTION Delete_pg_amproc_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_opclass
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_opclass_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_opclass where opcfamily in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_opclass_temp();
|
||||
DROP FUNCTION Delete_pg_opclass_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_cast
|
||||
--------------------------------------------------------------
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP CAST IF EXISTS (json AS jsonb) CASCADE;
|
||||
DROP CAST IF EXISTS (jsonb AS json) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_opfamily
|
||||
--------------------------------------------------------------
|
||||
CREATE OR REPLACE FUNCTION Delete_pg_opfamily_temp()
|
||||
RETURNS void
|
||||
AS $$
|
||||
DECLARE
|
||||
row_name record;
|
||||
query_str text;
|
||||
query_str_nodes text;
|
||||
BEGIN
|
||||
query_str_nodes := 'select * from dbe_perf.node_name';
|
||||
FOR row_name IN EXECUTE(query_str_nodes) LOOP
|
||||
delete from pg_catalog.pg_opfamily where oid in (4033, 4034, 4035, 4036, 4037);
|
||||
END LOOP;
|
||||
return;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
SELECT Delete_pg_opfamily_temp();
|
||||
DROP FUNCTION Delete_pg_opfamily_temp();
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete pg_operator
|
||||
--------------------------------------------------------------
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(json, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(json, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(json, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(json, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>(json, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>>(json, _text) cascade;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->(jsonb, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.->>(jsonb, integer) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.#>>(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.>=(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.@>(jsonb, jsonb) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?(jsonb, text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?|(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.?&(jsonb, _text) cascade;
|
||||
DROP OPERATOR IF EXISTS pg_catalog.<@(jsonb, jsonb) cascade;
|
||||
end if;
|
||||
END$$;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete builtin funcs
|
||||
--------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_compare_jsonb(text, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_consistent_jsonb(internal, smallint, anyarray, integer, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_consistent_jsonb_hash(internal, smallint, anyarray, integer, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb(internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_hash(internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_query(anyarray, internal, smallint, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_extract_jsonb_query_hash(anyarray, internal, smallint, internal, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_triconsistent_jsonb(internal, smallint, anyarray, integer, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gin_triconsistent_jsonb_hash(internal, smallint, anyarray, integer, internal, internal, internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_element(json, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_element_text(json, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_elements(from_json json, OUT value json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_elements_text(from_json json, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_array_length(json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_array() CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_array(VARIADIC "any") CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_object() CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_build_object(VARIADIC "any") CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_each(from_json json, OUT key text, OUT value json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_each_text(from_json json, OUT key text, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path(json, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_op(json, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_text(json, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_extract_path_text_op(json, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object(text[], text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object(text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_field(json, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_field_text(json, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_keys(json) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_populate_record(anyelement, json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_populate_recordset(anyelement, json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_to_record(json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_to_recordset(json, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.to_json(anyelement) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_typeof(json) CASCADE;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_element(jsonb, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_element_text(jsonb, integer) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_elements(from_json jsonb, OUT value jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_elements_text(from_json jsonb, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_array_length(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_cmp(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_contained(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_contains(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_each(from_json jsonb, OUT key text, OUT value jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_each_text(from_json jsonb, OUT key text, OUT value text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_eq(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists_all(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_exists_any(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path(jsonb, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_op(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_text(jsonb, VARIADIC text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_extract_path_text_op(jsonb, text[]) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_ge(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_gt(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_hash(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_le(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_lt(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_ne(jsonb, jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_field(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_field_text(jsonb, text) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_object_keys(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_populate_record(anyelement, jsonb, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_populate_recordset(anyelement, jsonb, boolean) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_typeof(jsonb) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
----------------------------------------------------------------
|
||||
-- recover funcs
|
||||
----------------------------------------------------------------
|
||||
ALTER FUNCTION json_in(cstring) STABLE;
|
||||
ALTER FUNCTION json_send(json) STABLE;
|
||||
ALTER FUNCTION json_recv(internal) STABLE;
|
||||
|
||||
----------------------------------------------------------------
|
||||
-- delete two agg funcs
|
||||
----------------------------------------------------------------
|
||||
drop aggregate if exists pg_catalog.json_object_agg("any", "any");
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_agg_finalfn(internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_object_agg_transfn(internal, "any", "any") CASCADE;
|
||||
|
||||
drop aggregate if exists pg_catalog.json_agg(anyelement);
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_agg_finalfn(internal) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.json_agg_transfn(internal, anyelement) CASCADE;
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- delete type jsonb
|
||||
--------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_in(cstring) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_recv(internal) CASCADE;
|
||||
DO $$
|
||||
DECLARE
|
||||
ans boolean;
|
||||
BEGIN
|
||||
select case when count(*)=1 then true else false end as ans from (select * from pg_type where typname = 'jsonb' limit 1) into ans;
|
||||
if ans = true then
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_out(jsonb) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.jsonb_send(jsonb) CASCADE;
|
||||
end if;
|
||||
END$$;
|
||||
|
||||
DROP TYPE IF EXISTS pg_catalog.jsonb;
|
||||
do $$DECLARE ans boolean;
|
||||
BEGIN
|
||||
for ans in select case when count(*)=1 then true else false end as ans from (select nspname from pg_namespace where nspname='dbe_pldebugger' limit 1)
|
||||
|
|
@ -696,20 +440,6 @@ SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0,
|
|||
-- ----------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_trim(anyarray, integer) CASCADE;
|
||||
|
||||
CREATE OR REPLACE VIEW pg_catalog.gs_session_cpu_statistics AS
|
||||
SELECT
|
||||
S.datid AS datid,
|
||||
S.usename,
|
||||
S.pid,
|
||||
S.query_start AS start_time,
|
||||
T.min_cpu_time,
|
||||
T.max_cpu_time,
|
||||
T.total_cpu_time,
|
||||
S.query,
|
||||
S.node_group,
|
||||
T.top_cpu_dn
|
||||
FROM pg_stat_activity_ng AS S, pg_stat_get_wlm_realtime_session_info(NULL) AS T
|
||||
WHERE S.pid = T.threadid;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.copy_summary_create() CASCADE;
|
||||
do $$DECLARE
|
||||
ans boolean;
|
||||
|
|
|
|||
|
|
@ -1992,66 +1992,8 @@ DROP FUNCTION IF EXISTS pg_catalog.gs_read_file_from_remote(oid, oid, oid, integ
|
|||
DROP FUNCTION IF EXISTS pg_catalog.gs_read_file_size_from_remote(oid, oid, oid, integer, integer, xid, integer) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_read_segment_block_from_remote(integer, integer, integer, smallint, integer, xid, integer, xid, integer, integer) CASCADE;
|
||||
-- deleting system view
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_publication_tables;
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_stat_subscription;
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_replication_origin_status;
|
||||
|
||||
-- deleting function pg_replication_origin_create
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_create(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_drop
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_drop(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_oid
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_oid(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_session_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_setup(IN node_name text) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_session_reset
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_reset() CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_session_is_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_is_setup() CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_session_progress
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_progress(IN flush boolean) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_xact_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_xact_setup(IN origin_lsn text, IN origin_timestamp timestamp with time zone) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_xact_reset
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_xact_reset() CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_advance
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_advance(IN node_name text, IN lsn text) CASCADE;
|
||||
|
||||
-- deleting function pg_replication_origin_progress
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_progress(IN node_name text, IN flush boolean) CASCADE;
|
||||
|
||||
-- deleting function pg_show_replication_origin_status
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_show_replication_origin_status(OUT local_id oid, OUT external_id text, OUT remote_lsn text, OUT local_lsn text) CASCADE;
|
||||
|
||||
-- deleting function pg_get_publication_tables
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_get_publication_tables(IN pubname text, OUT relid oid) CASCADE;
|
||||
|
||||
-- deleting function pg_stat_get_subscription
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_stat_get_subscription(IN subid oid, OUT subid oid, OUT pid integer, OUT received_lsn text, OUT last_msg_send_time timestamp with time zone, OUT last_msg_receipt_time timestamp with time zone, OUT latest_end_lsn text, OUT latest_end_time timestamp with time zone) CASCADE;
|
||||
|
||||
-- deleting system table pg_subscription
|
||||
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_subscription_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_subscription_subname_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.pg_subscription;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_subscription;
|
||||
|
||||
-- deleting system table pg_replication_origin
|
||||
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_replication_origin_roident_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_replication_origin_roname_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.pg_replication_origin;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_replication_origin;DROP FUNCTION IF EXISTS pg_catalog.gs_explain_model(text) cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_explain_model(text) cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_float8_array(text, VARIADIC "any") cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_bool(text, VARIADIC "any") cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_float4(text, VARIADIC "any") cascade;
|
||||
|
|
@ -2321,18 +2263,6 @@ CREATE OR REPLACE FUNCTION pg_catalog.gs_read_block_from_remote(integer, integer
|
|||
STRICT NOT FENCED NOT SHIPPABLE
|
||||
AS $function$gs_read_block_from_remote$function$;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_remove(anyarray, anyelement) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_replace(anyarray, anyelement, anyelement) CASCADE;
|
||||
DROP AGGREGATE IF EXISTS pg_catalog.last(anyelement) CASCADE;
|
||||
DROP AGGREGATE IF EXISTS pg_catalog.first(anyelement) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.last_transition(anyelement, anyelement) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.first_transition(anyelement, anyelement) CASCADE;
|
||||
|
||||
|
||||
DROP AGGREGATE IF EXISTS pg_catalog.max(inet) CASCADE;
|
||||
DROP AGGREGATE IF EXISTS pg_catalog.min(inet) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.network_larger(inet, inet) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.network_smaller(inet, inet) CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_buffercache_pages() CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4130;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,529 @@
|
|||
SET search_path TO information_schema;
|
||||
|
||||
-- element_types is generated by data_type_privileges
|
||||
DROP VIEW IF EXISTS information_schema.element_types CASCADE;
|
||||
|
||||
-- data_type_privileges is generated by columns
|
||||
DROP VIEW IF EXISTS information_schema.data_type_privileges CASCADE;
|
||||
-- data_type_privileges is generated by table_privileges
|
||||
DROP VIEW IF EXISTS information_schema.role_column_grants CASCADE;
|
||||
-- data_type_privileges is generated by column_privileges
|
||||
DROP VIEW IF EXISTS information_schema.role_table_grants CASCADE;
|
||||
|
||||
-- other views need upgrade for matview
|
||||
DROP VIEW IF EXISTS information_schema.column_domain_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.column_privileges CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.column_udt_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.columns CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.table_privileges CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.tables CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.view_column_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.view_table_usage CASCADE;
|
||||
|
||||
CREATE VIEW information_schema.column_domain_usage AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS domain_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS domain_schema,
|
||||
CAST(t.typname AS sql_identifier) AS domain_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_type t, pg_namespace nt, pg_class c, pg_namespace nc,
|
||||
pg_attribute a
|
||||
|
||||
WHERE t.typnamespace = nt.oid
|
||||
AND c.relnamespace = nc.oid
|
||||
AND a.attrelid = c.oid
|
||||
AND a.atttypid = t.oid
|
||||
AND t.typtype = 'd'
|
||||
AND c.relkind IN ('r', 'v', 'f')
|
||||
AND a.attnum > 0
|
||||
AND NOT a.attisdropped
|
||||
AND pg_has_role(t.typowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.column_privileges AS
|
||||
SELECT CAST(u_grantor.rolname AS sql_identifier) AS grantor,
|
||||
CAST(grantee.rolname AS sql_identifier) AS grantee,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(x.relname AS sql_identifier) AS table_name,
|
||||
CAST(x.attname AS sql_identifier) AS column_name,
|
||||
CAST(x.prtype AS character_data) AS privilege_type,
|
||||
CAST(
|
||||
CASE WHEN
|
||||
-- object owner always has grant options
|
||||
pg_has_role(x.grantee, x.relowner, 'USAGE')
|
||||
OR x.grantable
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_grantable
|
||||
|
||||
FROM (
|
||||
SELECT pr_c.grantor,
|
||||
pr_c.grantee,
|
||||
attname,
|
||||
relname,
|
||||
relnamespace,
|
||||
pr_c.prtype,
|
||||
pr_c.grantable,
|
||||
pr_c.relowner
|
||||
FROM (SELECT oid, relname, relnamespace, relowner, (aclexplode(coalesce(relacl, acldefault('r', relowner)))).*
|
||||
FROM pg_class
|
||||
WHERE relkind IN ('r', 'v', 'f')
|
||||
) pr_c (oid, relname, relnamespace, relowner, grantor, grantee, prtype, grantable),
|
||||
pg_attribute a
|
||||
WHERE a.attrelid = pr_c.oid
|
||||
AND a.attnum > 0
|
||||
AND NOT a.attisdropped
|
||||
UNION
|
||||
SELECT pr_a.grantor,
|
||||
pr_a.grantee,
|
||||
attname,
|
||||
relname,
|
||||
relnamespace,
|
||||
pr_a.prtype,
|
||||
pr_a.grantable,
|
||||
c.relowner
|
||||
FROM (SELECT attrelid, attname, (aclexplode(coalesce(attacl, acldefault('c', relowner)))).*
|
||||
FROM pg_attribute a JOIN pg_class cc ON (a.attrelid = cc.oid)
|
||||
WHERE attnum > 0
|
||||
AND NOT attisdropped
|
||||
) pr_a (attrelid, attname, grantor, grantee, prtype, grantable),
|
||||
pg_class c
|
||||
WHERE pr_a.attrelid = c.oid
|
||||
AND relkind IN ('r', 'v', 'f')
|
||||
) x,
|
||||
pg_namespace nc,
|
||||
pg_authid u_grantor,
|
||||
(
|
||||
SELECT oid, rolname FROM pg_authid
|
||||
UNION ALL
|
||||
SELECT 0::oid, 'PUBLIC'
|
||||
) AS grantee (oid, rolname)
|
||||
|
||||
WHERE x.relnamespace = nc.oid
|
||||
AND x.grantee = grantee.oid
|
||||
AND x.grantor = u_grantor.oid
|
||||
AND x.prtype IN ('INSERT', 'SELECT', 'UPDATE', 'REFERENCES', 'COMMENT')
|
||||
AND (pg_has_role(u_grantor.oid, 'USAGE')
|
||||
OR pg_has_role(grantee.oid, 'USAGE')
|
||||
OR grantee.rolname = 'PUBLIC');
|
||||
|
||||
CREATE VIEW information_schema.column_udt_usage AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(coalesce(nbt.nspname, nt.nspname) AS sql_identifier) AS udt_schema,
|
||||
CAST(coalesce(bt.typname, t.typname) AS sql_identifier) AS udt_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_attribute a, pg_class c, pg_namespace nc,
|
||||
(pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid))
|
||||
LEFT JOIN (pg_type bt JOIN pg_namespace nbt ON (bt.typnamespace = nbt.oid))
|
||||
ON (t.typtype = 'd' AND t.typbasetype = bt.oid)
|
||||
|
||||
WHERE a.attrelid = c.oid
|
||||
AND a.atttypid = t.oid
|
||||
AND nc.oid = c.relnamespace
|
||||
AND a.attnum > 0 AND NOT a.attisdropped AND c.relkind in ('r', 'v', 'f')
|
||||
AND pg_has_role(coalesce(bt.typowner, t.typowner), 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.columns AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name,
|
||||
CAST(a.attnum AS cardinal_number) AS ordinal_position,
|
||||
CAST(pg_get_expr(ad.adbin, ad.adrelid) AS character_data) AS column_default,
|
||||
CAST(CASE WHEN a.attnotnull OR (t.typtype = 'd' AND t.typnotnull) THEN 'NO' ELSE 'YES' END
|
||||
AS yes_or_no)
|
||||
AS is_nullable,
|
||||
|
||||
CAST(
|
||||
CASE WHEN t.typtype = 'd' THEN
|
||||
CASE WHEN bt.typelem <> 0 AND bt.typlen = -1 THEN 'ARRAY'
|
||||
WHEN nbt.nspname = 'pg_catalog' THEN format_type(t.typbasetype, null)
|
||||
ELSE 'USER-DEFINED' END
|
||||
ELSE
|
||||
CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'ARRAY'
|
||||
WHEN nt.nspname = 'pg_catalog' THEN format_type(a.atttypid, null)
|
||||
ELSE 'USER-DEFINED' END
|
||||
END
|
||||
AS character_data)
|
||||
AS data_type,
|
||||
|
||||
CAST(
|
||||
_pg_char_max_length(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS character_maximum_length,
|
||||
|
||||
CAST(
|
||||
_pg_char_octet_length(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS character_octet_length,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_precision(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_precision,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_precision_radix(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_precision_radix,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_scale(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_scale,
|
||||
|
||||
CAST(
|
||||
_pg_datetime_precision(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS datetime_precision,
|
||||
|
||||
CAST(
|
||||
_pg_interval_type(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS character_data)
|
||||
AS interval_type,
|
||||
CAST(null AS cardinal_number) AS interval_precision,
|
||||
|
||||
CAST(null AS sql_identifier) AS character_set_catalog,
|
||||
CAST(null AS sql_identifier) AS character_set_schema,
|
||||
CAST(null AS sql_identifier) AS character_set_name,
|
||||
|
||||
CAST(CASE WHEN nco.nspname IS NOT NULL THEN current_database() END AS sql_identifier) AS collation_catalog,
|
||||
CAST(nco.nspname AS sql_identifier) AS collation_schema,
|
||||
CAST(co.collname AS sql_identifier) AS collation_name,
|
||||
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN current_database() ELSE null END
|
||||
AS sql_identifier) AS domain_catalog,
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN nt.nspname ELSE null END
|
||||
AS sql_identifier) AS domain_schema,
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN t.typname ELSE null END
|
||||
AS sql_identifier) AS domain_name,
|
||||
|
||||
CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(coalesce(nbt.nspname, nt.nspname) AS sql_identifier) AS udt_schema,
|
||||
CAST(coalesce(bt.typname, t.typname) AS sql_identifier) AS udt_name,
|
||||
|
||||
CAST(null AS sql_identifier) AS scope_catalog,
|
||||
CAST(null AS sql_identifier) AS scope_schema,
|
||||
CAST(null AS sql_identifier) AS scope_name,
|
||||
|
||||
CAST(null AS cardinal_number) AS maximum_cardinality,
|
||||
CAST(a.attnum AS sql_identifier) AS dtd_identifier,
|
||||
CAST('NO' AS yes_or_no) AS is_self_referencing,
|
||||
|
||||
CAST('NO' AS yes_or_no) AS is_identity,
|
||||
CAST(null AS character_data) AS identity_generation,
|
||||
CAST(null AS character_data) AS identity_start,
|
||||
CAST(null AS character_data) AS identity_increment,
|
||||
CAST(null AS character_data) AS identity_maximum,
|
||||
CAST(null AS character_data) AS identity_minimum,
|
||||
CAST(null AS yes_or_no) AS identity_cycle,
|
||||
|
||||
CAST('NEVER' AS character_data) AS is_generated,
|
||||
CAST(null AS character_data) AS generation_expression,
|
||||
|
||||
CAST(CASE WHEN c.relkind = 'r'
|
||||
OR (c.relkind = 'v'
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '2' AND is_instead)
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '4' AND is_instead))
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_updatable
|
||||
|
||||
FROM (pg_attribute a LEFT JOIN pg_attrdef ad ON attrelid = adrelid AND attnum = adnum)
|
||||
JOIN (pg_class c JOIN pg_namespace nc ON (c.relnamespace = nc.oid)) ON a.attrelid = c.oid
|
||||
JOIN (pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid)) ON a.atttypid = t.oid
|
||||
LEFT JOIN (pg_type bt JOIN pg_namespace nbt ON (bt.typnamespace = nbt.oid))
|
||||
ON (t.typtype = 'd' AND t.typbasetype = bt.oid)
|
||||
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
|
||||
ON a.attcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
|
||||
|
||||
WHERE (NOT pg_is_other_temp_schema(nc.oid))
|
||||
|
||||
AND a.attnum > 0 AND NOT a.attisdropped AND c.relkind in ('r', 'v', 'f')
|
||||
|
||||
AND (pg_has_role(c.relowner, 'USAGE')
|
||||
OR has_column_privilege(c.oid, a.attnum,
|
||||
'SELECT, INSERT, UPDATE, REFERENCES'));
|
||||
|
||||
CREATE VIEW information_schema.table_privileges AS
|
||||
SELECT CAST(u_grantor.rolname AS sql_identifier) AS grantor,
|
||||
CAST(grantee.rolname AS sql_identifier) AS grantee,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(c.prtype AS character_data) AS privilege_type,
|
||||
CAST(
|
||||
CASE WHEN
|
||||
-- object owner always has grant options
|
||||
pg_has_role(grantee.oid, c.relowner, 'USAGE')
|
||||
OR c.grantable
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_grantable,
|
||||
CAST(CASE WHEN c.prtype = 'SELECT' THEN 'YES' ELSE 'NO' END AS yes_or_no) AS with_hierarchy
|
||||
|
||||
FROM (
|
||||
SELECT oid, relname, relnamespace, relkind, relowner, (aclexplode(coalesce(relacl, acldefault('r', relowner)))).* FROM pg_class
|
||||
) AS c (oid, relname, relnamespace, relkind, relowner, grantor, grantee, prtype, grantable),
|
||||
pg_namespace nc,
|
||||
pg_authid u_grantor,
|
||||
(
|
||||
SELECT oid, rolname FROM pg_authid
|
||||
UNION ALL
|
||||
SELECT 0::oid, 'PUBLIC'
|
||||
) AS grantee (oid, rolname)
|
||||
|
||||
WHERE c.relnamespace = nc.oid
|
||||
AND c.relkind IN ('r', 'v')
|
||||
AND c.grantee = grantee.oid
|
||||
AND c.grantor = u_grantor.oid
|
||||
AND c.prtype IN ('INSERT', 'SELECT', 'UPDATE', 'DELETE', 'TRUNCATE', 'REFERENCES', 'TRIGGER' ,
|
||||
'ALTER', 'DROP', 'COMMENT', 'INDEX', 'VACUUM')
|
||||
AND (pg_has_role(u_grantor.oid, 'USAGE')
|
||||
OR pg_has_role(grantee.oid, 'USAGE')
|
||||
OR grantee.rolname = 'PUBLIC');
|
||||
|
||||
CREATE VIEW information_schema.tables AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
|
||||
CAST(
|
||||
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY'
|
||||
WHEN c.relkind = 'r' THEN 'BASE TABLE'
|
||||
WHEN c.relkind = 'v' THEN 'VIEW'
|
||||
WHEN c.relkind = 'f' THEN 'FOREIGN TABLE'
|
||||
ELSE null END
|
||||
AS character_data) AS table_type,
|
||||
|
||||
CAST(null AS sql_identifier) AS self_referencing_column_name,
|
||||
CAST(null AS character_data) AS reference_generation,
|
||||
|
||||
CAST(CASE WHEN t.typname IS NOT NULL THEN current_database() ELSE null END AS sql_identifier) AS user_defined_type_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS user_defined_type_schema,
|
||||
CAST(t.typname AS sql_identifier) AS user_defined_type_name,
|
||||
|
||||
CAST(CASE WHEN c.relkind = 'r'
|
||||
OR (c.relkind = 'v'
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '3' AND is_instead))
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_insertable_into,
|
||||
|
||||
CAST(CASE WHEN t.typname IS NOT NULL THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_typed,
|
||||
CAST(null AS character_data) AS commit_action
|
||||
|
||||
FROM pg_namespace nc JOIN pg_class c ON (nc.oid = c.relnamespace)
|
||||
LEFT JOIN (pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid)) ON (c.reloftype = t.oid)
|
||||
|
||||
WHERE c.relkind IN ('r', 'v', 'f')
|
||||
AND (NOT pg_is_other_temp_schema(nc.oid))
|
||||
AND (pg_has_role(c.relowner, 'USAGE')
|
||||
OR has_table_privilege(c.oid, 'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER')
|
||||
OR has_any_column_privilege(c.oid, 'SELECT, INSERT, UPDATE, REFERENCES') );
|
||||
|
||||
CREATE VIEW information_schema.view_column_usage AS
|
||||
SELECT DISTINCT
|
||||
CAST(current_database() AS sql_identifier) AS view_catalog,
|
||||
CAST(nv.nspname AS sql_identifier) AS view_schema,
|
||||
CAST(v.relname AS sql_identifier) AS view_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(t.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_namespace nv, pg_class v, pg_depend dv,
|
||||
pg_depend dt, pg_class t, pg_namespace nt,
|
||||
pg_attribute a
|
||||
|
||||
WHERE nv.oid = v.relnamespace
|
||||
AND v.relkind = 'v'
|
||||
AND v.oid = dv.refobjid
|
||||
AND dv.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dv.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dv.deptype = 'i'
|
||||
AND dv.objid = dt.objid
|
||||
AND dv.refobjid <> dt.refobjid
|
||||
AND dt.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dt.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dt.refobjid = t.oid
|
||||
AND t.relnamespace = nt.oid
|
||||
AND t.relkind IN ('r', 'v', 'f')
|
||||
AND t.oid = a.attrelid
|
||||
AND dt.refobjsubid = a.attnum
|
||||
AND pg_has_role(t.relowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.view_table_usage AS
|
||||
SELECT DISTINCT
|
||||
CAST(current_database() AS sql_identifier) AS view_catalog,
|
||||
CAST(nv.nspname AS sql_identifier) AS view_schema,
|
||||
CAST(v.relname AS sql_identifier) AS view_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(t.relname AS sql_identifier) AS table_name
|
||||
|
||||
FROM pg_namespace nv, pg_class v, pg_depend dv,
|
||||
pg_depend dt, pg_class t, pg_namespace nt
|
||||
|
||||
WHERE nv.oid = v.relnamespace
|
||||
AND v.relkind = 'v'
|
||||
AND v.oid = dv.refobjid
|
||||
AND dv.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dv.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dv.deptype = 'i'
|
||||
AND dv.objid = dt.objid
|
||||
AND dv.refobjid <> dt.refobjid
|
||||
AND dt.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dt.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dt.refobjid = t.oid
|
||||
AND t.relnamespace = nt.oid
|
||||
AND t.relkind IN ('r', 'v', 'f')
|
||||
AND pg_has_role(t.relowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.data_type_privileges AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS object_catalog,
|
||||
CAST(x.objschema AS sql_identifier) AS object_schema,
|
||||
CAST(x.objname AS sql_identifier) AS object_name,
|
||||
CAST(x.objtype AS character_data) AS object_type,
|
||||
CAST(x.objdtdid AS sql_identifier) AS dtd_identifier
|
||||
|
||||
FROM
|
||||
(
|
||||
SELECT udt_schema, udt_name, 'USER-DEFINED TYPE'::text, dtd_identifier FROM attributes
|
||||
UNION ALL
|
||||
SELECT table_schema, table_name, 'TABLE'::text, dtd_identifier FROM columns
|
||||
UNION ALL
|
||||
SELECT domain_schema, domain_name, 'DOMAIN'::text, dtd_identifier FROM domains
|
||||
UNION ALL
|
||||
SELECT specific_schema, specific_name, 'ROUTINE'::text, dtd_identifier FROM parameters
|
||||
UNION ALL
|
||||
SELECT specific_schema, specific_name, 'ROUTINE'::text, dtd_identifier FROM routines
|
||||
) AS x (objschema, objname, objtype, objdtdid);
|
||||
|
||||
CREATE VIEW information_schema.role_column_grants AS
|
||||
SELECT grantor,
|
||||
grantee,
|
||||
table_catalog,
|
||||
table_schema,
|
||||
table_name,
|
||||
column_name,
|
||||
privilege_type,
|
||||
is_grantable
|
||||
FROM column_privileges
|
||||
WHERE grantor IN (SELECT role_name FROM enabled_roles)
|
||||
OR grantee IN (SELECT role_name FROM enabled_roles);
|
||||
|
||||
CREATE VIEW information_schema.role_table_grants AS
|
||||
SELECT grantor,
|
||||
grantee,
|
||||
table_catalog,
|
||||
table_schema,
|
||||
table_name,
|
||||
privilege_type,
|
||||
is_grantable,
|
||||
with_hierarchy
|
||||
FROM table_privileges
|
||||
WHERE grantor IN (SELECT role_name FROM enabled_roles)
|
||||
OR grantee IN (SELECT role_name FROM enabled_roles);
|
||||
|
||||
CREATE VIEW information_schema.element_types AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS object_catalog,
|
||||
CAST(n.nspname AS sql_identifier) AS object_schema,
|
||||
CAST(x.objname AS sql_identifier) AS object_name,
|
||||
CAST(x.objtype AS character_data) AS object_type,
|
||||
CAST(x.objdtdid AS sql_identifier) AS collection_type_identifier,
|
||||
CAST(
|
||||
CASE WHEN nbt.nspname = 'pg_catalog' THEN format_type(bt.oid, null)
|
||||
ELSE 'USER-DEFINED' END AS character_data) AS data_type,
|
||||
|
||||
CAST(null AS cardinal_number) AS character_maximum_length,
|
||||
CAST(null AS cardinal_number) AS character_octet_length,
|
||||
CAST(null AS sql_identifier) AS character_set_catalog,
|
||||
CAST(null AS sql_identifier) AS character_set_schema,
|
||||
CAST(null AS sql_identifier) AS character_set_name,
|
||||
CAST(CASE WHEN nco.nspname IS NOT NULL THEN current_database() END AS sql_identifier) AS collation_catalog,
|
||||
CAST(nco.nspname AS sql_identifier) AS collation_schema,
|
||||
CAST(co.collname AS sql_identifier) AS collation_name,
|
||||
CAST(null AS cardinal_number) AS numeric_precision,
|
||||
CAST(null AS cardinal_number) AS numeric_precision_radix,
|
||||
CAST(null AS cardinal_number) AS numeric_scale,
|
||||
CAST(null AS cardinal_number) AS datetime_precision,
|
||||
CAST(null AS character_data) AS interval_type,
|
||||
CAST(null AS cardinal_number) AS interval_precision,
|
||||
|
||||
CAST(null AS character_data) AS domain_default, -- XXX maybe a bug in the standard
|
||||
|
||||
CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(nbt.nspname AS sql_identifier) AS udt_schema,
|
||||
CAST(bt.typname AS sql_identifier) AS udt_name,
|
||||
|
||||
CAST(null AS sql_identifier) AS scope_catalog,
|
||||
CAST(null AS sql_identifier) AS scope_schema,
|
||||
CAST(null AS sql_identifier) AS scope_name,
|
||||
|
||||
CAST(null AS cardinal_number) AS maximum_cardinality,
|
||||
CAST('a' || CAST(x.objdtdid AS text) AS sql_identifier) AS dtd_identifier
|
||||
|
||||
FROM pg_namespace n, pg_type at, pg_namespace nbt, pg_type bt,
|
||||
(
|
||||
/* columns, attributes */
|
||||
SELECT c.relnamespace, CAST(c.relname AS sql_identifier),
|
||||
CASE WHEN c.relkind = 'c' THEN 'USER-DEFINED TYPE'::text ELSE 'TABLE'::text END,
|
||||
a.attnum, a.atttypid, a.attcollation
|
||||
FROM pg_class c, pg_attribute a
|
||||
WHERE c.oid = a.attrelid
|
||||
AND c.relkind IN ('r', 'v', 'f', 'c')
|
||||
AND attnum > 0 AND NOT attisdropped
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* domains */
|
||||
SELECT t.typnamespace, CAST(t.typname AS sql_identifier),
|
||||
'DOMAIN'::text, 1, t.typbasetype, t.typcollation
|
||||
FROM pg_type t
|
||||
WHERE t.typtype = 'd'
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* parameters */
|
||||
SELECT pronamespace, CAST(proname || '_' || CAST(oid AS text) AS sql_identifier),
|
||||
'ROUTINE'::text, (ss.x).n, (ss.x).x, 0
|
||||
FROM (SELECT p.pronamespace, p.proname, p.oid,
|
||||
_pg_expandarray(coalesce(p.proallargtypes, p.proargtypes::oid[])) AS x
|
||||
FROM pg_proc p) AS ss
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* result types */
|
||||
SELECT p.pronamespace, CAST(p.proname || '_' || CAST(p.oid AS text) AS sql_identifier),
|
||||
'ROUTINE'::text, 0, p.prorettype, 0
|
||||
FROM pg_proc p
|
||||
|
||||
) AS x (objschema, objname, objtype, objdtdid, objtypeid, objcollation)
|
||||
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
|
||||
ON x.objcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
|
||||
|
||||
WHERE n.oid = x.objschema
|
||||
AND at.oid = x.objtypeid
|
||||
AND (at.typelem <> 0 AND at.typlen = -1)
|
||||
AND at.typelem = bt.oid
|
||||
AND nbt.oid = bt.typnamespace
|
||||
|
||||
AND (n.nspname, x.objname, x.objtype, CAST(x.objdtdid AS sql_identifier)) IN
|
||||
( SELECT object_schema, object_name, object_type, dtd_identifier
|
||||
FROM data_type_privileges );
|
||||
|
||||
|
||||
GRANT SELECT ON information_schema.element_types TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.data_type_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.role_column_grants TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.role_table_grants TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_domain_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_udt_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.columns TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.table_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.tables TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.view_column_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.view_table_usage TO PUBLIC;
|
||||
|
||||
RESET search_path;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
-- --------------------------------------------------------------
|
||||
-- rollback pg_catalog.pg_collation
|
||||
-- --------------------------------------------------------------
|
||||
delete from pg_catalog.pg_collation where collname='zh_CN' and collnamespace=11 and collencoding=36 and collcollate='zh_CN.gb18030' and collctype='zh_CN.gb18030';
|
||||
delete from pg_catalog.pg_collation where collname='zh_CN.gb18030' and collnamespace=11 and collencoding=36 and collcollate='zh_CN.gb18030' and collctype='zh_CN.gb18030';
|
||||
|
|
@ -1,550 +1,4 @@
|
|||
SET search_path TO information_schema;
|
||||
|
||||
-- element_types is generated by data_type_privileges
|
||||
DROP VIEW IF EXISTS information_schema.element_types CASCADE;
|
||||
|
||||
-- data_type_privileges is generated by columns
|
||||
DROP VIEW IF EXISTS information_schema.data_type_privileges CASCADE;
|
||||
-- data_type_privileges is generated by table_privileges
|
||||
DROP VIEW IF EXISTS information_schema.role_column_grants CASCADE;
|
||||
-- data_type_privileges is generated by column_privileges
|
||||
DROP VIEW IF EXISTS information_schema.role_table_grants CASCADE;
|
||||
|
||||
-- other views need upgrade for matview
|
||||
DROP VIEW IF EXISTS information_schema.column_domain_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.column_privileges CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.column_udt_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.columns CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.table_privileges CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.tables CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.view_column_usage CASCADE;
|
||||
DROP VIEW IF EXISTS information_schema.view_table_usage CASCADE;
|
||||
|
||||
CREATE VIEW information_schema.column_domain_usage AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS domain_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS domain_schema,
|
||||
CAST(t.typname AS sql_identifier) AS domain_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_type t, pg_namespace nt, pg_class c, pg_namespace nc,
|
||||
pg_attribute a
|
||||
|
||||
WHERE t.typnamespace = nt.oid
|
||||
AND c.relnamespace = nc.oid
|
||||
AND a.attrelid = c.oid
|
||||
AND a.atttypid = t.oid
|
||||
AND t.typtype = 'd'
|
||||
AND c.relkind IN ('r', 'v', 'f')
|
||||
AND a.attnum > 0
|
||||
AND NOT a.attisdropped
|
||||
AND pg_has_role(t.typowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.column_privileges AS
|
||||
SELECT CAST(u_grantor.rolname AS sql_identifier) AS grantor,
|
||||
CAST(grantee.rolname AS sql_identifier) AS grantee,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(x.relname AS sql_identifier) AS table_name,
|
||||
CAST(x.attname AS sql_identifier) AS column_name,
|
||||
CAST(x.prtype AS character_data) AS privilege_type,
|
||||
CAST(
|
||||
CASE WHEN
|
||||
-- object owner always has grant options
|
||||
pg_has_role(x.grantee, x.relowner, 'USAGE')
|
||||
OR x.grantable
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_grantable
|
||||
|
||||
FROM (
|
||||
SELECT pr_c.grantor,
|
||||
pr_c.grantee,
|
||||
attname,
|
||||
relname,
|
||||
relnamespace,
|
||||
pr_c.prtype,
|
||||
pr_c.grantable,
|
||||
pr_c.relowner
|
||||
FROM (SELECT oid, relname, relnamespace, relowner, (aclexplode(coalesce(relacl, acldefault('r', relowner)))).*
|
||||
FROM pg_class
|
||||
WHERE relkind IN ('r', 'v', 'f')
|
||||
) pr_c (oid, relname, relnamespace, relowner, grantor, grantee, prtype, grantable),
|
||||
pg_attribute a
|
||||
WHERE a.attrelid = pr_c.oid
|
||||
AND a.attnum > 0
|
||||
AND NOT a.attisdropped
|
||||
UNION
|
||||
SELECT pr_a.grantor,
|
||||
pr_a.grantee,
|
||||
attname,
|
||||
relname,
|
||||
relnamespace,
|
||||
pr_a.prtype,
|
||||
pr_a.grantable,
|
||||
c.relowner
|
||||
FROM (SELECT attrelid, attname, (aclexplode(coalesce(attacl, acldefault('c', relowner)))).*
|
||||
FROM pg_attribute a JOIN pg_class cc ON (a.attrelid = cc.oid)
|
||||
WHERE attnum > 0
|
||||
AND NOT attisdropped
|
||||
) pr_a (attrelid, attname, grantor, grantee, prtype, grantable),
|
||||
pg_class c
|
||||
WHERE pr_a.attrelid = c.oid
|
||||
AND relkind IN ('r', 'v', 'f')
|
||||
) x,
|
||||
pg_namespace nc,
|
||||
pg_authid u_grantor,
|
||||
(
|
||||
SELECT oid, rolname FROM pg_authid
|
||||
UNION ALL
|
||||
SELECT 0::oid, 'PUBLIC'
|
||||
) AS grantee (oid, rolname)
|
||||
|
||||
WHERE x.relnamespace = nc.oid
|
||||
AND x.grantee = grantee.oid
|
||||
AND x.grantor = u_grantor.oid
|
||||
AND x.prtype IN ('INSERT', 'SELECT', 'UPDATE', 'REFERENCES', 'COMMENT')
|
||||
AND (pg_has_role(u_grantor.oid, 'USAGE')
|
||||
OR pg_has_role(grantee.oid, 'USAGE')
|
||||
OR grantee.rolname = 'PUBLIC');
|
||||
|
||||
CREATE VIEW information_schema.column_udt_usage AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(coalesce(nbt.nspname, nt.nspname) AS sql_identifier) AS udt_schema,
|
||||
CAST(coalesce(bt.typname, t.typname) AS sql_identifier) AS udt_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_attribute a, pg_class c, pg_namespace nc,
|
||||
(pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid))
|
||||
LEFT JOIN (pg_type bt JOIN pg_namespace nbt ON (bt.typnamespace = nbt.oid))
|
||||
ON (t.typtype = 'd' AND t.typbasetype = bt.oid)
|
||||
|
||||
WHERE a.attrelid = c.oid
|
||||
AND a.atttypid = t.oid
|
||||
AND nc.oid = c.relnamespace
|
||||
AND a.attnum > 0 AND NOT a.attisdropped AND c.relkind in ('r', 'v', 'f')
|
||||
AND pg_has_role(coalesce(bt.typowner, t.typowner), 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.columns AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name,
|
||||
CAST(a.attnum AS cardinal_number) AS ordinal_position,
|
||||
CAST(pg_get_expr(ad.adbin, ad.adrelid) AS character_data) AS column_default,
|
||||
CAST(CASE WHEN a.attnotnull OR (t.typtype = 'd' AND t.typnotnull) THEN 'NO' ELSE 'YES' END
|
||||
AS yes_or_no)
|
||||
AS is_nullable,
|
||||
|
||||
CAST(
|
||||
CASE WHEN t.typtype = 'd' THEN
|
||||
CASE WHEN bt.typelem <> 0 AND bt.typlen = -1 THEN 'ARRAY'
|
||||
WHEN nbt.nspname = 'pg_catalog' THEN format_type(t.typbasetype, null)
|
||||
ELSE 'USER-DEFINED' END
|
||||
ELSE
|
||||
CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'ARRAY'
|
||||
WHEN nt.nspname = 'pg_catalog' THEN format_type(a.atttypid, null)
|
||||
ELSE 'USER-DEFINED' END
|
||||
END
|
||||
AS character_data)
|
||||
AS data_type,
|
||||
|
||||
CAST(
|
||||
_pg_char_max_length(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS character_maximum_length,
|
||||
|
||||
CAST(
|
||||
_pg_char_octet_length(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS character_octet_length,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_precision(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_precision,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_precision_radix(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_precision_radix,
|
||||
|
||||
CAST(
|
||||
_pg_numeric_scale(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS numeric_scale,
|
||||
|
||||
CAST(
|
||||
_pg_datetime_precision(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS cardinal_number)
|
||||
AS datetime_precision,
|
||||
|
||||
CAST(
|
||||
_pg_interval_type(_pg_truetypid(a, t), _pg_truetypmod(a, t))
|
||||
AS character_data)
|
||||
AS interval_type,
|
||||
CAST(null AS cardinal_number) AS interval_precision,
|
||||
|
||||
CAST(null AS sql_identifier) AS character_set_catalog,
|
||||
CAST(null AS sql_identifier) AS character_set_schema,
|
||||
CAST(null AS sql_identifier) AS character_set_name,
|
||||
|
||||
CAST(CASE WHEN nco.nspname IS NOT NULL THEN current_database() END AS sql_identifier) AS collation_catalog,
|
||||
CAST(nco.nspname AS sql_identifier) AS collation_schema,
|
||||
CAST(co.collname AS sql_identifier) AS collation_name,
|
||||
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN current_database() ELSE null END
|
||||
AS sql_identifier) AS domain_catalog,
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN nt.nspname ELSE null END
|
||||
AS sql_identifier) AS domain_schema,
|
||||
CAST(CASE WHEN t.typtype = 'd' THEN t.typname ELSE null END
|
||||
AS sql_identifier) AS domain_name,
|
||||
|
||||
CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(coalesce(nbt.nspname, nt.nspname) AS sql_identifier) AS udt_schema,
|
||||
CAST(coalesce(bt.typname, t.typname) AS sql_identifier) AS udt_name,
|
||||
|
||||
CAST(null AS sql_identifier) AS scope_catalog,
|
||||
CAST(null AS sql_identifier) AS scope_schema,
|
||||
CAST(null AS sql_identifier) AS scope_name,
|
||||
|
||||
CAST(null AS cardinal_number) AS maximum_cardinality,
|
||||
CAST(a.attnum AS sql_identifier) AS dtd_identifier,
|
||||
CAST('NO' AS yes_or_no) AS is_self_referencing,
|
||||
|
||||
CAST('NO' AS yes_or_no) AS is_identity,
|
||||
CAST(null AS character_data) AS identity_generation,
|
||||
CAST(null AS character_data) AS identity_start,
|
||||
CAST(null AS character_data) AS identity_increment,
|
||||
CAST(null AS character_data) AS identity_maximum,
|
||||
CAST(null AS character_data) AS identity_minimum,
|
||||
CAST(null AS yes_or_no) AS identity_cycle,
|
||||
|
||||
CAST('NEVER' AS character_data) AS is_generated,
|
||||
CAST(null AS character_data) AS generation_expression,
|
||||
|
||||
CAST(CASE WHEN c.relkind = 'r'
|
||||
OR (c.relkind = 'v'
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '2' AND is_instead)
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '4' AND is_instead))
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_updatable
|
||||
|
||||
FROM (pg_attribute a LEFT JOIN pg_attrdef ad ON attrelid = adrelid AND attnum = adnum)
|
||||
JOIN (pg_class c JOIN pg_namespace nc ON (c.relnamespace = nc.oid)) ON a.attrelid = c.oid
|
||||
JOIN (pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid)) ON a.atttypid = t.oid
|
||||
LEFT JOIN (pg_type bt JOIN pg_namespace nbt ON (bt.typnamespace = nbt.oid))
|
||||
ON (t.typtype = 'd' AND t.typbasetype = bt.oid)
|
||||
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
|
||||
ON a.attcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
|
||||
|
||||
WHERE (NOT pg_is_other_temp_schema(nc.oid))
|
||||
|
||||
AND a.attnum > 0 AND NOT a.attisdropped AND c.relkind in ('r', 'v', 'f')
|
||||
|
||||
AND (pg_has_role(c.relowner, 'USAGE')
|
||||
OR has_column_privilege(c.oid, a.attnum,
|
||||
'SELECT, INSERT, UPDATE, REFERENCES'));
|
||||
|
||||
CREATE VIEW information_schema.table_privileges AS
|
||||
SELECT CAST(u_grantor.rolname AS sql_identifier) AS grantor,
|
||||
CAST(grantee.rolname AS sql_identifier) AS grantee,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
CAST(c.prtype AS character_data) AS privilege_type,
|
||||
CAST(
|
||||
CASE WHEN
|
||||
-- object owner always has grant options
|
||||
pg_has_role(grantee.oid, c.relowner, 'USAGE')
|
||||
OR c.grantable
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_grantable,
|
||||
CAST(CASE WHEN c.prtype = 'SELECT' THEN 'YES' ELSE 'NO' END AS yes_or_no) AS with_hierarchy
|
||||
|
||||
FROM (
|
||||
SELECT oid, relname, relnamespace, relkind, relowner, (aclexplode(coalesce(relacl, acldefault('r', relowner)))).* FROM pg_class
|
||||
) AS c (oid, relname, relnamespace, relkind, relowner, grantor, grantee, prtype, grantable),
|
||||
pg_namespace nc,
|
||||
pg_authid u_grantor,
|
||||
(
|
||||
SELECT oid, rolname FROM pg_authid
|
||||
UNION ALL
|
||||
SELECT 0::oid, 'PUBLIC'
|
||||
) AS grantee (oid, rolname)
|
||||
|
||||
WHERE c.relnamespace = nc.oid
|
||||
AND c.relkind IN ('r', 'v')
|
||||
AND c.grantee = grantee.oid
|
||||
AND c.grantor = u_grantor.oid
|
||||
AND c.prtype IN ('INSERT', 'SELECT', 'UPDATE', 'DELETE', 'TRUNCATE', 'REFERENCES', 'TRIGGER' ,
|
||||
'ALTER', 'DROP', 'COMMENT', 'INDEX', 'VACUUM')
|
||||
AND (pg_has_role(u_grantor.oid, 'USAGE')
|
||||
OR pg_has_role(grantee.oid, 'USAGE')
|
||||
OR grantee.rolname = 'PUBLIC');
|
||||
|
||||
CREATE VIEW information_schema.tables AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nc.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(c.relname AS sql_identifier) AS table_name,
|
||||
|
||||
CAST(
|
||||
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY'
|
||||
WHEN c.relkind = 'r' THEN 'BASE TABLE'
|
||||
WHEN c.relkind = 'v' THEN 'VIEW'
|
||||
WHEN c.relkind = 'f' THEN 'FOREIGN TABLE'
|
||||
ELSE null END
|
||||
AS character_data) AS table_type,
|
||||
|
||||
CAST(null AS sql_identifier) AS self_referencing_column_name,
|
||||
CAST(null AS character_data) AS reference_generation,
|
||||
|
||||
CAST(CASE WHEN t.typname IS NOT NULL THEN current_database() ELSE null END AS sql_identifier) AS user_defined_type_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS user_defined_type_schema,
|
||||
CAST(t.typname AS sql_identifier) AS user_defined_type_name,
|
||||
|
||||
CAST(CASE WHEN c.relkind = 'r'
|
||||
OR (c.relkind = 'v'
|
||||
AND EXISTS (SELECT 1 FROM pg_rewrite WHERE ev_class = c.oid AND ev_type = '3' AND is_instead))
|
||||
THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_insertable_into,
|
||||
|
||||
CAST(CASE WHEN t.typname IS NOT NULL THEN 'YES' ELSE 'NO' END AS yes_or_no) AS is_typed,
|
||||
CAST(null AS character_data) AS commit_action
|
||||
|
||||
FROM pg_namespace nc JOIN pg_class c ON (nc.oid = c.relnamespace)
|
||||
LEFT JOIN (pg_type t JOIN pg_namespace nt ON (t.typnamespace = nt.oid)) ON (c.reloftype = t.oid)
|
||||
|
||||
WHERE c.relkind IN ('r', 'v', 'f')
|
||||
AND (NOT pg_is_other_temp_schema(nc.oid))
|
||||
AND (pg_has_role(c.relowner, 'USAGE')
|
||||
OR has_table_privilege(c.oid, 'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER')
|
||||
OR has_any_column_privilege(c.oid, 'SELECT, INSERT, UPDATE, REFERENCES') );
|
||||
|
||||
CREATE VIEW information_schema.view_column_usage AS
|
||||
SELECT DISTINCT
|
||||
CAST(current_database() AS sql_identifier) AS view_catalog,
|
||||
CAST(nv.nspname AS sql_identifier) AS view_schema,
|
||||
CAST(v.relname AS sql_identifier) AS view_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(t.relname AS sql_identifier) AS table_name,
|
||||
CAST(a.attname AS sql_identifier) AS column_name
|
||||
|
||||
FROM pg_namespace nv, pg_class v, pg_depend dv,
|
||||
pg_depend dt, pg_class t, pg_namespace nt,
|
||||
pg_attribute a
|
||||
|
||||
WHERE nv.oid = v.relnamespace
|
||||
AND v.relkind = 'v'
|
||||
AND v.oid = dv.refobjid
|
||||
AND dv.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dv.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dv.deptype = 'i'
|
||||
AND dv.objid = dt.objid
|
||||
AND dv.refobjid <> dt.refobjid
|
||||
AND dt.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dt.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dt.refobjid = t.oid
|
||||
AND t.relnamespace = nt.oid
|
||||
AND t.relkind IN ('r', 'v', 'f')
|
||||
AND t.oid = a.attrelid
|
||||
AND dt.refobjsubid = a.attnum
|
||||
AND pg_has_role(t.relowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.view_table_usage AS
|
||||
SELECT DISTINCT
|
||||
CAST(current_database() AS sql_identifier) AS view_catalog,
|
||||
CAST(nv.nspname AS sql_identifier) AS view_schema,
|
||||
CAST(v.relname AS sql_identifier) AS view_name,
|
||||
CAST(current_database() AS sql_identifier) AS table_catalog,
|
||||
CAST(nt.nspname AS sql_identifier) AS table_schema,
|
||||
CAST(t.relname AS sql_identifier) AS table_name
|
||||
|
||||
FROM pg_namespace nv, pg_class v, pg_depend dv,
|
||||
pg_depend dt, pg_class t, pg_namespace nt
|
||||
|
||||
WHERE nv.oid = v.relnamespace
|
||||
AND v.relkind = 'v'
|
||||
AND v.oid = dv.refobjid
|
||||
AND dv.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dv.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dv.deptype = 'i'
|
||||
AND dv.objid = dt.objid
|
||||
AND dv.refobjid <> dt.refobjid
|
||||
AND dt.classid = 'pg_catalog.pg_rewrite'::regclass
|
||||
AND dt.refclassid = 'pg_catalog.pg_class'::regclass
|
||||
AND dt.refobjid = t.oid
|
||||
AND t.relnamespace = nt.oid
|
||||
AND t.relkind IN ('r', 'v', 'f')
|
||||
AND pg_has_role(t.relowner, 'USAGE');
|
||||
|
||||
CREATE VIEW information_schema.data_type_privileges AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS object_catalog,
|
||||
CAST(x.objschema AS sql_identifier) AS object_schema,
|
||||
CAST(x.objname AS sql_identifier) AS object_name,
|
||||
CAST(x.objtype AS character_data) AS object_type,
|
||||
CAST(x.objdtdid AS sql_identifier) AS dtd_identifier
|
||||
|
||||
FROM
|
||||
(
|
||||
SELECT udt_schema, udt_name, 'USER-DEFINED TYPE'::text, dtd_identifier FROM attributes
|
||||
UNION ALL
|
||||
SELECT table_schema, table_name, 'TABLE'::text, dtd_identifier FROM columns
|
||||
UNION ALL
|
||||
SELECT domain_schema, domain_name, 'DOMAIN'::text, dtd_identifier FROM domains
|
||||
UNION ALL
|
||||
SELECT specific_schema, specific_name, 'ROUTINE'::text, dtd_identifier FROM parameters
|
||||
UNION ALL
|
||||
SELECT specific_schema, specific_name, 'ROUTINE'::text, dtd_identifier FROM routines
|
||||
) AS x (objschema, objname, objtype, objdtdid);
|
||||
|
||||
CREATE VIEW information_schema.role_column_grants AS
|
||||
SELECT grantor,
|
||||
grantee,
|
||||
table_catalog,
|
||||
table_schema,
|
||||
table_name,
|
||||
column_name,
|
||||
privilege_type,
|
||||
is_grantable
|
||||
FROM column_privileges
|
||||
WHERE grantor IN (SELECT role_name FROM enabled_roles)
|
||||
OR grantee IN (SELECT role_name FROM enabled_roles);
|
||||
|
||||
CREATE VIEW information_schema.role_table_grants AS
|
||||
SELECT grantor,
|
||||
grantee,
|
||||
table_catalog,
|
||||
table_schema,
|
||||
table_name,
|
||||
privilege_type,
|
||||
is_grantable,
|
||||
with_hierarchy
|
||||
FROM table_privileges
|
||||
WHERE grantor IN (SELECT role_name FROM enabled_roles)
|
||||
OR grantee IN (SELECT role_name FROM enabled_roles);
|
||||
|
||||
CREATE VIEW information_schema.element_types AS
|
||||
SELECT CAST(current_database() AS sql_identifier) AS object_catalog,
|
||||
CAST(n.nspname AS sql_identifier) AS object_schema,
|
||||
CAST(x.objname AS sql_identifier) AS object_name,
|
||||
CAST(x.objtype AS character_data) AS object_type,
|
||||
CAST(x.objdtdid AS sql_identifier) AS collection_type_identifier,
|
||||
CAST(
|
||||
CASE WHEN nbt.nspname = 'pg_catalog' THEN format_type(bt.oid, null)
|
||||
ELSE 'USER-DEFINED' END AS character_data) AS data_type,
|
||||
|
||||
CAST(null AS cardinal_number) AS character_maximum_length,
|
||||
CAST(null AS cardinal_number) AS character_octet_length,
|
||||
CAST(null AS sql_identifier) AS character_set_catalog,
|
||||
CAST(null AS sql_identifier) AS character_set_schema,
|
||||
CAST(null AS sql_identifier) AS character_set_name,
|
||||
CAST(CASE WHEN nco.nspname IS NOT NULL THEN current_database() END AS sql_identifier) AS collation_catalog,
|
||||
CAST(nco.nspname AS sql_identifier) AS collation_schema,
|
||||
CAST(co.collname AS sql_identifier) AS collation_name,
|
||||
CAST(null AS cardinal_number) AS numeric_precision,
|
||||
CAST(null AS cardinal_number) AS numeric_precision_radix,
|
||||
CAST(null AS cardinal_number) AS numeric_scale,
|
||||
CAST(null AS cardinal_number) AS datetime_precision,
|
||||
CAST(null AS character_data) AS interval_type,
|
||||
CAST(null AS cardinal_number) AS interval_precision,
|
||||
|
||||
CAST(null AS character_data) AS domain_default, -- XXX maybe a bug in the standard
|
||||
|
||||
CAST(current_database() AS sql_identifier) AS udt_catalog,
|
||||
CAST(nbt.nspname AS sql_identifier) AS udt_schema,
|
||||
CAST(bt.typname AS sql_identifier) AS udt_name,
|
||||
|
||||
CAST(null AS sql_identifier) AS scope_catalog,
|
||||
CAST(null AS sql_identifier) AS scope_schema,
|
||||
CAST(null AS sql_identifier) AS scope_name,
|
||||
|
||||
CAST(null AS cardinal_number) AS maximum_cardinality,
|
||||
CAST('a' || CAST(x.objdtdid AS text) AS sql_identifier) AS dtd_identifier
|
||||
|
||||
FROM pg_namespace n, pg_type at, pg_namespace nbt, pg_type bt,
|
||||
(
|
||||
/* columns, attributes */
|
||||
SELECT c.relnamespace, CAST(c.relname AS sql_identifier),
|
||||
CASE WHEN c.relkind = 'c' THEN 'USER-DEFINED TYPE'::text ELSE 'TABLE'::text END,
|
||||
a.attnum, a.atttypid, a.attcollation
|
||||
FROM pg_class c, pg_attribute a
|
||||
WHERE c.oid = a.attrelid
|
||||
AND c.relkind IN ('r', 'v', 'f', 'c')
|
||||
AND attnum > 0 AND NOT attisdropped
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* domains */
|
||||
SELECT t.typnamespace, CAST(t.typname AS sql_identifier),
|
||||
'DOMAIN'::text, 1, t.typbasetype, t.typcollation
|
||||
FROM pg_type t
|
||||
WHERE t.typtype = 'd'
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* parameters */
|
||||
SELECT pronamespace, CAST(proname || '_' || CAST(oid AS text) AS sql_identifier),
|
||||
'ROUTINE'::text, (ss.x).n, (ss.x).x, 0
|
||||
FROM (SELECT p.pronamespace, p.proname, p.oid,
|
||||
_pg_expandarray(coalesce(p.proallargtypes, p.proargtypes::oid[])) AS x
|
||||
FROM pg_proc p) AS ss
|
||||
|
||||
UNION ALL
|
||||
|
||||
/* result types */
|
||||
SELECT p.pronamespace, CAST(p.proname || '_' || CAST(p.oid AS text) AS sql_identifier),
|
||||
'ROUTINE'::text, 0, p.prorettype, 0
|
||||
FROM pg_proc p
|
||||
|
||||
) AS x (objschema, objname, objtype, objdtdid, objtypeid, objcollation)
|
||||
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
|
||||
ON x.objcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
|
||||
|
||||
WHERE n.oid = x.objschema
|
||||
AND at.oid = x.objtypeid
|
||||
AND (at.typelem <> 0 AND at.typlen = -1)
|
||||
AND at.typelem = bt.oid
|
||||
AND nbt.oid = bt.typnamespace
|
||||
|
||||
AND (n.nspname, x.objname, x.objtype, CAST(x.objdtdid AS sql_identifier)) IN
|
||||
( SELECT object_schema, object_name, object_type, dtd_identifier
|
||||
FROM data_type_privileges );
|
||||
|
||||
|
||||
GRANT SELECT ON information_schema.element_types TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.data_type_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.role_column_grants TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.role_table_grants TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_domain_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.column_udt_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.columns TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.table_privileges TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.tables TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.view_column_usage TO PUBLIC;
|
||||
GRANT SELECT ON information_schema.view_table_usage TO PUBLIC;
|
||||
|
||||
RESET search_path;
|
||||
-- --------------------------------------------------------------
|
||||
-- rollback pg_catalog.pg_buffercache_pages
|
||||
-- --------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_buffercache_pages() CASCADE;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4130;
|
||||
CREATE OR REPLACE FUNCTION pg_catalog.pg_buffercache_pages
|
||||
(out bufferid pg_catalog.int4,
|
||||
out relfilenode pg_catalog.oid,
|
||||
out bucketid pg_catalog.int2,
|
||||
out storage_type pg_catalog.int2,
|
||||
out reltablespace pg_catalog.oid,
|
||||
out reldatabase pg_catalog.oid,
|
||||
out relforknumber pg_catalog.int2,
|
||||
out relblocknumber pg_catalog.int8,
|
||||
out isdirty pg_catalog.bool,
|
||||
out usage_count pg_catalog.int2)
|
||||
RETURNS SETOF record LANGUAGE INTERNAL STABLE STRICT as 'pg_buffercache_pages';CREATE OR REPLACE VIEW pg_catalog.pg_statio_all_sequences AS
|
||||
CREATE OR REPLACE VIEW pg_catalog.pg_statio_all_sequences AS
|
||||
SELECT
|
||||
C.oid AS relid,
|
||||
N.nspname AS schemaname,
|
||||
|
|
@ -792,11 +246,8 @@ UPDATE pg_catalog.pg_conversion SET contoencoding=37 WHERE conname like '%_to_bi
|
|||
|
||||
UPDATE pg_catalog.pg_conversion SET conforencoding=38 WHERE conname like 'uhc_to_%';
|
||||
UPDATE pg_catalog.pg_conversion SET contoencoding=38 WHERE conname like '%_to_uhc';
|
||||
-- ----------------------------------------------------------------
|
||||
-- rollback pg_catalog.pg_collatio
|
||||
-- ----------------------------------------------------------------
|
||||
delete from pg_catalog.pg_collation where collname='zh_CN' and collnamespace=11 and collencoding=36 and collcollate='zh_CN.gb18030' and collctype='zh_CN.gb18030';
|
||||
delete from pg_catalog.pg_collation where collname='zh_CN.gb18030' and collnamespace=11 and collencoding=36 and collcollate='zh_CN.gb18030' and collctype='zh_CN.gb18030';-- deleting system table pg_publication
|
||||
|
||||
-- deleting system table pg_publication
|
||||
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_pubname_index;
|
||||
|
|
@ -808,5 +259,5 @@ DROP TABLE IF EXISTS pg_catalog.pg_publication;
|
|||
DROP INDEX IF EXISTS pg_catalog.pg_publication_rel_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_rel_map_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.pg_publication_rel;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_publication_rel;DROP FUNCTION IF EXISTS pg_catalog.pg_read_binary_file_blocks(IN inputpath text, IN startblocknum int8, IN count int8) CASCADE;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_read_block_from_remote(int4, int4, int4, int2, int2, int4, xid, int4, xid, boolean) CASCADE;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_publication_rel;
|
||||
|
||||
|
|
|
|||
|
|
@ -108,19 +108,8 @@ BEGIN
|
|||
end if;
|
||||
end if;
|
||||
END$$;
|
||||
-- deleting system table pg_publication
|
||||
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_pubname_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.pg_publication;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_publication;
|
||||
|
||||
-- deleting system table pg_publication_rel
|
||||
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_rel_oid_index;
|
||||
DROP INDEX IF EXISTS pg_catalog.pg_publication_rel_map_index;
|
||||
DROP TYPE IF EXISTS pg_catalog.pg_publication_rel;
|
||||
DROP TABLE IF EXISTS pg_catalog.pg_publication_rel;do $$DECLARE
|
||||
do $$DECLARE
|
||||
ans boolean;
|
||||
func boolean;
|
||||
user_name text;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -2430,162 +2430,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.gs_read_segment_block_from_remote(integer,
|
|||
AS $function$gs_read_segment_block_from_remote$function$;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
-- adding system table pg_subscription
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, true, 6126, 6128, 0, 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pg_catalog.pg_subscription
|
||||
(
|
||||
subdbid oid NOCOMPRESS NOT NULL,
|
||||
subname name NOCOMPRESS,
|
||||
subowner oid NOCOMPRESS,
|
||||
subenabled bool NOCOMPRESS,
|
||||
subconninfo text NOCOMPRESS,
|
||||
subslotname name NOCOMPRESS,
|
||||
subsynccommit text NOCOMPRESS,
|
||||
subpublications text[] NOCOMPRESS
|
||||
) WITH OIDS TABLESPACE pg_global;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, true, 0, 0, 0, 6124;
|
||||
CREATE UNIQUE INDEX pg_subscription_oid_index ON pg_catalog.pg_subscription USING BTREE(oid OID_OPS);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, true, 0, 0, 0, 6125;
|
||||
CREATE UNIQUE INDEX pg_subscription_subname_index ON pg_catalog.pg_subscription USING BTREE(subdbid, subname);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
DECLARE
|
||||
user_name text;
|
||||
query_str text;
|
||||
BEGIN
|
||||
SELECT SESSION_USER INTO user_name;
|
||||
query_str := 'GRANT INSERT, SELECT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER ON TABLE pg_catalog.pg_subscription TO ' || quote_ident(user_name) || ';';
|
||||
EXECUTE IMMEDIATE query_str;
|
||||
END;
|
||||
/
|
||||
|
||||
-- adding system table pg_replication_origin
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, true, 6134, 6143, 0, 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pg_catalog.pg_replication_origin
|
||||
(
|
||||
roident oid NOCOMPRESS NOT NULL,
|
||||
roname text NOCOMPRESS
|
||||
) TABLESPACE pg_global;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, true, 0, 0, 0, 6136;
|
||||
CREATE UNIQUE INDEX pg_replication_origin_roident_index ON pg_catalog.pg_replication_origin USING BTREE(roident OID_OPS);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, true, 0, 0, 0, 6137;
|
||||
CREATE UNIQUE INDEX pg_replication_origin_roname_index ON pg_catalog.pg_replication_origin USING BTREE(roname TEXT_PATTERN_OPS);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
GRANT SELECT ON TABLE pg_catalog.pg_replication_origin TO PUBLIC;
|
||||
|
||||
-- adding function pg_replication_origin_create
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_create(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2635;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_create(IN node_name text, OUT replication_origin_oid oid) RETURNS oid LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_create';
|
||||
|
||||
-- adding function pg_replication_origin_drop
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_drop(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2636;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_drop(IN node_name text, OUT replication_origin_oid oid) RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_drop';
|
||||
|
||||
-- adding function pg_replication_origin_oid
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_oid(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2637;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_oid(IN node_name text, OUT replication_origin_oid oid) RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_oid';
|
||||
|
||||
-- adding function pg_replication_origin_session_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_setup(IN node_name text) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2751;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_session_setup(IN node_name text) RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_session_setup';
|
||||
|
||||
-- adding function pg_replication_origin_session_reset
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_reset() CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2750;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_session_reset() RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_session_reset';
|
||||
|
||||
-- adding function pg_replication_origin_session_is_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_is_setup() CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2639;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_session_is_setup() RETURNS boolean LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_session_is_setup';
|
||||
|
||||
-- adding function pg_replication_origin_session_progress
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_progress(IN flush boolean) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2640;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_session_progress(IN flush boolean) RETURNS record LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_session_progress';
|
||||
|
||||
-- adding function pg_replication_origin_xact_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_xact_setup(IN origin_lsn text, IN origin_timestamp timestamp with time zone) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2799;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_xact_setup(IN origin_lsn text, IN origin_timestamp timestamp with time zone) RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_xact_setup';
|
||||
|
||||
-- adding function pg_replication_origin_xact_reset
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_xact_reset() CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2752;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_xact_reset() RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_xact_reset';
|
||||
|
||||
-- adding function pg_replication_origin_advance
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_advance(IN node_name text, IN lsn text) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2634;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_advance(IN node_name text, IN lsn text) RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_advance';
|
||||
|
||||
-- adding function pg_replication_origin_progress
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_progress(IN node_name text, IN flush boolean) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2638;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_progress(IN node_name text, IN flush boolean) RETURNS record LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_progress';
|
||||
|
||||
-- adding function pg_show_replication_origin_status
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_show_replication_origin_status(OUT local_id oid, OUT external_id text, OUT remote_lsn text, OUT local_lsn text) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2800;
|
||||
CREATE FUNCTION pg_catalog.pg_show_replication_origin_status(OUT local_id oid, OUT external_id text, OUT remote_lsn text, OUT local_lsn text) RETURNS SETOF record LANGUAGE INTERNAL STABLE ROWS 100 AS 'pg_show_replication_origin_status';
|
||||
|
||||
-- adding function pg_get_publication_tables
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_get_publication_tables(IN pubname text, OUT relid oid) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2801;
|
||||
CREATE FUNCTION pg_catalog.pg_get_publication_tables(IN pubname text, OUT relid oid) RETURNS SETOF oid LANGUAGE INTERNAL STABLE STRICT AS 'pg_get_publication_tables';
|
||||
|
||||
-- adding function pg_stat_get_subscription
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_stat_get_subscription(IN subid oid, OUT subid oid, OUT pid integer, OUT received_lsn text, OUT last_msg_send_time timestamp with time zone, OUT last_msg_receipt_time timestamp with time zone, OUT latest_end_lsn text, OUT latest_end_time timestamp with time zone) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2802;
|
||||
CREATE FUNCTION pg_catalog.pg_stat_get_subscription(IN subid oid, OUT subid oid, OUT pid integer, OUT received_lsn text, OUT last_msg_send_time timestamp with time zone, OUT last_msg_receipt_time timestamp with time zone, OUT latest_end_lsn text, OUT latest_end_time timestamp with time zone) RETURNS record LANGUAGE INTERNAL STABLE AS 'pg_stat_get_subscription';
|
||||
|
||||
-- adding system view
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_publication_tables CASCADE;
|
||||
CREATE VIEW pg_catalog.pg_publication_tables AS
|
||||
SELECT
|
||||
P.pubname AS pubname,
|
||||
N.nspname AS schemaname,
|
||||
C.relname AS tablename
|
||||
FROM pg_publication P, pg_class C
|
||||
JOIN pg_namespace N ON (N.oid = C.relnamespace)
|
||||
WHERE C.oid IN (SELECT relid FROM pg_get_publication_tables(P.pubname));
|
||||
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_stat_subscription CASCADE;
|
||||
CREATE VIEW pg_catalog.pg_stat_subscription AS
|
||||
SELECT
|
||||
su.oid AS subid,
|
||||
su.subname,
|
||||
st.pid,
|
||||
st.received_lsn,
|
||||
st.last_msg_send_time,
|
||||
st.last_msg_receipt_time,
|
||||
st.latest_end_lsn,
|
||||
st.latest_end_time
|
||||
FROM pg_subscription su
|
||||
LEFT JOIN pg_stat_get_subscription(NULL) st
|
||||
ON (st.subid = su.oid);
|
||||
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_replication_origin_status CASCADE;
|
||||
CREATE VIEW pg_catalog.pg_replication_origin_status AS
|
||||
SELECT *
|
||||
FROM pg_show_replication_origin_status();
|
||||
|
||||
REVOKE ALL ON pg_catalog.pg_replication_origin_status FROM public;DROP FUNCTION IF EXISTS pg_catalog.gs_explain_model(text) cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_explain_model(text) cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_float8_array(text, VARIADIC "any") cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_bool(text, VARIADIC "any") cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_float4(text, VARIADIC "any") cascade;
|
||||
|
|
@ -2965,73 +2810,6 @@ AS $function$gs_read_block_from_remote$function$;
|
|||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_remove(anyarray, anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6555;
|
||||
CREATE FUNCTION pg_catalog.array_remove (
|
||||
anyarray, anyelement
|
||||
) RETURNS anyarray LANGUAGE INTERNAL IMMUTABLE as 'array_remove';
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_replace(anyarray, anyelement, anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6556;
|
||||
CREATE FUNCTION pg_catalog.array_replace (
|
||||
anyarray, anyelement, anyelement
|
||||
) RETURNS anyarray LANGUAGE INTERNAL IMMUTABLE as 'array_replace';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.first_transition(anyelement, anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6558;
|
||||
CREATE FUNCTION pg_catalog.first_transition (
|
||||
anyelement, anyelement
|
||||
) RETURNS anyelement LANGUAGE INTERNAL IMMUTABLE STRICT as 'first_transition';
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.last_transition(anyelement, anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6559;
|
||||
CREATE FUNCTION pg_catalog.last_transition (
|
||||
anyelement, anyelement
|
||||
) RETURNS anyelement LANGUAGE INTERNAL IMMUTABLE STRICT as 'last_transition';
|
||||
|
||||
DROP aggregate IF EXISTS pg_catalog.first(anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6560;
|
||||
create aggregate first(anyelement) (
|
||||
sfunc = first_transition,
|
||||
stype = anyelement
|
||||
);
|
||||
|
||||
DROP aggregate IF EXISTS pg_catalog.last(anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6561;
|
||||
create aggregate last(anyelement) (
|
||||
sfunc = last_transition,
|
||||
stype = anyelement
|
||||
);
|
||||
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.network_larger(inet, inet) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6666;
|
||||
CREATE FUNCTION pg_catalog.network_larger (
|
||||
inet, inet
|
||||
) RETURNS inet LANGUAGE INTERNAL STRICT as 'network_larger';
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.network_smaller(inet, inet) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6667;
|
||||
CREATE FUNCTION pg_catalog.network_smaller (
|
||||
inet, inet
|
||||
) RETURNS inet LANGUAGE INTERNAL STRICT as 'network_smaller';
|
||||
|
||||
|
||||
DROP aggregate IF EXISTS pg_catalog.max(inet) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6668;
|
||||
create aggregate max(inet) (
|
||||
sfunc = network_larger,
|
||||
stype = inet
|
||||
);
|
||||
|
||||
DROP aggregate IF EXISTS pg_catalog.min(inet) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6669;
|
||||
create aggregate min(inet) (
|
||||
sfunc = network_smaller,
|
||||
stype = inet
|
||||
);
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_buffercache_pages() CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4130;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
-- --------------------------------------------------------------
|
||||
-- upgrade pg_catalog.pg_collation
|
||||
-- --------------------------------------------------------------
|
||||
insert into pg_catalog.pg_collation values ('zh_CN', 11, 10, 36, 'zh_CN.gb18030', 'zh_CN.gb18030'), ('zh_CN.gb18030', 11, 10, 36, 'zh_CN.gb18030', 'zh_CN.gb18030');
|
||||
|
|
@ -1,23 +1,4 @@
|
|||
-- --------------------------------------------------------------
|
||||
-- upgrade pg_catalog.pg_buffercache_pages
|
||||
-- --------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_buffercache_pages() CASCADE;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4130;
|
||||
CREATE OR REPLACE FUNCTION pg_catalog.pg_buffercache_pages
|
||||
(out bufferid pg_catalog.int4,
|
||||
out relfilenode pg_catalog.oid,
|
||||
out bucketid pg_catalog.int4,
|
||||
out storage_type pg_catalog.int2,
|
||||
out reltablespace pg_catalog.oid,
|
||||
out reldatabase pg_catalog.oid,
|
||||
out relforknumber pg_catalog.int2,
|
||||
out relblocknumber pg_catalog.int8,
|
||||
out isdirty pg_catalog.bool,
|
||||
out isvalid pg_catalog.bool,
|
||||
out usage_count pg_catalog.int2,
|
||||
out pinning_backends pg_catalog.int4)
|
||||
RETURNS SETOF record LANGUAGE INTERNAL STABLE STRICT as 'pg_buffercache_pages';DROP TYPE IF EXISTS pg_catalog.gs_job_attribute;
|
||||
DROP TYPE IF EXISTS pg_catalog.gs_job_attribute;
|
||||
DROP TABLE IF EXISTS pg_catalog.gs_job_attribute;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG,false,true,9031,9031,0,0;
|
||||
CREATE TABLE IF NOT EXISTS pg_catalog.gs_job_attribute
|
||||
|
|
@ -148,10 +129,7 @@ SELECT pg_catalog.insert_pg_shdepend_temp(1059);
|
|||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
DROP FUNCTION pg_catalog.insert_pg_authid_temp();
|
||||
DROP FUNCTION pg_catalog.insert_pg_shdepend_temp();
|
||||
-- ----------------------------------------------------------------
|
||||
-- upgrade pg_catalog.pg_collation
|
||||
-- ----------------------------------------------------------------
|
||||
insert into pg_catalog.pg_collation values ('zh_CN', 11, 10, 36, 'zh_CN.gb18030', 'zh_CN.gb18030'), ('zh_CN.gb18030', 11, 10, 36, 'zh_CN.gb18030', 'zh_CN.gb18030');-- adding system table pg_publication
|
||||
-- adding system table pg_publication
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 6130, 6141, 0, 0;
|
||||
|
||||
|
|
@ -193,25 +171,4 @@ CREATE UNIQUE INDEX pg_publication_rel_map_index ON pg_catalog.pg_publication_re
|
|||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
GRANT SELECT ON TABLE pg_catalog.pg_publication_rel TO PUBLIC;SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4768;
|
||||
CREATE OR REPLACE FUNCTION pg_catalog.gs_read_block_from_remote
|
||||
( int4,
|
||||
int4,
|
||||
int4,
|
||||
int2,
|
||||
int2,
|
||||
int4,
|
||||
xid,
|
||||
int4,
|
||||
xid,
|
||||
boolean)
|
||||
RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 STRICT as 'gs_read_block_from_remote_compress';
|
||||
-- pg_read_binary_file_blocks()
|
||||
--
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8413;
|
||||
CREATE FUNCTION pg_catalog.pg_read_binary_file_blocks(IN inputpath text, IN startblocknum int8, IN count int8,
|
||||
OUT path text,
|
||||
OUT blocknum int4,
|
||||
OUT len int4,
|
||||
OUT data bytea)
|
||||
AS 'pg_read_binary_file_blocks' LANGUAGE INTERNAL IMMUTABLE STRICT;
|
||||
GRANT SELECT ON TABLE pg_catalog.pg_publication_rel TO PUBLIC;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4434;
|
|||
CREATE FUNCTION pg_catalog.gs_stat_undo(OUT curr_used_zone_count int4, OUT top_used_zones text, OUT curr_used_undo_size int4,
|
||||
OUT undo_threshold int4, OUT oldest_xid_in_undo oid, OUT oldest_xmin oid, OUT total_undo_chain_len oid, OUT max_undo_chain_len oid,
|
||||
OUT create_undo_file_count int4, OUT discard_undo_file_count int4)
|
||||
RETURNS record LANGUAGE INTERNAL as 'gs_stat_undo';--create system relation gs_db_privilege and its indexes
|
||||
RETURNS record LANGUAGE INTERNAL as 'gs_stat_undo';
|
||||
|
||||
--create system relation gs_db_privilege and its indexes
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 5566, 5567, 0, 0;
|
||||
CREATE TABLE pg_catalog.gs_db_privilege
|
||||
(
|
||||
|
|
@ -113,46 +115,3 @@ CREATE OR REPLACE FUNCTION pg_catalog.pg_logical_get_area_changes(start_lsn text
|
|||
LANGUAGE internal
|
||||
NOT FENCED NOT SHIPPABLE COST 1000
|
||||
AS $function$pg_logical_get_area_changes$function$;
|
||||
-- adding system table pg_publication
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 6130, 6141, 0, 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pg_catalog.pg_publication
|
||||
(
|
||||
pubname name NOCOMPRESS,
|
||||
pubowner oid NOCOMPRESS,
|
||||
puballtables bool NOCOMPRESS,
|
||||
pubinsert bool NOCOMPRESS,
|
||||
pubupdate bool NOCOMPRESS,
|
||||
pubdelete bool NOCOMPRESS
|
||||
) WITH OIDS;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6120;
|
||||
CREATE UNIQUE INDEX pg_publication_oid_index ON pg_catalog.pg_publication USING BTREE(oid OID_OPS);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6121;
|
||||
CREATE UNIQUE INDEX pg_publication_pubname_index ON pg_catalog.pg_publication USING BTREE(pubname);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
GRANT SELECT ON TABLE pg_catalog.pg_publication TO PUBLIC;
|
||||
|
||||
-- adding system table pg_publication_rel
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 6132, 6142, 0, 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pg_catalog.pg_publication_rel
|
||||
(
|
||||
prpubid oid NOCOMPRESS NOT NULL,
|
||||
prrelid oid NOCOMPRESS NOT NULL
|
||||
) WITH OIDS;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6122;
|
||||
CREATE UNIQUE INDEX pg_publication_rel_oid_index ON pg_catalog.pg_publication_rel USING BTREE(oid OID_OPS);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6123;
|
||||
CREATE UNIQUE INDEX pg_publication_rel_map_index ON pg_catalog.pg_publication_rel USING BTREE(prrelid, prpubid);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
GRANT SELECT ON TABLE pg_catalog.pg_publication_rel TO PUBLIC;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4768;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 5843;
|
||||
CREATE OR REPLACE FUNCTION pg_catalog.gs_read_block_from_remote
|
||||
( int4,
|
||||
int4,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -2431,162 +2431,8 @@ CREATE OR REPLACE FUNCTION pg_catalog.gs_read_segment_block_from_remote(integer,
|
|||
AS $function$gs_read_segment_block_from_remote$function$;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
-- adding system table pg_subscription
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, false, 6126, 6128, 0, 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pg_catalog.pg_subscription
|
||||
(
|
||||
subdbid oid NOCOMPRESS NOT NULL,
|
||||
subname name NOCOMPRESS,
|
||||
subowner oid NOCOMPRESS,
|
||||
subenabled bool NOCOMPRESS,
|
||||
subconninfo text NOCOMPRESS,
|
||||
subslotname name NOCOMPRESS,
|
||||
subsynccommit text NOCOMPRESS,
|
||||
subpublications text[] NOCOMPRESS
|
||||
) WITH OIDS TABLESPACE pg_global;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, false, 0, 0, 0, 6124;
|
||||
CREATE UNIQUE INDEX pg_subscription_oid_index ON pg_catalog.pg_subscription USING BTREE(oid OID_OPS);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, false, 0, 0, 0, 6125;
|
||||
CREATE UNIQUE INDEX pg_subscription_subname_index ON pg_catalog.pg_subscription USING BTREE(subdbid, subname);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
DECLARE
|
||||
user_name text;
|
||||
query_str text;
|
||||
BEGIN
|
||||
SELECT SESSION_USER INTO user_name;
|
||||
query_str := 'GRANT INSERT, SELECT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER ON TABLE pg_catalog.pg_subscription TO ' || quote_ident(user_name) || ';';
|
||||
EXECUTE IMMEDIATE query_str;
|
||||
END;
|
||||
/
|
||||
|
||||
-- adding system table pg_replication_origin
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, false, 6134, 6143, 0, 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pg_catalog.pg_replication_origin
|
||||
(
|
||||
roident oid NOCOMPRESS NOT NULL,
|
||||
roname text NOCOMPRESS
|
||||
) TABLESPACE pg_global;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, false, 0, 0, 0, 6136;
|
||||
CREATE UNIQUE INDEX pg_replication_origin_roident_index ON pg_catalog.pg_replication_origin USING BTREE(roident OID_OPS);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, true, false, 0, 0, 0, 6137;
|
||||
CREATE UNIQUE INDEX pg_replication_origin_roname_index ON pg_catalog.pg_replication_origin USING BTREE(roname TEXT_PATTERN_OPS);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
GRANT SELECT ON TABLE pg_catalog.pg_replication_origin TO PUBLIC;
|
||||
|
||||
-- adding function pg_replication_origin_create
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_create(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2635;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_create(IN node_name text, OUT replication_origin_oid oid) RETURNS oid LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_create';
|
||||
|
||||
-- adding function pg_replication_origin_drop
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_drop(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2636;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_drop(IN node_name text, OUT replication_origin_oid oid) RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_drop';
|
||||
|
||||
-- adding function pg_replication_origin_oid
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_oid(IN node_name text, OUT replication_origin_oid oid) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2637;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_oid(IN node_name text, OUT replication_origin_oid oid) RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_oid';
|
||||
|
||||
-- adding function pg_replication_origin_session_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_setup(IN node_name text) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2751;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_session_setup(IN node_name text) RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_session_setup';
|
||||
|
||||
-- adding function pg_replication_origin_session_reset
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_reset() CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2750;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_session_reset() RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_session_reset';
|
||||
|
||||
-- adding function pg_replication_origin_session_is_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_is_setup() CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2639;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_session_is_setup() RETURNS boolean LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_session_is_setup';
|
||||
|
||||
-- adding function pg_replication_origin_session_progress
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_session_progress(IN flush boolean) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2640;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_session_progress(IN flush boolean) RETURNS record LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_session_progress';
|
||||
|
||||
-- adding function pg_replication_origin_xact_setup
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_xact_setup(IN origin_lsn text, IN origin_timestamp timestamp with time zone) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2799;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_xact_setup(IN origin_lsn text, IN origin_timestamp timestamp with time zone) RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_xact_setup';
|
||||
|
||||
-- adding function pg_replication_origin_xact_reset
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_xact_reset() CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2752;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_xact_reset() RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_xact_reset';
|
||||
|
||||
-- adding function pg_replication_origin_advance
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_advance(IN node_name text, IN lsn text) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2634;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_advance(IN node_name text, IN lsn text) RETURNS void LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_advance';
|
||||
|
||||
-- adding function pg_replication_origin_progress
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_replication_origin_progress(IN node_name text, IN flush boolean) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2638;
|
||||
CREATE FUNCTION pg_catalog.pg_replication_origin_progress(IN node_name text, IN flush boolean) RETURNS record LANGUAGE INTERNAL STRICT AS 'pg_replication_origin_progress';
|
||||
|
||||
-- adding function pg_show_replication_origin_status
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_show_replication_origin_status(OUT local_id oid, OUT external_id text, OUT remote_lsn text, OUT local_lsn text) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2800;
|
||||
CREATE FUNCTION pg_catalog.pg_show_replication_origin_status(OUT local_id oid, OUT external_id text, OUT remote_lsn text, OUT local_lsn text) RETURNS SETOF record LANGUAGE INTERNAL STABLE ROWS 100 AS 'pg_show_replication_origin_status';
|
||||
|
||||
-- adding function pg_get_publication_tables
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_get_publication_tables(IN pubname text, OUT relid oid) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2801;
|
||||
CREATE FUNCTION pg_catalog.pg_get_publication_tables(IN pubname text, OUT relid oid) RETURNS SETOF oid LANGUAGE INTERNAL STABLE STRICT AS 'pg_get_publication_tables';
|
||||
|
||||
-- adding function pg_stat_get_subscription
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_stat_get_subscription(IN subid oid, OUT subid oid, OUT pid integer, OUT received_lsn text, OUT last_msg_send_time timestamp with time zone, OUT last_msg_receipt_time timestamp with time zone, OUT latest_end_lsn text, OUT latest_end_time timestamp with time zone) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 2802;
|
||||
CREATE FUNCTION pg_catalog.pg_stat_get_subscription(IN subid oid, OUT subid oid, OUT pid integer, OUT received_lsn text, OUT last_msg_send_time timestamp with time zone, OUT last_msg_receipt_time timestamp with time zone, OUT latest_end_lsn text, OUT latest_end_time timestamp with time zone) RETURNS record LANGUAGE INTERNAL STABLE AS 'pg_stat_get_subscription';
|
||||
|
||||
-- adding system view
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_publication_tables CASCADE;
|
||||
CREATE VIEW pg_catalog.pg_publication_tables AS
|
||||
SELECT
|
||||
P.pubname AS pubname,
|
||||
N.nspname AS schemaname,
|
||||
C.relname AS tablename
|
||||
FROM pg_publication P, pg_class C
|
||||
JOIN pg_namespace N ON (N.oid = C.relnamespace)
|
||||
WHERE C.oid IN (SELECT relid FROM pg_get_publication_tables(P.pubname));
|
||||
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_stat_subscription CASCADE;
|
||||
CREATE VIEW pg_catalog.pg_stat_subscription AS
|
||||
SELECT
|
||||
su.oid AS subid,
|
||||
su.subname,
|
||||
st.pid,
|
||||
st.received_lsn,
|
||||
st.last_msg_send_time,
|
||||
st.last_msg_receipt_time,
|
||||
st.latest_end_lsn,
|
||||
st.latest_end_time
|
||||
FROM pg_subscription su
|
||||
LEFT JOIN pg_stat_get_subscription(NULL) st
|
||||
ON (st.subid = su.oid);
|
||||
|
||||
DROP VIEW IF EXISTS pg_catalog.pg_replication_origin_status CASCADE;
|
||||
CREATE VIEW pg_catalog.pg_replication_origin_status AS
|
||||
SELECT *
|
||||
FROM pg_show_replication_origin_status();
|
||||
|
||||
REVOKE ALL ON pg_catalog.pg_replication_origin_status FROM public;DROP FUNCTION IF EXISTS pg_catalog.gs_explain_model(text) cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.gs_explain_model(text) cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_float8_array(text, VARIADIC "any") cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_bool(text, VARIADIC "any") cascade;
|
||||
DROP FUNCTION IF EXISTS pg_catalog.db4ai_predict_by_float4(text, VARIADIC "any") cascade;
|
||||
|
|
@ -2966,73 +2812,6 @@ AS $function$gs_read_block_from_remote$function$;
|
|||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_remove(anyarray, anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6555;
|
||||
CREATE FUNCTION pg_catalog.array_remove (
|
||||
anyarray, anyelement
|
||||
) RETURNS anyarray LANGUAGE INTERNAL IMMUTABLE as 'array_remove';
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.array_replace(anyarray, anyelement, anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6556;
|
||||
CREATE FUNCTION pg_catalog.array_replace (
|
||||
anyarray, anyelement, anyelement
|
||||
) RETURNS anyarray LANGUAGE INTERNAL IMMUTABLE as 'array_replace';
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.first_transition(anyelement, anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6558;
|
||||
CREATE FUNCTION pg_catalog.first_transition (
|
||||
anyelement, anyelement
|
||||
) RETURNS anyelement LANGUAGE INTERNAL IMMUTABLE STRICT as 'first_transition';
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.last_transition(anyelement, anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6559;
|
||||
CREATE FUNCTION pg_catalog.last_transition (
|
||||
anyelement, anyelement
|
||||
) RETURNS anyelement LANGUAGE INTERNAL IMMUTABLE STRICT as 'last_transition';
|
||||
|
||||
DROP aggregate IF EXISTS pg_catalog.first(anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6560;
|
||||
create aggregate first(anyelement) (
|
||||
sfunc = first_transition,
|
||||
stype = anyelement
|
||||
);
|
||||
|
||||
DROP aggregate IF EXISTS pg_catalog.last(anyelement) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6561;
|
||||
create aggregate last(anyelement) (
|
||||
sfunc = last_transition,
|
||||
stype = anyelement
|
||||
);
|
||||
|
||||
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.network_larger(inet, inet) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6666;
|
||||
CREATE FUNCTION pg_catalog.network_larger (
|
||||
inet, inet
|
||||
) RETURNS inet LANGUAGE INTERNAL STRICT as 'network_larger';
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.network_smaller(inet, inet) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6667;
|
||||
CREATE FUNCTION pg_catalog.network_smaller (
|
||||
inet, inet
|
||||
) RETURNS inet LANGUAGE INTERNAL STRICT as 'network_smaller';
|
||||
|
||||
|
||||
DROP aggregate IF EXISTS pg_catalog.max(inet) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6668;
|
||||
create aggregate max(inet) (
|
||||
sfunc = network_larger,
|
||||
stype = inet
|
||||
);
|
||||
|
||||
DROP aggregate IF EXISTS pg_catalog.min(inet) CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6669;
|
||||
create aggregate min(inet) (
|
||||
sfunc = network_smaller,
|
||||
stype = inet
|
||||
);
|
||||
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_buffercache_pages() CASCADE;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4130;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
-- --------------------------------------------------------------
|
||||
-- upgrade pg_catalog.pg_collation
|
||||
-- --------------------------------------------------------------
|
||||
insert into pg_catalog.pg_collation values ('zh_CN', 11, 10, 36, 'zh_CN.gb18030', 'zh_CN.gb18030'), ('zh_CN.gb18030', 11, 10, 36, 'zh_CN.gb18030', 'zh_CN.gb18030');
|
||||
|
|
@ -1,23 +1,4 @@
|
|||
-- --------------------------------------------------------------
|
||||
-- upgrade pg_catalog.pg_buffercache_pages
|
||||
-- --------------------------------------------------------------
|
||||
DROP FUNCTION IF EXISTS pg_catalog.pg_buffercache_pages() CASCADE;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4130;
|
||||
CREATE OR REPLACE FUNCTION pg_catalog.pg_buffercache_pages
|
||||
(out bufferid pg_catalog.int4,
|
||||
out relfilenode pg_catalog.oid,
|
||||
out bucketid pg_catalog.int4,
|
||||
out storage_type pg_catalog.int2,
|
||||
out reltablespace pg_catalog.oid,
|
||||
out reldatabase pg_catalog.oid,
|
||||
out relforknumber pg_catalog.int2,
|
||||
out relblocknumber pg_catalog.int8,
|
||||
out isdirty pg_catalog.bool,
|
||||
out isvalid pg_catalog.bool,
|
||||
out usage_count pg_catalog.int2,
|
||||
out pinning_backends pg_catalog.int4)
|
||||
RETURNS SETOF record LANGUAGE INTERNAL STABLE STRICT as 'pg_buffercache_pages';DROP TYPE IF EXISTS pg_catalog.gs_job_attribute;
|
||||
DROP TYPE IF EXISTS pg_catalog.gs_job_attribute;
|
||||
DROP TABLE IF EXISTS pg_catalog.gs_job_attribute;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG,false,true,9031,9031,0,0;
|
||||
CREATE TABLE IF NOT EXISTS pg_catalog.gs_job_attribute
|
||||
|
|
@ -115,10 +96,8 @@ UPDATE pg_catalog.pg_conversion SET contoencoding=38 WHERE conname like '%_to_bi
|
|||
|
||||
UPDATE pg_catalog.pg_conversion SET conforencoding=39 WHERE conname like 'uhc_to_%';
|
||||
UPDATE pg_catalog.pg_conversion SET contoencoding=39 WHERE conname like '%_to_uhc';
|
||||
-- ----------------------------------------------------------------
|
||||
-- upgrade pg_catalog.pg_collation
|
||||
-- ----------------------------------------------------------------
|
||||
insert into pg_catalog.pg_collation values ('zh_CN', 11, 10, 36, 'zh_CN.gb18030', 'zh_CN.gb18030'), ('zh_CN.gb18030', 11, 10, 36, 'zh_CN.gb18030', 'zh_CN.gb18030');-- adding system table pg_publication
|
||||
|
||||
-- adding system table pg_publication
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 6130, 6141, 0, 0;
|
||||
|
||||
|
|
@ -160,25 +139,4 @@ CREATE UNIQUE INDEX pg_publication_rel_map_index ON pg_catalog.pg_publication_re
|
|||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
GRANT SELECT ON TABLE pg_catalog.pg_publication_rel TO PUBLIC;SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4768;
|
||||
CREATE OR REPLACE FUNCTION pg_catalog.gs_read_block_from_remote
|
||||
( int4,
|
||||
int4,
|
||||
int4,
|
||||
int2,
|
||||
int2,
|
||||
int4,
|
||||
xid,
|
||||
int4,
|
||||
xid,
|
||||
boolean)
|
||||
RETURNS SETOF record LANGUAGE INTERNAL ROWS 1 STRICT as 'gs_read_block_from_remote_compress';
|
||||
-- pg_read_binary_file_blocks()
|
||||
--
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 8413;
|
||||
CREATE FUNCTION pg_catalog.pg_read_binary_file_blocks(IN inputpath text, IN startblocknum int8, IN count int8,
|
||||
OUT path text,
|
||||
OUT blocknum int4,
|
||||
OUT len int4,
|
||||
OUT data bytea)
|
||||
AS 'pg_read_binary_file_blocks' LANGUAGE INTERNAL IMMUTABLE STRICT;
|
||||
GRANT SELECT ON TABLE pg_catalog.pg_publication_rel TO PUBLIC;
|
||||
|
|
|
|||
|
|
@ -113,46 +113,3 @@ CREATE OR REPLACE FUNCTION pg_catalog.pg_logical_get_area_changes(start_lsn text
|
|||
LANGUAGE internal
|
||||
NOT FENCED NOT SHIPPABLE COST 1000
|
||||
AS $function$pg_logical_get_area_changes$function$;
|
||||
-- adding system table pg_publication
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 6130, 6141, 0, 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pg_catalog.pg_publication
|
||||
(
|
||||
pubname name NOCOMPRESS,
|
||||
pubowner oid NOCOMPRESS,
|
||||
puballtables bool NOCOMPRESS,
|
||||
pubinsert bool NOCOMPRESS,
|
||||
pubupdate bool NOCOMPRESS,
|
||||
pubdelete bool NOCOMPRESS
|
||||
) WITH OIDS;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6120;
|
||||
CREATE UNIQUE INDEX pg_publication_oid_index ON pg_catalog.pg_publication USING BTREE(oid OID_OPS);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6121;
|
||||
CREATE UNIQUE INDEX pg_publication_pubname_index ON pg_catalog.pg_publication USING BTREE(pubname);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
GRANT SELECT ON TABLE pg_catalog.pg_publication TO PUBLIC;
|
||||
|
||||
-- adding system table pg_publication_rel
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 6132, 6142, 0, 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pg_catalog.pg_publication_rel
|
||||
(
|
||||
prpubid oid NOCOMPRESS NOT NULL,
|
||||
prrelid oid NOCOMPRESS NOT NULL
|
||||
) WITH OIDS;
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6122;
|
||||
CREATE UNIQUE INDEX pg_publication_rel_oid_index ON pg_catalog.pg_publication_rel USING BTREE(oid OID_OPS);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6123;
|
||||
CREATE UNIQUE INDEX pg_publication_rel_map_index ON pg_catalog.pg_publication_rel USING BTREE(prrelid, prpubid);
|
||||
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||
|
||||
GRANT SELECT ON TABLE pg_catalog.pg_publication_rel TO PUBLIC;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 4768;
|
||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 5843;
|
||||
CREATE OR REPLACE FUNCTION pg_catalog.gs_read_block_from_remote
|
||||
( int4,
|
||||
int4,
|
||||
|
|
|
|||
Loading…
Reference in New Issue