mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Support column-level privileges, as required by SQL standard.
Stephen Frost, with help from KaiGai Kohei and others
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.420 2009/01/16 13:27:23 heikki Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.421 2009/01/22 20:16:03 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1740,6 +1740,8 @@ _copyRangeTblEntry(RangeTblEntry *from)
|
||||
COPY_SCALAR_FIELD(inFromCl);
|
||||
COPY_SCALAR_FIELD(requiredPerms);
|
||||
COPY_SCALAR_FIELD(checkAsUser);
|
||||
COPY_BITMAPSET_FIELD(selectedCols);
|
||||
COPY_BITMAPSET_FIELD(modifiedCols);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@ -2342,6 +2344,17 @@ _copyFuncWithArgs(FuncWithArgs *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static AccessPriv *
|
||||
_copyAccessPriv(AccessPriv *from)
|
||||
{
|
||||
AccessPriv *newnode = makeNode(AccessPriv);
|
||||
|
||||
COPY_STRING_FIELD(priv_name);
|
||||
COPY_NODE_FIELD(cols);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static GrantRoleStmt *
|
||||
_copyGrantRoleStmt(GrantRoleStmt *from)
|
||||
{
|
||||
@ -4096,6 +4109,9 @@ copyObject(void *from)
|
||||
case T_FuncWithArgs:
|
||||
retval = _copyFuncWithArgs(from);
|
||||
break;
|
||||
case T_AccessPriv:
|
||||
retval = _copyAccessPriv(from);
|
||||
break;
|
||||
case T_XmlSerialize:
|
||||
retval = _copyXmlSerialize(from);
|
||||
break;
|
||||
|
@ -22,7 +22,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.345 2009/01/16 13:27:23 heikki Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.346 2009/01/22 20:16:03 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1013,6 +1013,15 @@ _equalFuncWithArgs(FuncWithArgs *a, FuncWithArgs *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalAccessPriv(AccessPriv *a, AccessPriv *b)
|
||||
{
|
||||
COMPARE_STRING_FIELD(priv_name);
|
||||
COMPARE_NODE_FIELD(cols);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalGrantRoleStmt(GrantRoleStmt *a, GrantRoleStmt *b)
|
||||
{
|
||||
@ -2122,6 +2131,8 @@ _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
|
||||
COMPARE_SCALAR_FIELD(inFromCl);
|
||||
COMPARE_SCALAR_FIELD(requiredPerms);
|
||||
COMPARE_SCALAR_FIELD(checkAsUser);
|
||||
COMPARE_BITMAPSET_FIELD(selectedCols);
|
||||
COMPARE_BITMAPSET_FIELD(modifiedCols);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2874,6 +2885,9 @@ equal(void *a, void *b)
|
||||
case T_FuncWithArgs:
|
||||
retval = _equalFuncWithArgs(a, b);
|
||||
break;
|
||||
case T_AccessPriv:
|
||||
retval = _equalAccessPriv(a, b);
|
||||
break;
|
||||
case T_XmlSerialize:
|
||||
retval = _equalXmlSerialize(a, b);
|
||||
break;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.349 2009/01/01 17:23:43 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.350 2009/01/22 20:16:04 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every node type that can appear in stored rules' parsetrees *must*
|
||||
@ -180,8 +180,6 @@ _outList(StringInfo str, List *node)
|
||||
* converts a bitmap set of integers
|
||||
*
|
||||
* Note: the output format is "(b int int ...)", similar to an integer List.
|
||||
* Currently bitmapsets do not appear in any node type that is stored in
|
||||
* rules, so there is no support in readfuncs.c for reading this format.
|
||||
*/
|
||||
static void
|
||||
_outBitmapset(StringInfo str, Bitmapset *bms)
|
||||
@ -2060,6 +2058,8 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
|
||||
WRITE_BOOL_FIELD(inFromCl);
|
||||
WRITE_UINT_FIELD(requiredPerms);
|
||||
WRITE_OID_FIELD(checkAsUser);
|
||||
WRITE_BITMAPSET_FIELD(selectedCols);
|
||||
WRITE_BITMAPSET_FIELD(modifiedCols);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.220 2009/01/01 17:23:43 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.221 2009/01/22 20:16:04 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Path and Plan nodes do not have any readfuncs support, because we
|
||||
@ -114,6 +114,11 @@
|
||||
token = pg_strtok(&length); /* skip :fldname */ \
|
||||
local_node->fldname = nodeRead(NULL, 0)
|
||||
|
||||
/* Read a bitmapset field */
|
||||
#define READ_BITMAPSET_FIELD(fldname) \
|
||||
token = pg_strtok(&length); /* skip :fldname */ \
|
||||
local_node->fldname = _readBitmapset()
|
||||
|
||||
/* Routine exit */
|
||||
#define READ_DONE() \
|
||||
return local_node
|
||||
@ -137,6 +142,46 @@
|
||||
|
||||
static Datum readDatum(bool typbyval);
|
||||
|
||||
/*
|
||||
* _readBitmapset
|
||||
*/
|
||||
static Bitmapset *
|
||||
_readBitmapset(void)
|
||||
{
|
||||
Bitmapset *result = NULL;
|
||||
READ_TEMP_LOCALS();
|
||||
|
||||
token = pg_strtok(&length);
|
||||
if (token == NULL)
|
||||
elog(ERROR, "incomplete Bitmapset structure");
|
||||
if (length != 1 || token[0] != '(')
|
||||
elog(ERROR, "unrecognized token: \"%.*s\"", length, token);
|
||||
|
||||
token = pg_strtok(&length);
|
||||
if (token == NULL)
|
||||
elog(ERROR, "incomplete Bitmapset structure");
|
||||
if (length != 1 || token[0] != 'b')
|
||||
elog(ERROR, "unrecognized token: \"%.*s\"", length, token);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int val;
|
||||
char *endptr;
|
||||
|
||||
token = pg_strtok(&length);
|
||||
if (token == NULL)
|
||||
elog(ERROR, "unterminated Bitmapset structure");
|
||||
if (length == 1 && token[0] == ')')
|
||||
break;
|
||||
val = (int) strtol(token, &endptr, 10);
|
||||
if (endptr != token + length)
|
||||
elog(ERROR, "unrecognized integer: \"%.*s\"", length, token);
|
||||
result = bms_add_member(result, val);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* _readQuery
|
||||
@ -1102,6 +1147,8 @@ _readRangeTblEntry(void)
|
||||
READ_BOOL_FIELD(inFromCl);
|
||||
READ_UINT_FIELD(requiredPerms);
|
||||
READ_OID_FIELD(checkAsUser);
|
||||
READ_BITMAPSET_FIELD(selectedCols);
|
||||
READ_BITMAPSET_FIELD(modifiedCols);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
|
Reference in New Issue
Block a user