15670430创建于 2020年12月28日历史提交
--
-- gs_upgrade coverage
--
drop database if exists testaes1;
create database testaes1;
\c testaes1
-- 1. execute the precondition
SET client_min_messages = warning;
DROP SCHEMA IF EXISTS upgrade_coverage CASCADE;
RESET client_min_messages;
create schema upgrade_coverage;
create table upgrade_coverage.tbl_part_cstore_with_toast (a int, b varchar (8000))
with(orientation = column) partition by range (a)
(
  partition tbl_part_cstore_with_toast_p1 values less than (500),
  partition tbl_part_cstore_with_toast_p2 values less than (1000)
);
create index tbl_part_cstore_with_toast_idx on upgrade_coverage.tbl_part_cstore_with_toast(a) local;
create table upgrade_coverage.tbl_part_cstore_without_toast (a int)
with(orientation = column) partition by range (a)
(
  partition tbl_part_cstore_without_toast_p1 values less than (500),
  partition tbl_part_cstore_without_toast_p2 values less than (1000)
);
create index tbl_part_cstore_without_toast_idx on upgrade_coverage.tbl_part_cstore_without_toast(a) local;
create table upgrade_coverage.tbl_cstore_with_toast (a int, b varchar (8000)) with(orientation = column);
create table upgrade_coverage.tbl_cstore_without_toast (a int) with(orientation = column);
create index tbl_cstore_with_toast_idx on upgrade_coverage.tbl_cstore_with_toast(a);
create index tbl_cstore_without_toast_idx on upgrade_coverage.tbl_cstore_without_toast(a);
create table upgrade_coverage.tbl_part_with_toast (a int, b varchar (8000))
partition by range (a)
(
  partition tbl_part_with_toast_p1 values less than (500),
  partition tbl_part_with_toast_p2 values less than (1000)
);
create index tbl_part_with_toast_idx on upgrade_coverage.tbl_part_with_toast(a) local;
create table upgrade_coverage.tbl_part_without_toast (a int)
partition by range (a)
(
  partition tbl_part_without_toast_p1 values less than (500),
  partition tbl_part_without_toast_p2 values less than (1000)
);
create index tbl_part_without_toast_idx on upgrade_coverage.tbl_part_without_toast(a) local;
create table upgrade_coverage.tbl_with_toast (a int, b varchar (8000));
create table upgrade_coverage.tbl_without_toast (a int);
create index tbl_with_toast_idx on upgrade_coverage.tbl_with_toast(a);
create index tbl_without_toast_idx on upgrade_coverage.tbl_without_toast(a);
-- foreign table
create foreign table upgrade_coverage.foreign_tbl_with_toast (a int, b varchar (8000)) SERVER gsmpp_server OPTIONS (location
'file:///input_data/*', format 'csv', mode 'private', delimiter ',') READ ONLY;
create foreign table upgrade_coverage.foreign_tbl_without_toast (a int) SERVER gsmpp_server OPTIONS (location
'file:///input_data/*', format 'csv', mode 'private', delimiter ',') READ ONLY;
-- 2. take the dump in binary upgrade mode
\! @abs_bindir@/gs_dump --schema-only --no-owner --no-privileges --binary-upgrade --schema=upgrade_coverage -p @portstring@ -f @abs_bindir@/gs_dump_upgrade_schema.sql testaes1> @abs_bindir@/gs_dump_upgrade_schema.log 2>&1
-- 3. cleanup existing tables
\! @abs_bindir@/gsql -d testaes1 -p @portstring@ -c "DROP SCHEMA IF EXISTS upgrade_coverage CASCADE;" >/dev/null 2>&1
CHECKPOINT;
-- 4. execute the create binary upgrade functions
SET client_min_messages = warning;
DROP SCHEMA IF EXISTS binary_upgrade CASCADE;
RESET client_min_messages;
CREATE SCHEMA binary_upgrade;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_pg_type_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_array_pg_type_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_toast_pg_type_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_heap_pg_class_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_index_pg_class_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_toast_pg_class_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_etbl_pg_type_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_etbl_array_pg_type_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_etbl_toast_pg_type_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_etbl_heap_pg_class_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_etbl_index_pg_class_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_etbl_toast_pg_class_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_partrel_pg_partition_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_part_pg_partition_oids(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.setnext_part_toast_pg_class_oids(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_part_toast_pg_type_oids(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.setnext_part_index_pg_class_oids(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_psort_oid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_psort_typoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_psort_atypoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_delta_oid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_delta_typoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_delta_atypoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_cudesc_oid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_cudesc_typoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_cudesc_atypoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_cudesc_idx_oid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_cudesc_toast_oid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_cudesc_toast_typoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_cudesc_toast_idx_oid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_delta_toast_oid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_delta_toast_typoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_delta_toast_idx_oid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_pg_enum_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_pg_authid_oid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_delta_rfoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_delta_toast_idx_rfoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_delta_toast_rfoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_psort_rfoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_etbl_heap_pg_class_rfoid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_etbl_index_pg_class_rfoid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_etbl_toast_pg_class_rfoid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_heap_pg_class_rfoid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_index_pg_class_rfoid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.setnext_part_index_pg_class_rfoids(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_part_pg_partition_rfoids(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_partrel_pg_partition_rfoid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.setnext_part_toast_pg_class_rfoids(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_toast_pg_class_rfoid(OID)  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_cudesc_idx_rfoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_cudesc_rfoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_cudesc_toast_idx_rfoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.set_next_cstore_cudesc_toast_rfoid(OID[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.create_empty_extension(text, text, bool, text, oid[], text[], text[])  RETURNS VOID  AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support'  LANGUAGE C STRICT NOT FENCED;

CREATE OR REPLACE FUNCTION  binary_upgrade.start_upgrade_functions_manually() RETURNS VOID AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support' LANGUAGE C STRICT NOT FENCED;
CREATE OR REPLACE FUNCTION  binary_upgrade.stop_upgrade_functions_manually() RETURNS VOID AS '@abs_bindir@/../lib/postgresql/pg_upgrade_support' LANGUAGE C STRICT NOT FENCED;
CHECKPOINT;
-- 5. restore the dump file which was created previously
\! echo "" >@abs_bindir@/gs_dump_upgrade_coverage.sql
\! echo "select binary_upgrade.start_upgrade_functions_manually();"  >>@abs_bindir@/gs_dump_upgrade_coverage.sql
\! echo "CHECKPOINT;"  >>@abs_bindir@/gs_dump_upgrade_coverage.sql
\! echo "CHECKPOINT;"  >>@abs_bindir@/gs_dump_upgrade_coverage.sql
\! cat @abs_bindir@/gs_dump_upgrade_schema.sql >>@abs_bindir@/gs_dump_upgrade_coverage.sql
\! echo "CHECKPOINT;"  >>@abs_bindir@/gs_dump_upgrade_coverage.sql
\! echo "select binary_upgrade.stop_upgrade_functions_manually();"  >>@abs_bindir@/gs_dump_upgrade_coverage.sql
\! @abs_bindir@/gsql -d testaes1 -p @portstring@ -f @abs_bindir@/gs_dump_upgrade_coverage.sql > @abs_bindir@/gs_dump_upgrade_coverage.log 2>&1
CHECKPOINT;
-- 6. do complete clean up
\! @abs_bindir@/gsql -d testaes1 -p @portstring@ -c "DROP SCHEMA IF EXISTS upgrade_coverage CASCADE;" >/dev/null 2>&1
\! @abs_bindir@/gsql -d testaes1 -p @portstring@ -c "DROP SCHEMA IF EXISTS binary_upgrade CASCADE;" >/dev/null 2>&1