|
9 | 9 | * |
10 | 10 | * |
11 | 11 | * IDENTIFICATION |
12 | | - * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.68 1999/09/29 16:06:11 wieck Exp $ |
| 12 | + * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.69 1999/09/30 01:12:36 tgl Exp $ |
13 | 13 | * |
14 | 14 | *------------------------------------------------------------------------- |
15 | 15 | */ |
@@ -206,35 +206,30 @@ ProcessUtility(Node *parsetree, |
206 | 206 | } |
207 | 207 | break; |
208 | 208 |
|
209 | | -caseT_TruncateStmt: |
210 | | - { |
| 209 | +caseT_TruncateStmt: |
| 210 | +{ |
| 211 | +Relationrel; |
211 | 212 |
|
212 | | -Relationrel; |
| 213 | +PS_SET_STATUS(commandTag="TRUNCATE"); |
| 214 | +CHECK_IF_ABORTED(); |
213 | 215 |
|
214 | | -PS_SET_STATUS(commandTag="TRUNCATE"); |
215 | | -CHECK_IF_ABORTED(); |
| 216 | +relname= ((TruncateStmt*)parsetree)->relName; |
| 217 | +if (!allowSystemTableMods&&IsSystemRelationName(relname)) |
| 218 | +elog(ERROR,"TRUNCATE cannot be used on system tables. '%s' is a system table", |
| 219 | +relname); |
216 | 220 |
|
217 | | -relname= ((TruncateStmt*)parsetree)->relName; |
218 | | -if (!allowSystemTableMods&&IsSystemRelationName(relname)) { |
219 | | -elog(ERROR,"TRUNCATE cannot be used on system tables. '%s' is a system table", |
220 | | -relname); |
221 | | - } |
222 | | - |
223 | | -rel=heap_openr(relname,AccessExclusiveLock); |
224 | | -if (RelationIsValid(rel)) { |
225 | | -if (rel->rd_rel->relkind==RELKIND_SEQUENCE) { |
226 | | -elog(ERROR,"TRUNCATE cannot be used on sequences. '%s' is a sequence", |
227 | | -relname); |
228 | | - } |
| 221 | +/* Grab exclusive lock in preparation for truncate... */ |
| 222 | +rel=heap_openr(relname,AccessExclusiveLock); |
| 223 | +if (rel->rd_rel->relkind==RELKIND_SEQUENCE) |
| 224 | +elog(ERROR,"TRUNCATE cannot be used on sequences. '%s' is a sequence", |
| 225 | +relname); |
229 | 226 | heap_close(rel,NoLock); |
230 | | - } |
| 227 | + |
231 | 228 | #ifndefNO_SECURITY |
232 | | -if (!pg_ownercheck(userName,relname,RELNAME)) { |
233 | | -elog(ERROR,"you do not own class \"%s\"",relname); |
234 | | - } |
| 229 | +if (!pg_ownercheck(userName,relname,RELNAME)) |
| 230 | +elog(ERROR,"you do not own class \"%s\"",relname); |
235 | 231 | #endif |
236 | | -TruncateRelation(((TruncateStmt*)parsetree)->relName); |
237 | | - |
| 232 | +TruncateRelation(relname); |
238 | 233 | } |
239 | 234 | break; |
240 | 235 |
|
|