diff --git a/src/gausskernel/optimizer/commands/schemacmds.cpp b/src/gausskernel/optimizer/commands/schemacmds.cpp index fff6f66d3..3b1bb221e 100755 --- a/src/gausskernel/optimizer/commands/schemacmds.cpp +++ b/src/gausskernel/optimizer/commands/schemacmds.cpp @@ -141,7 +141,10 @@ void CreateSchemaCommand(CreateSchemaStmt* stmt, const char* queryString) //@Temp Table. We allow datanode to create pg_temp namespace to enable create namespace stmt by CN to execute on // DN if (!g_instance.attr.attr_common.allowSystemTableMods && !u_sess->attr.attr_common.IsInplaceUpgrade && - IsReservedName(schemaName) && !IS_PGXC_DATANODE) +#ifdef ENABLE_MULTIPLE_NODES + !IS_PGXC_DATANODE && +#endif + IsReservedName(schemaName)) ereport(ERROR, (errcode(ERRCODE_RESERVED_NAME), errmsg("unacceptable schema name \"%s\"", schemaName), diff --git a/src/test/regress/expected/create_schema.out b/src/test/regress/expected/create_schema.out index 260c27c31..c6bb2acce 100644 --- a/src/test/regress/expected/create_schema.out +++ b/src/test/regress/expected/create_schema.out @@ -17,6 +17,14 @@ create table abc( b int ); NOTICE: CREATE TABLE will create implicit sequence "abc_a_seq" for serial column "abc.a" +--illegal schema name, start with 'pg_' +create schema pg_error_schema; +ERROR: unacceptable schema name "pg_error_schema" +DETAIL: The prefix "pg_" is reserved for system schemas. +--create user will create a schema which name is same as username, so it is also illegal. +create user pg_error_username password 'test-1234'; +ERROR: unacceptable user name: fail to create same name schema for user "pg_error_username" +DETAIL: The prefix "pg_" is reserved for system schemas. drop role samedb_schema_cn_role_02_001; drop schema test_ns_schema_1 cascade; NOTICE: drop cascades to 2 other objects diff --git a/src/test/regress/sql/create_schema.sql b/src/test/regress/sql/create_schema.sql index 8859582d8..33a8b3170 100644 --- a/src/test/regress/sql/create_schema.sql +++ b/src/test/regress/sql/create_schema.sql @@ -24,6 +24,11 @@ create table abc( b int ); +--illegal schema name, start with 'pg_' +create schema pg_error_schema; +--create user will create a schema which name is same as username, so it is also illegal. +create user pg_error_username password 'test-1234'; + drop role samedb_schema_cn_role_02_001; drop schema test_ns_schema_1 cascade;