diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-09-30 01:12:36 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-09-30 01:12:36 +0000 |
commit | 5fc889fbead0260f814788a8747f674d95f92aa4 (patch) | |
tree | 7ecdbce95e72554daea63a62ad2196a3105298a6 /src | |
parent | 82b1f552399fbfc6e5d1e94d356252e4360369d0 (diff) | |
download | postgresql-5fc889fbead0260f814788a8747f674d95f92aa4.tar.gz postgresql-5fc889fbead0260f814788a8747f674d95f92aa4.zip |
Hmm, guess I forgot to commit this file the other day ...
just some cosmetic changes now, Vadim already fixed the heap_xxx calls.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/tcop/utility.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 18609201169..0b8d1efcdde 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.68 1999/09/29 16:06:11 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.69 1999/09/30 01:12:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -206,35 +206,30 @@ ProcessUtility(Node *parsetree, } break; - case T_TruncateStmt: - { + case T_TruncateStmt: + { + Relation rel; - Relation rel; + PS_SET_STATUS(commandTag = "TRUNCATE"); + CHECK_IF_ABORTED(); - PS_SET_STATUS(commandTag = "TRUNCATE"); - CHECK_IF_ABORTED(); + relname = ((TruncateStmt *) parsetree)->relName; + if (!allowSystemTableMods && IsSystemRelationName(relname)) + elog(ERROR, "TRUNCATE cannot be used on system tables. '%s' is a system table", + relname); - relname = ((TruncateStmt *) parsetree)->relName; - if (!allowSystemTableMods && IsSystemRelationName(relname)) { - elog(ERROR, "TRUNCATE cannot be used on system tables. '%s' is a system table", - relname); - } - - rel = heap_openr(relname, AccessExclusiveLock); - if (RelationIsValid(rel)) { - if (rel->rd_rel->relkind == RELKIND_SEQUENCE) { - elog(ERROR, "TRUNCATE cannot be used on sequences. '%s' is a sequence", - relname); - } + /* Grab exclusive lock in preparation for truncate... */ + rel = heap_openr(relname, AccessExclusiveLock); + if (rel->rd_rel->relkind == RELKIND_SEQUENCE) + elog(ERROR, "TRUNCATE cannot be used on sequences. '%s' is a sequence", + relname); heap_close(rel, NoLock); - } + #ifndef NO_SECURITY - if (!pg_ownercheck(userName, relname, RELNAME)) { - elog(ERROR, "you do not own class \"%s\"", relname); - } + if (!pg_ownercheck(userName, relname, RELNAME)) + elog(ERROR, "you do not own class \"%s\"", relname); #endif - TruncateRelation(((TruncateStmt *) parsetree)->relName); - + TruncateRelation(relname); } break; |