Commit 5fc889fb authored by Tom Lane's avatar Tom Lane

Hmm, guess I forgot to commit this file the other day ...

just some cosmetic changes now, Vadim already fixed the heap_xxx calls.
parent 82b1f552
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -208,33 +208,28 @@ ProcessUtility(Node *parsetree, ...@@ -208,33 +208,28 @@ ProcessUtility(Node *parsetree,
case T_TruncateStmt: case T_TruncateStmt:
{ {
Relation rel; Relation rel;
PS_SET_STATUS(commandTag = "TRUNCATE"); PS_SET_STATUS(commandTag = "TRUNCATE");
CHECK_IF_ABORTED(); CHECK_IF_ABORTED();
relname = ((TruncateStmt *) parsetree)->relName; relname = ((TruncateStmt *) parsetree)->relName;
if (!allowSystemTableMods && IsSystemRelationName(relname)) { if (!allowSystemTableMods && IsSystemRelationName(relname))
elog(ERROR, "TRUNCATE cannot be used on system tables. '%s' is a system table", elog(ERROR, "TRUNCATE cannot be used on system tables. '%s' is a system table",
relname); relname);
}
/* Grab exclusive lock in preparation for truncate... */
rel = heap_openr(relname, AccessExclusiveLock); rel = heap_openr(relname, AccessExclusiveLock);
if (RelationIsValid(rel)) { if (rel->rd_rel->relkind == RELKIND_SEQUENCE)
if (rel->rd_rel->relkind == RELKIND_SEQUENCE) {
elog(ERROR, "TRUNCATE cannot be used on sequences. '%s' is a sequence", elog(ERROR, "TRUNCATE cannot be used on sequences. '%s' is a sequence",
relname); relname);
}
heap_close(rel, NoLock); heap_close(rel, NoLock);
}
#ifndef NO_SECURITY #ifndef NO_SECURITY
if (!pg_ownercheck(userName, relname, RELNAME)) { if (!pg_ownercheck(userName, relname, RELNAME))
elog(ERROR, "you do not own class \"%s\"", relname); elog(ERROR, "you do not own class \"%s\"", relname);
}
#endif #endif
TruncateRelation(((TruncateStmt *) parsetree)->relName); TruncateRelation(relname);
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment