!2957 修复alter table set schema可修改为系统内部模式的问题

Merge pull request !2957 from Ruixiang Li/master
This commit is contained in:
opengauss-bot
2023-02-24 12:01:58 +00:00
committed by Gitee
4 changed files with 82 additions and 13 deletions

View File

@ -3413,20 +3413,14 @@ void CheckSetNamespace(Oid oldNspOid, Oid nspOid, Oid classid, Oid objid)
ereport(
ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot move objects into or out of TOAST schema")));
/*disallow set into cstore schema*/
if (nspOid == CSTORE_NAMESPACE)
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot move objects into CSTORE schema")));
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_DBEPERF_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")));
/* disallow user to set table into system schema */
if (IsSysSchema(nspOid)) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot move objects into %s schema", get_namespace_name(nspOid))));
}
}
/*

View File

@ -0,0 +1,23 @@
create table t2(a int);
alter table t2 set schema blockchain;
create table t2(a int);
alter table t2 set schema cstore;
create table t2(a int);
alter table t2 set schema db4ai;
create table t2(a int);
alter table t2 set schema dbe_perf;
create table t2(a int);
alter table t2 set schema dbe_pldebugger;
create table t2(a int);
alter table t2 set schema dbe_pldeveloper;
create table t2(a int);
alter table t2 set schema dbe_sql_util;
create table t2(a int);
alter table t2 set schema pkg_service;
create table t2(a int);
alter table t2 set schema snapshot;
create table t2(a int);
alter table t2 set schema sqladvisor;
create table t2(a int);
create schema user_schema;
alter table t2 set schema user_schema;

View File

@ -0,0 +1,53 @@
create table t2(a int);
alter table t2 set schema blockchain;
ERROR: cannot move objects into blockchain schema
create table t2(a int);
--?.*
--?.*
alter table t2 set schema cstore;
ERROR: cannot move objects into cstore schema
create table t2(a int);
--?.*
--?.*
alter table t2 set schema db4ai;
ERROR: cannot move objects into db4ai schema
create table t2(a int);
--?.*
--?.*
alter table t2 set schema dbe_perf;
ERROR: cannot move objects into dbe_perf schema
create table t2(a int);
--?.*
--?.*
alter table t2 set schema dbe_pldebugger;
ERROR: cannot move objects into dbe_pldebugger schema
create table t2(a int);
--?.*
--?.*
alter table t2 set schema dbe_pldeveloper;
ERROR: cannot move objects into dbe_pldeveloper schema
create table t2(a int);
--?.*
--?.*
alter table t2 set schema dbe_sql_util;
ERROR: cannot move objects into dbe_sql_util schema
create table t2(a int);
--?.*
--?.*
alter table t2 set schema pkg_service;
ERROR: cannot move objects into pkg_service schema
create table t2(a int);
--?.*
--?.*
alter table t2 set schema snapshot;
ERROR: cannot move objects into snapshot schema
create table t2(a int);
--?.*
--?.*
alter table t2 set schema sqladvisor;
ERROR: cannot move objects into sqladvisor schema
create table t2(a int);
--?.*
--?.*
create schema user_schema;
alter table t2 set schema user_schema;

View File

@ -1043,9 +1043,8 @@ test: dolphin_guc_config
test: row_count_function
# show_warnings
test: show_warnings
test: show_warnings prevent_table_in_sys_schema
# partition expression key
test: partition_expr_key
test: alter_foreign_schema