From e93cfc267b02b39a872665432134e74113d731c0 Mon Sep 17 00:00:00 2001 From: wangpingyun <2418191738@qq.com> Date: Thu, 5 Dec 2024 10:43:15 +0800 Subject: [PATCH] =?UTF-8?q?gs=5Fdump=E6=B7=BB=E5=8A=A0=E5=8F=AF=E9=80=89?= =?UTF-8?q?=E5=8F=82=E6=95=B0--force-clean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/dolphin/input/dump_force_clean.source | 41 +++++++++++ .../dolphin/output/dump_force_clean.source | 72 +++++++++++++++++++ contrib/dolphin/parallel_schedule_dolphinA | 2 +- 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 contrib/dolphin/input/dump_force_clean.source create mode 100644 contrib/dolphin/output/dump_force_clean.source diff --git a/contrib/dolphin/input/dump_force_clean.source b/contrib/dolphin/input/dump_force_clean.source new file mode 100644 index 000000000..c252ce6af --- /dev/null +++ b/contrib/dolphin/input/dump_force_clean.source @@ -0,0 +1,41 @@ +create database aaa dbcompatibility 'B'; +\c aaa +create schema envision01; +set search_path to envision01; +CREATE TABLE IF NOT EXISTS yx_channel ( + yx_id bigint NOT NULL, + channel tinyint unsigned NOT NULL, + raw_data tinyint unsigned DEFAULT NULL, + q bigint DEFAULT NULL, + ld_alias varchar(64) DEFAULT NULL, + order_no smallint DEFAULT '-1', + gin bigint DEFAULT NULL, + source_mode tinyint unsigned DEFAULT NULL, + change_time bigint DEFAULT '0', + PRIMARY KEY (yx_id, channel), + KEY i_yx_channel_1 (ld_alias, channel, order_no) +); +CREATE or replace FUNCTION "ti_yx_channel_trigger_function"() RETURNS "trigger" + LANGUAGE "plpgsql" NOT SHIPPABLE +AS $$ +DECLARE + num1 INTEGER; +BEGIN + IF NEW.ld_alias IS NOT NULL AND NEW.order_no >= 0 THEN + SELECT COUNT(*) INTO num1 FROM yx_channel + WHERE channel = NEW.channel AND ld_alias = NEW.ld_alias AND order_no = NEW.order_no ; + IF num1 > 0 THEN + END IF ; + END IF ; + RETURN NEW; +END$$; +CREATE TRIGGER "ti_yx_channel" BEFORE INSERT ON "yx_channel" FOR EACH ROW EXECUTE PROCEDURE "ti_yx_channel_trigger_function"(); + +\! @abs_bindir@/gs_dump -p @portstring@ -E=utf8 -n envision01 -c --force-clean aaa -f before_clean.sql >/dev/null; +create table t1(aaa int); +\! @abs_bindir@/gsql -daaa -p @portstring@ -f "before_clean.sql"; + +\! @abs_bindir@/gs_dump -p @portstring@ -s -E=utf8 -n envision01 --force-clean aaa -f before_clean.sql; +\c postgres +drop database aaa; +reset search_path; \ No newline at end of file diff --git a/contrib/dolphin/output/dump_force_clean.source b/contrib/dolphin/output/dump_force_clean.source new file mode 100644 index 000000000..2a98d5fff --- /dev/null +++ b/contrib/dolphin/output/dump_force_clean.source @@ -0,0 +1,72 @@ +create database aaa dbcompatibility 'B'; +\c aaa +create schema envision01; +set search_path to envision01; +CREATE TABLE IF NOT EXISTS yx_channel ( + yx_id bigint NOT NULL, + channel tinyint unsigned NOT NULL, + raw_data tinyint unsigned DEFAULT NULL, + q bigint DEFAULT NULL, + ld_alias varchar(64) DEFAULT NULL, + order_no smallint DEFAULT '-1', + gin bigint DEFAULT NULL, + source_mode tinyint unsigned DEFAULT NULL, + change_time bigint DEFAULT '0', + PRIMARY KEY (yx_id, channel), + KEY i_yx_channel_1 (ld_alias, channel, order_no) +); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "yx_channel_pkey" for table "yx_channel" +CREATE or replace FUNCTION "ti_yx_channel_trigger_function"() RETURNS "trigger" + LANGUAGE "plpgsql" NOT SHIPPABLE +AS $$ +DECLARE + num1 INTEGER; +BEGIN + IF NEW.ld_alias IS NOT NULL AND NEW.order_no >= 0 THEN + SELECT COUNT(*) INTO num1 FROM yx_channel + WHERE channel = NEW.channel AND ld_alias = NEW.ld_alias AND order_no = NEW.order_no ; + IF num1 > 0 THEN + END IF ; + END IF ; + RETURN NEW; +END$$; +CREATE TRIGGER "ti_yx_channel" BEFORE INSERT ON "yx_channel" FOR EACH ROW EXECUTE PROCEDURE "ti_yx_channel_trigger_function"(); +\! @abs_bindir@/gs_dump -p @portstring@ -E=utf8 -n envision01 -c --force-clean aaa -f before_clean.sql >/dev/null; +create table t1(aaa int); +\! @abs_bindir@/gsql -daaa -p @portstring@ -f "before_clean.sql"; +SET +SET +SET +SET +SET +SET +SET +SET +SET +SET +DROP TRIGGER +DROP INDEX +ALTER TABLE +DROP TABLE +DROP FUNCTION +DROP SCHEMA +SET +SET +CREATE SCHEMA +ALTER SCHEMA +SET +CREATE FUNCTION +ALTER FUNCTION +SET +SET +CREATE TABLE +ALTER TABLE +ALTER TABLE +CREATE INDEX +CREATE TRIGGER +--?.* +\! @abs_bindir@/gs_dump -p @portstring@ -s -E=utf8 -n envision01 --force-clean aaa -f before_clean.sql; +gs_dump: options --force-clean should be used with -c option. +\c postgres +drop database aaa; +reset search_path; diff --git a/contrib/dolphin/parallel_schedule_dolphinA b/contrib/dolphin/parallel_schedule_dolphinA index 04b42b603..02c7c10d4 100644 --- a/contrib/dolphin/parallel_schedule_dolphinA +++ b/contrib/dolphin/parallel_schedule_dolphinA @@ -79,7 +79,7 @@ test: partition_test1 partition_test2 partition_test3 partition_test4 partition_ test: builtin_funcs/b_compatibility_time_funcs builtin_funcs/b_compatibility_time_funcs2 builtin_funcs/b_compatibility_time_funcs3 builtin_funcs/repeat builtin_funcs/b_compatibility_time_funcs_year -test: test_show_status pad_char_to_full_length dump_dumpall_test timestamp_test test_mediumtext ai dump_ddl +test: test_show_status pad_char_to_full_length dump_dumpall_test timestamp_test test_mediumtext ai dump_ddl dump_force_clean test: b_auth_8_0 ignore_keyword_list test_show_slave_status recursive autoinc_sql_mode -- Gitee