From 8ac25633517d05deaff6ffc918cb72f2bf68aa3e Mon Sep 17 00:00:00 2001 From: xue_meng_en <1836611252@qq.com> Date: Mon, 28 Dec 2020 18:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E7=94=A8=E6=88=B7=E5=90=91?= =?UTF-8?q?=E5=86=85=E9=83=A8=E6=A8=A1=E5=BC=8F=E6=B7=BB=E5=8A=A0=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/catalog/namespace.cpp | 8 +++ .../input/disable_dbeperf_and_snapshot.source | 24 ++++++++ .../disable_dbeperf_and_snapshot.source | 55 +++++++++++++++++++ src/test/regress/parallel_schedule10 | 4 +- 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/test/regress/input/disable_dbeperf_and_snapshot.source create mode 100644 src/test/regress/output/disable_dbeperf_and_snapshot.source diff --git a/src/common/backend/catalog/namespace.cpp b/src/common/backend/catalog/namespace.cpp index c4bc7a418..a6c5ab1a2 100755 --- a/src/common/backend/catalog/namespace.cpp +++ b/src/common/backend/catalog/namespace.cpp @@ -2700,6 +2700,14 @@ void CheckSetNamespace(Oid oldNspOid, Oid nspOid, Oid classid, Oid objid) if (nspOid == PG_CATALOG_NAMESPACE) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot move objects into system schema"))); + + /* disallow set into dbe_perf schema */ + if (nspOid == PG_DBMSPERF_NAMESPACE) + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot move objects into dbe_perf schema"))); + + /* disallow set into snapshot schema */ + if (nspOid == PG_SNAPSHOT_NAMESPACE) + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot move objects into snapshot schema"))); } /* diff --git a/src/test/regress/input/disable_dbeperf_and_snapshot.source b/src/test/regress/input/disable_dbeperf_and_snapshot.source new file mode 100644 index 000000000..f7e1608fc --- /dev/null +++ b/src/test/regress/input/disable_dbeperf_and_snapshot.source @@ -0,0 +1,24 @@ +--- +-- disable dbe_perf and snapshot +--- +-- 1. Test whether the administrator has dbe_perf and snapshot schema permissions +create table t1(col int); +alter table t1 set schema dbe_perf; +alter table t1 set schema snapshot; +-- 2. Test whether the wdr snapshot is generated properly +\c postgres +alter system set enable_wdr_snapshot to on; +\! sleep 15s +show enable_wdr_snapshot ; +select create_wdr_snapshot(); +\! sleep 15s +select create_wdr_snapshot(); +\! sleep 15s +select create_wdr_snapshot(); +\! sleep 15s +select snapshot_id from snapshot.snapshot limit 4; +\! mkdir @abs_srcdir@/temp +\a \t \o @abs_srcdir@/temp/wdrTestNode.html +\! test -f @abs_srcdir@/temp/wdrTestNode.html && echo "found" || echo "not found" +\o \a \t +\! rm @abs_srcdir@/temp -rf \ No newline at end of file diff --git a/src/test/regress/output/disable_dbeperf_and_snapshot.source b/src/test/regress/output/disable_dbeperf_and_snapshot.source new file mode 100644 index 000000000..0a5f1ec19 --- /dev/null +++ b/src/test/regress/output/disable_dbeperf_and_snapshot.source @@ -0,0 +1,55 @@ +--- +-- disable dbe_perf and snapshot +--- +-- 1. Test whether the administrator has dbe_perf and snapshot schema permissions +create table t1(col int); +alter table t1 set schema dbe_perf; +ERROR: cannot move objects into dbe_perf schema +alter table t1 set schema snapshot; +ERROR: cannot move objects into snapshot schema +-- 2. Test whether the wdr snapshot is generated properly +\c postgres +alter system set enable_wdr_snapshot to on; +\! sleep 15s +show enable_wdr_snapshot ; + enable_wdr_snapshot +--------------------- + on +(1 row) + +select create_wdr_snapshot(); + create_wdr_snapshot +----------------------------------------- + WDR snapshot request has been submitted +(1 row) + +\! sleep 15s +select create_wdr_snapshot(); + create_wdr_snapshot +----------------------------------------- + WDR snapshot request has been submitted +(1 row) + +\! sleep 15s +select create_wdr_snapshot(); + create_wdr_snapshot +----------------------------------------- + WDR snapshot request has been submitted +(1 row) + +\! sleep 15s +select snapshot_id from snapshot.snapshot limit 4; + snapshot_id +------------- + 1 + 2 + 3 + 4 +(4 rows) + +\! mkdir /data/archclean/openGauss-server/src/test/regress/temp +\a \t \o /data/archclean/openGauss-server/src/test/regress/temp/wdrTestNode.html +\! test -f /data/archclean/openGauss-server/src/test/regress/temp/wdrTestNode.html && echo "found" || echo "not found" +found +\o \a \t +\! rm /data/archclean/openGauss-server/src/test/regress/temp -rf \ No newline at end of file diff --git a/src/test/regress/parallel_schedule10 b/src/test/regress/parallel_schedule10 index 352ab5566..4829f7691 100644 --- a/src/test/regress/parallel_schedule10 +++ b/src/test/regress/parallel_schedule10 @@ -86,4 +86,6 @@ test: synchronous_commit_test test: alter_set_same_parameter test: gs_guc_value_range test: global_temporary_table_get_table_def -test: double_support_unit \ No newline at end of file +test: double_support_unit + +test: disable_dbeperf_and_snapshot \ No newline at end of file