From 9999f5a10e722c052006886b678995695001958a Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 12 Apr 2002 20:38:31 +0000 Subject: Checking to decide whether relations are system relations now depends on the namespace not the name; pg_ is not a reserved prefix for table names anymore. From Fernando Nasser. --- src/backend/commands/command.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/backend/commands/command.c') diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index c74d24cf7a5..c13b2aa67d4 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.173 2002/04/11 23:20:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.174 2002/04/12 20:38:20 tgl Exp $ * * NOTES * The PerformAddAttribute() code, like most of the relation @@ -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); -- cgit v1.2.3