1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Implement DROP OWNED and REASSIGN OWNED. These new commands facilitate the

process of dropping roles by dropping objects owned by them and privileges
granted to them, or giving the owned objects to someone else, through the
use of the data stored in the new pg_shdepend catalog.

Some refactoring of the GRANT/REVOKE code was needed, as well as ALTER OWNER
code.  Further cleanup of code duplication in the GRANT code seems necessary.

Implemented by me after an idea from Tom Lane, who also provided various kind
of implementation advice.

Regression tests pass.  Some tests for the new functionality are also added,
as well as rudimentary documentation.
This commit is contained in:
Alvaro Herrera
2005-11-21 12:49:33 +00:00
parent c52795d18a
commit cec3b0a9e6
31 changed files with 1532 additions and 377 deletions

View File

@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.318 2005/11/20 23:24:12 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.319 2005/11/21 12:49:31 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@ -2595,6 +2595,27 @@ _copyDeallocateStmt(DeallocateStmt *from)
return newnode;
}
static DropOwnedStmt *
_copyDropOwnedStmt(DropOwnedStmt *from)
{
DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
COPY_NODE_FIELD(roles);
COPY_SCALAR_FIELD(behavior);
return newnode;
}
static ReassignOwnedStmt *
_copyReassignOwnedStmt(ReassignOwnedStmt *from)
{
ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
COPY_NODE_FIELD(roles);
COPY_SCALAR_FIELD(newrole);
return newnode;
}
/* ****************************************************************
* pg_list.h copy functions
@ -3146,6 +3167,12 @@ copyObject(void *from)
case T_DeallocateStmt:
retval = _copyDeallocateStmt(from);
break;
case T_DropOwnedStmt:
retval = _copyDropOwnedStmt(from);
break;
case T_ReassignOwnedStmt:
retval = _copyReassignOwnedStmt(from);
break;
case T_A_Expr:
retval = _copyAExpr(from);

View File

@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.255 2005/11/20 23:24:12 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.256 2005/11/21 12:49:31 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@ -1469,10 +1469,23 @@ _equalDeallocateStmt(DeallocateStmt *a, DeallocateStmt *b)
return true;
}
static bool
_equalDropOwnedStmt(DropOwnedStmt *a, DropOwnedStmt *b)
{
COMPARE_NODE_FIELD(roles);
COMPARE_SCALAR_FIELD(behavior);
/*
* stuff from parsenodes.h
*/
return true;
}
static bool
_equalReassignOwnedStmt(ReassignOwnedStmt *a, ReassignOwnedStmt *b)
{
COMPARE_NODE_FIELD(roles);
COMPARE_NODE_FIELD(newrole);
return true;
}
static bool
_equalAExpr(A_Expr *a, A_Expr *b)
@ -2188,6 +2201,13 @@ equal(void *a, void *b)
case T_DeallocateStmt:
retval = _equalDeallocateStmt(a, b);
break;
case T_DropOwnedStmt:
retval = _equalDropOwnedStmt(a, b);
break;
case T_ReassignOwnedStmt:
retval = _equalReassignOwnedStmt(a, b);
break;
case T_A_Expr:
retval = _equalAExpr(a, b);