per previous discussion.
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.95 2002/04/04 04:25:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.96 2002/04/18 21:16:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
datum = heap_getattr(tuple, Anum_pg_group_groname, dsc, &isnull);
if (isnull)
continue; /* ignore NULL groupnames */
- groname = (char *) DatumGetName(datum);
+ groname = NameStr(*DatumGetName(datum));
grolist_datum = heap_getattr(tuple, Anum_pg_group_grolist, dsc, &isnull);
/* Ignore NULL group lists */
datum = heap_getattr(tuple, Anum_pg_shadow_usename, dsc, &isnull);
if (isnull)
continue; /* ignore NULL usernames */
- usename = (char *) DatumGetName(datum);
+ usename = NameStr(*DatumGetName(datum));
datum = heap_getattr(tuple, Anum_pg_shadow_passwd, dsc, &isnull);
if (!superuser())
elog(ERROR, "CREATE USER: permission denied");
+ if (strcmp(stmt->user, "public") == 0)
+ elog(ERROR, "CREATE USER: user name \"%s\" is reserved",
+ stmt->user);
+
/*
* Scan the pg_shadow relation to be certain the user or id doesn't
* already exist. Note we secure exclusive lock, because we also need
datum = heap_getattr(tuple, Anum_pg_shadow_usename,
pg_shadow_dsc, &null);
Assert(!null);
- user_exists = (strcmp((char *) DatumGetName(datum), stmt->user) == 0);
+ user_exists = (strcmp(NameStr(*DatumGetName(datum)), stmt->user) == 0);
datum = heap_getattr(tuple, Anum_pg_shadow_usesysid,
pg_shadow_dsc, &null);
datum = heap_getattr(tmp_tuple, Anum_pg_database_datname,
pg_dsc, &null);
Assert(!null);
- dbname = (char *) DatumGetName(datum);
+ dbname = NameStr(*DatumGetName(datum));
elog(ERROR, "DROP USER: user \"%s\" owns database \"%s\", cannot be removed%s",
user, dbname,
(length(stmt->users) > 1) ? " (no users removed)" : "");
if (!superuser())
elog(ERROR, "CREATE GROUP: permission denied");
+ if (strcmp(stmt->name, "public") == 0)
+ elog(ERROR, "CREATE GROUP: group name \"%s\" is reserved",
+ stmt->name);
+
pg_group_rel = heap_openr(GroupRelationName, ExclusiveLock);
pg_group_dsc = RelationGetDescr(pg_group_rel);
datum = heap_getattr(tuple, Anum_pg_group_groname,
pg_group_dsc, &null);
Assert(!null);
- group_exists = (strcmp((char *) DatumGetName(datum), stmt->name) == 0);
+ group_exists = (strcmp(NameStr(*DatumGetName(datum)), stmt->name) == 0);
datum = heap_getattr(tuple, Anum_pg_group_grosysid,
pg_group_dsc, &null);
datum = heap_getattr(tuple, Anum_pg_group_groname,
pg_group_dsc, &null);
- if (!null && strcmp((char *) DatumGetName(datum), stmt->name) == 0)
+ if (!null && strcmp(NameStr(*DatumGetName(datum)), stmt->name) == 0)
{
gro_exists = true;
simple_heap_delete(pg_group_rel, &tuple->t_self);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.304 2002/04/18 20:01:09 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.305 2002/04/18 21:16:16 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
MATCH, MINUTE_P, MONTH_P, NAMES,
NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NULLIF, NULL_P, NUMERIC,
OF, OLD, ON, ONLY, OPTION, OR, ORDER, OUTER_P, OVERLAPS,
- PARTIAL, POSITION, PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE, PUBLIC,
+ PARTIAL, POSITION, PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE,
READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
SCHEMA, SCROLL, SECOND_P, SELECT, SESSION, SESSION_USER, SET, SOME, SUBSTRING,
TABLE, TEMPORARY, THEN, TIME, TIMESTAMP,
| grantee_list ',' grantee { $$ = lappend($1, $3); }
;
-grantee: PUBLIC
+grantee: ColId
{
PrivGrantee *n = makeNode(PrivGrantee);
- n->username = NULL;
+ /* This hack lets us avoid reserving PUBLIC as a keyword */
+ if (strcmp($1, "public") == 0)
+ n->username = NULL;
+ else
+ n->username = $1;
n->groupname = NULL;
$$ = (Node *)n;
}
| GROUP ColId
{
PrivGrantee *n = makeNode(PrivGrantee);
+ /* Treat GROUP PUBLIC as a synonym for PUBLIC */
+ if (strcmp($2, "public") == 0)
+ n->groupname = NULL;
+ else
+ n->groupname = $2;
n->username = NULL;
- n->groupname = $2;
- $$ = (Node *)n;
- }
- | ColId
- {
- PrivGrantee *n = makeNode(PrivGrantee);
- n->username = $1;
- n->groupname = NULL;
$$ = (Node *)n;
}
;
| STATISTICS { $$ = "statistics"; }
| STDIN { $$ = "stdin"; }
| STDOUT { $$ = "stdout"; }
- | STORAGE { $$ = "storage"; }
+ | STORAGE { $$ = "storage"; }
| SYSID { $$ = "sysid"; }
| TEMP { $$ = "temp"; }
| TEMPLATE { $$ = "template"; }
| NOTNULL { $$ = "notnull"; }
| OUTER_P { $$ = "outer"; }
| OVERLAPS { $$ = "overlaps"; }
- | PUBLIC { $$ = "public"; }
| RIGHT { $$ = "right"; }
| VERBOSE { $$ = "verbose"; }
;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.104 2002/03/19 02:18:19 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.105 2002/04/18 21:16:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
{"privileges", PRIVILEGES},
{"procedural", PROCEDURAL},
{"procedure", PROCEDURE},
- {"public", PUBLIC},
{"read", READ},
{"references", REFERENCES},
{"reindex", REINDEX},