summaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-09-08 00:47:41 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-09-08 00:47:41 +0000
commita0b76dc662efde6e02921c2d16e06418483b7534 (patch)
tree2f3038d0791a79d2230fca027ac73b5fd64f03c8 /src/backend/commands/tablecmds.c
parenta26c7e3d71d65381bc60b0d0b30f03cd738fb0e9 (diff)
downloadpostgresql-a0b76dc662efde6e02921c2d16e06418483b7534.tar.gz
Create a separate grantable privilege for TRUNCATE, rather than having it be
always owner-only. The TRUNCATE privilege works identically to the DELETE privilege so far as interactions with the rest of the system go. Robert Haas
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 8b7b101595..62aeb2f3e6 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.265 2008/09/01 20:42:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.266 2008/09/08 00:47:40 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -989,6 +989,8 @@ ExecuteTruncate(TruncateStmt *stmt)
static void
truncate_check_rel(Relation rel)
{
+ AclResult aclresult;
+
/* Only allow truncate on regular tables */
if (rel->rd_rel->relkind != RELKIND_RELATION)
ereport(ERROR,
@@ -997,8 +999,10 @@ truncate_check_rel(Relation rel)
RelationGetRelationName(rel))));
/* Permissions checks */
- if (!pg_class_ownercheck(RelationGetRelid(rel), GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,
+ aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
+ ACL_TRUNCATE);
+ if (aclresult != ACLCHECK_OK)
+ aclcheck_error(aclresult, ACL_KIND_CLASS,
RelationGetRelationName(rel));
if (!allowSystemTableMods && IsSystemRelation(rel))