summaryrefslogtreecommitdiff
path: root/src/backend/commands/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/command.c')
-rw-r--r--src/backend/commands/command.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index 23e8248ba6..b4a7af3977 100644
--- a/src/backend/commands/command.c
+++ b/src/backend/commands/command.c
@@ -346,7 +346,7 @@ AlterTableAddColumn(Oid myrelid,
* normally, only the owner of a class can change its schema.
*/
if (!allowSystemTableMods
- && IsSystemRelationName(RelationGetRelationName(rel)))
+ && IsSystemRelation(rel))
elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
RelationGetRelationName(rel));
if (!pg_class_ownercheck(myrelid, GetUserId()))
@@ -548,7 +548,7 @@ AlterTableAlterColumnDropNotNull(Oid myrelid,
RelationGetRelationName(rel));
if (!allowSystemTableMods
- && IsSystemRelationName(RelationGetRelationName(rel)))
+ && IsSystemRelation(rel))
elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
RelationGetRelationName(rel));
@@ -699,7 +699,7 @@ AlterTableAlterColumnSetNotNull(Oid myrelid,
RelationGetRelationName(rel));
if (!allowSystemTableMods
- && IsSystemRelationName(RelationGetRelationName(rel)))
+ && IsSystemRelation(rel))
elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
RelationGetRelationName(rel));
@@ -829,7 +829,7 @@ AlterTableAlterColumnDefault(Oid myrelid,
RelationGetRelationName(rel));
if (!allowSystemTableMods
- && IsSystemRelationName(RelationGetRelationName(rel)))
+ && IsSystemRelation(rel))
elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
RelationGetRelationName(rel));
@@ -970,8 +970,8 @@ drop_default(Oid relid, int16 attnum)
*/
void
AlterTableAlterColumnFlags(Oid myrelid,
- bool inh, const char *colName,
- Node *flagValue, const char *flagType)
+ bool inh, const char *colName,
+ Node *flagValue, const char *flagType)
{
Relation rel;
int newtarget = 1;
@@ -989,9 +989,7 @@ AlterTableAlterColumnFlags(Oid myrelid,
/*
* we allow statistics case for system tables
*/
- if (*flagType != 'S' &&
- !allowSystemTableMods
- && IsSystemRelationName(RelationGetRelationName(rel)))
+ if (*flagType != 'S' && !allowSystemTableMods && IsSystemRelation(rel))
elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
RelationGetRelationName(rel));
@@ -1150,7 +1148,7 @@ AlterTableAddConstraint(Oid myrelid,
RelationGetRelationName(rel));
if (!allowSystemTableMods
- && IsSystemRelationName(RelationGetRelationName(rel)))
+ && IsSystemRelation(rel))
elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
RelationGetRelationName(rel));
@@ -1476,7 +1474,7 @@ AlterTableDropConstraint(Oid myrelid,
RelationGetRelationName(rel));
if (!allowSystemTableMods
- && IsSystemRelationName(RelationGetRelationName(rel)))
+ && IsSystemRelation(rel))
elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
RelationGetRelationName(rel));
@@ -1952,6 +1950,10 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
owner_name, authId);
}
+ if (!allowSystemTableMods && IsReservedName(schemaName))
+ elog(ERROR, "CREATE SCHEMA: Illegal schema name: \"%s\" -- pg_ is reserved for system schemas",
+ schemaName);
+
/* Create the schema's namespace */
NamespaceCreate(schemaName, owner_userid);