mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
Restructure AclItem representation so that we can have more than eight
different privilege bits (might as well make use of the space we were wasting on padding). EXECUTE and USAGE bits for procedures, languages now are separate privileges instead of being overlaid on SELECT. Add privileges for namespaces and databases. The GRANT and REVOKE commands work for these object types, but we don't actually enforce the privileges yet...
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.305 2002/04/18 21:16:16 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.306 2002/04/21 00:26:43 tgl Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -2473,8 +2473,8 @@ RevokeStmt: REVOKE opt_revoke_grant_option privileges ON privilege_target FROM
|
||||
|
||||
/* either ALL [PRIVILEGES] or a list of individual privileges */
|
||||
privileges: privilege_list { $$ = $1; }
|
||||
| ALL { $$ = makeListi1(ALL); }
|
||||
| ALL PRIVILEGES { $$ = makeListi1(ALL); }
|
||||
| ALL { $$ = makeListi1(ACL_ALL_RIGHTS); }
|
||||
| ALL PRIVILEGES { $$ = makeListi1(ACL_ALL_RIGHTS); }
|
||||
;
|
||||
|
||||
privilege_list: privilege { $$ = makeListi1($1); }
|
||||
@@ -2482,16 +2482,20 @@ privilege_list: privilege { $$ = makeListi1($1); }
|
||||
;
|
||||
|
||||
/* Not all of these privilege types apply to all objects, but that
|
||||
gets sorted out later. */
|
||||
privilege: SELECT { $$ = SELECT; }
|
||||
| INSERT { $$ = INSERT; }
|
||||
| UPDATE { $$ = UPDATE; }
|
||||
| DELETE { $$ = DELETE; }
|
||||
| RULE { $$ = RULE; }
|
||||
| REFERENCES { $$ = REFERENCES; }
|
||||
| TRIGGER { $$ = TRIGGER; }
|
||||
| EXECUTE { $$ = EXECUTE; }
|
||||
| USAGE { $$ = USAGE; }
|
||||
* gets sorted out later.
|
||||
*/
|
||||
privilege: SELECT { $$ = ACL_SELECT; }
|
||||
| INSERT { $$ = ACL_INSERT; }
|
||||
| UPDATE { $$ = ACL_UPDATE; }
|
||||
| DELETE { $$ = ACL_DELETE; }
|
||||
| RULE { $$ = ACL_RULE; }
|
||||
| REFERENCES { $$ = ACL_REFERENCES; }
|
||||
| TRIGGER { $$ = ACL_TRIGGER; }
|
||||
| EXECUTE { $$ = ACL_EXECUTE; }
|
||||
| USAGE { $$ = ACL_USAGE; }
|
||||
| CREATE { $$ = ACL_CREATE; }
|
||||
| TEMPORARY { $$ = ACL_CREATE_TEMP; }
|
||||
| TEMP { $$ = ACL_CREATE_TEMP; }
|
||||
;
|
||||
|
||||
|
||||
@@ -2500,28 +2504,42 @@ privilege: SELECT { $$ = SELECT; }
|
||||
privilege_target: qualified_name_list
|
||||
{
|
||||
PrivTarget *n = makeNode(PrivTarget);
|
||||
n->objtype = TABLE;
|
||||
n->objtype = ACL_OBJECT_RELATION;
|
||||
n->objs = $1;
|
||||
$$ = n;
|
||||
}
|
||||
| TABLE qualified_name_list
|
||||
{
|
||||
PrivTarget *n = makeNode(PrivTarget);
|
||||
n->objtype = TABLE;
|
||||
n->objtype = ACL_OBJECT_RELATION;
|
||||
n->objs = $2;
|
||||
$$ = n;
|
||||
}
|
||||
| FUNCTION function_with_argtypes_list
|
||||
{
|
||||
PrivTarget *n = makeNode(PrivTarget);
|
||||
n->objtype = FUNCTION;
|
||||
n->objtype = ACL_OBJECT_FUNCTION;
|
||||
n->objs = $2;
|
||||
$$ = n;
|
||||
}
|
||||
| DATABASE name_list
|
||||
{
|
||||
PrivTarget *n = makeNode(PrivTarget);
|
||||
n->objtype = ACL_OBJECT_DATABASE;
|
||||
n->objs = $2;
|
||||
$$ = n;
|
||||
}
|
||||
| LANGUAGE name_list
|
||||
{
|
||||
PrivTarget *n = makeNode(PrivTarget);
|
||||
n->objtype = LANGUAGE;
|
||||
n->objtype = ACL_OBJECT_LANGUAGE;
|
||||
n->objs = $2;
|
||||
$$ = n;
|
||||
}
|
||||
| SCHEMA name_list
|
||||
{
|
||||
PrivTarget *n = makeNode(PrivTarget);
|
||||
n->objtype = ACL_OBJECT_NAMESPACE;
|
||||
n->objs = $2;
|
||||
$$ = n;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.105 2002/04/18 21:16:16 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.106 2002/04/21 00:26:43 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -356,36 +356,3 @@ ScanKeywordLookup(char *text)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This does the reverse mapping from token number to string.
|
||||
*/
|
||||
const char *
|
||||
TokenString(int token)
|
||||
{
|
||||
int i = 0;
|
||||
static char buf[NAMEDATALEN];
|
||||
|
||||
while (i < sizeof(ScanKeywords))
|
||||
{
|
||||
if (ScanKeywords[i].value == token)
|
||||
{
|
||||
int k;
|
||||
|
||||
/* uppercase */
|
||||
for (k = 0; k < NAMEDATALEN; k++)
|
||||
if (ScanKeywords[i].name[k] >= 'a'
|
||||
&& ScanKeywords[i].name[k] <= 'z')
|
||||
buf[k] = ScanKeywords[i].name[k] + ('A' - 'a');
|
||||
else
|
||||
buf[k] = ScanKeywords[i].name[k];
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user