Skip to content

Commit 5fc889f

Browse files
committed
Hmm, guess I forgot to commit this file the other day ...
just some cosmetic changes now, Vadim already fixed the heap_xxx calls.
1 parent 82b1f55 commit 5fc889f

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

src/backend/tcop/utility.c

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* 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 $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -206,35 +206,30 @@ ProcessUtility(Node *parsetree,
206206
}
207207
break;
208208

209-
case T_TruncateStmt:
210-
{
209+
case T_TruncateStmt:
210+
{
211+
Relation rel;
211212

212-
Relation rel;
213+
PS_SET_STATUS(commandTag = "TRUNCATE");
214+
CHECK_IF_ABORTED();
213215

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);
216220

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);
229226
heap_close(rel, NoLock);
230-
}
227+
231228
#ifndef NO_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);
235231
#endif
236-
TruncateRelation(((TruncateStmt *) parsetree)->relName);
237-
232+
TruncateRelation(relname);
238233
}
239234
break;
240235

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy