summaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorTom Lane2002-04-21 00:26:44 +0000
committerTom Lane2002-04-21 00:26:44 +0000
commitb0bcf8aab2da6710ff8842b86fed93571e143cc8 (patch)
tree922f5b76b34a555d1a30003f216dd5df1aa3663c /src/backend/parser
parentad201b8d18b19d8c7a4a458e078bb555fcc2de74 (diff)
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...
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/gram.y52
-rw-r--r--src/backend/parser/keywords.c35
2 files changed, 36 insertions, 51 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 1f03ce42dbe..9ee7a66a421 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -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;
}
diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c
index ab08ae04f7e..eee0e1b9b2e 100644
--- a/src/backend/parser/keywords.c
+++ b/src/backend/parser/keywords.c
@@ -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;
-}