diff options
Diffstat (limited to 'src/backend/tcop/utility.c')
| -rw-r--r-- | src/backend/tcop/utility.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 29b4fb527c..26735a5d80 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.65 1999/09/18 19:07:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.66 1999/09/23 17:02:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -206,6 +206,38 @@ ProcessUtility(Node *parsetree, } break; + case T_TruncateStmt: + { + + Relation rel; + + 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); + } + + rel = heap_openr(relname); + if (RelationIsValid(rel)) { + if (rel->rd_rel->relkind == RELKIND_SEQUENCE) { + elog(ERROR, "TRUNCATE cannot be used on sequences. '%s' is a sequence", + relname); + } + heap_close(rel); + } +#ifndef NO_SECURITY + if (!pg_ownercheck(userName, relname, RELNAME)) { + elog(ERROR, "you do not own class \"%s\"", relname); + } +#endif + TruncateRelation(((TruncateStmt *) parsetree)->relName); + + } + break; + case T_CopyStmt: { CopyStmt *stmt = (CopyStmt *) parsetree; |
