Commit 99b8f845 authored by Bruce Momjian's avatar Bruce Momjian

Here's the Create/Alter/Drop Group stuff that's been really overdue. I

didn't have time for documentation yet, but I'll write some. There are
still some things to work out what happens when you alter or drop users,
but the group stuff in and by itself is done.

--
Peter Eisentraut                  Sernanders väg 10:115
parent 4cb1fb6f
This diff is collapsed.
......@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.122 1999/12/14 00:08:15 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.123 1999/12/16 17:24:14 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
......@@ -129,6 +129,7 @@ static Node *doNegate(Node *n);
ClusterStmt, ExplainStmt, VariableSetStmt, VariableShowStmt, VariableResetStmt,
CreateUserStmt, AlterUserStmt, DropUserStmt, RuleActionStmt,
RuleActionStmtOrEmpty, ConstraintsSetStmt,
CreateGroupStmt, AlterGroupStmt, DropGroupStmt
%type <str> opt_database1, opt_database2, location, encoding
......@@ -139,7 +140,7 @@ static Node *doNegate(Node *n);
%type <str> user_passwd_clause
%type <ival> sysid_clause
%type <str> user_valid_clause
%type <list> user_group_list, user_group_clause
%type <list> user_group_list, user_group_clause, users_in_new_group_clause
%type <boolean> TriggerActionTime, TriggerForSpec, PLangTrusted
......@@ -391,11 +392,13 @@ stmtmulti: stmtmulti ';' stmt
;
stmt : AddAttrStmt
| AlterGroupStmt
| AlterUserStmt
| ClosePortalStmt
| CopyStmt
| CreateStmt
| CreateAsStmt
| CreateGroupStmt
| CreateSeqStmt
| CreatePLangStmt
| CreateTrigStmt
......@@ -405,6 +408,7 @@ stmt : AddAttrStmt
| DropStmt
| TruncateStmt
| CommentStmt
| DropGroupStmt
| DropPLangStmt
| DropTrigStmt
| DropUserStmt
......@@ -575,20 +579,99 @@ user_group_list: user_group_list ',' UserId
}
;
user_group_clause: IN GROUP user_group_list
{
/* the backend doesn't actually process this,
* so an error message is probably fairer */
yyerror("IN GROUP is not implemented");
/* $$ = $3; */
}
| /*EMPTY*/ { $$ = NULL; }
user_group_clause: IN GROUP user_group_list { $$ = $3; }
| /*EMPTY*/ { $$ = NULL; }
;
user_valid_clause: VALID UNTIL SCONST { $$ = $3; }
| /*EMPTY*/ { $$ = NULL; }
;
/*****************************************************************************
*
* Create a postresql group
*
*
*****************************************************************************/
CreateGroupStmt: CREATE GROUP UserId
{
CreateGroupStmt *n = makeNode(CreateGroupStmt);
n->name = $3;
n->sysid = -1;
n->initUsers = NULL;
$$ = (Node *)n;
}
|
CREATE GROUP UserId WITH sysid_clause users_in_new_group_clause
{
CreateGroupStmt *n = makeNode(CreateGroupStmt);
n->name = $3;
n->sysid = $5;
n->initUsers = $6;
$$ = (Node *)n;
}
;
users_in_new_group_clause: USER user_group_list { $$ = $2; }
| /* EMPTY */ { $$ = NULL; }
;
/*****************************************************************************
*
* Alter a postresql group
*
*
*****************************************************************************/
AlterGroupStmt: ALTER GROUP UserId WITH SYSID Iconst
{
AlterGroupStmt *n = makeNode(AlterGroupStmt);
n->name = $3;
n->sysid = $6;
n->action = 0;
n->listUsers = NULL;
$$ = (Node *)n;
}
|
ALTER GROUP UserId ADD USER user_group_list
{
AlterGroupStmt *n = makeNode(AlterGroupStmt);
n->name = $3;
n->sysid = -1;
n->action = +1;
n->listUsers = $6;
$$ = (Node *)n;
}
|
ALTER GROUP UserId DROP USER user_group_list
{
AlterGroupStmt *n = makeNode(AlterGroupStmt);
n->name = $3;
n->sysid = -1;
n->action = -1;
n->listUsers = $6;
$$ = (Node *)n;
}
;
/*****************************************************************************
*
* Drop a postresql group
*
*
*****************************************************************************/
DropGroupStmt: DROP GROUP UserId
{
DropGroupStmt *n = makeNode(DropGroupStmt);
n->name = $3;
$$ = (Node *)n;
}
;
/*****************************************************************************
*
* Set PG internal variable
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.74 1999/12/14 00:08:17 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.75 1999/12/16 17:24:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -809,6 +809,26 @@ ProcessUtility(Node *parsetree,
DeferredTriggerSetState((ConstraintsSetStmt *) parsetree);
break;
case T_CreateGroupStmt:
PS_SET_STATUS(commandTag = "CREATE GROUP");
CHECK_IF_ABORTED();
CreateGroup((CreateGroupStmt *) parsetree, dest);
break;
case T_AlterGroupStmt:
PS_SET_STATUS(commandTag = "ALTER GROUP");
CHECK_IF_ABORTED();
AlterGroup((AlterGroupStmt *) parsetree, dest);
break;
case T_DropGroupStmt:
PS_SET_STATUS(commandTag = "DROP GROUP");
CHECK_IF_ABORTED();
DropGroup((DropGroupStmt *) parsetree, dest);
break;
/*
* ******************************** default ********************************
......
......@@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_class.h,v 1.30 1999/09/29 16:06:16 wieck Exp $
* $Id: pg_class.h,v 1.31 1999/12/16 17:24:17 momjian Exp $
*
* NOTES
* ``pg_relation'' is being replaced by ``pg_class''. currently
......@@ -136,7 +136,7 @@ DATA(insert OID = 1259 ( pg_class 83 PGUID 0 0 0 f f r 18 0 0 0 0 0 f f _nul
DESCR("");
DATA(insert OID = 1260 ( pg_shadow 86 PGUID 0 0 0 f t r 8 0 0 0 0 0 f f _null_ ));
DESCR("");
DATA(insert OID = 1261 ( pg_group 87 PGUID 0 0 0 f t s 3 0 0 0 0 0 f f _null_ ));
DATA(insert OID = 1261 ( pg_group 87 PGUID 0 0 0 f t r 3 0 0 0 0 0 f f _null_ ));
DESCR("");
DATA(insert OID = 1262 ( pg_database 88 PGUID 0 0 0 f t r 4 0 0 0 0 0 f f _null_ ));
DESCR("");
......
......@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_group.h,v 1.6 1999/02/13 23:21:09 momjian Exp $
* $Id: pg_group.h,v 1.7 1999/12/16 17:24:17 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
......@@ -35,7 +35,7 @@ CATALOG(pg_group) BOOTSTRAP
typedef FormData_pg_group *Form_pg_group;
#define Natts_pg_group 1
#define Natts_pg_group 3
#define Anum_pg_group_groname 1
#define Anum_pg_group_grosysid 2
#define Anum_pg_group_grolist 3
......
......@@ -17,4 +17,8 @@ extern void DefineUser(CreateUserStmt *stmt, CommandDest);
extern void AlterUser(AlterUserStmt *stmt, CommandDest);
extern void RemoveUser(char *user, CommandDest);
extern void CreateGroup(CreateGroupStmt *stmt, CommandDest dest);
extern void AlterGroup(AlterGroupStmt *stmt, CommandDest dest);
extern void DropGroup(DropGroupStmt *stmt, CommandDest dest);
#endif /* USER_H */
......@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodes.h,v 1.58 1999/12/10 03:56:09 momjian Exp $
* $Id: nodes.h,v 1.59 1999/12/16 17:24:19 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -189,6 +189,9 @@ typedef enum NodeTag
T_DropUserStmt,
T_LockStmt,
T_ConstraintsSetStmt,
T_CreateGroupStmt,
T_AlterGroupStmt,
T_DropGroupStmt,
T_A_Expr = 700,
T_Attr,
......
......@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.91 1999/12/14 00:08:21 momjian Exp $
* $Id: parsenodes.h,v 1.92 1999/12/16 17:24:19 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -285,6 +285,34 @@ typedef struct DropUserStmt
} DropUserStmt;
/* ----------------------
* Create/Alter/Drop Group Statements
* ----------------------
*/
typedef struct CreateGroupStmt
{
NodeTag type;
char *name; /* name of the new group */
int sysid; /* group id (-1 if pick default) */
List *initUsers; /* list of initial users */
} CreateGroupStmt;
typedef struct AlterGroupStmt
{
NodeTag type;
char *name; /* name of group to alter */
int action; /* +1 = add, -1 = drop, 0 = other (HACK!) */
int sysid; /* sysid change */
List *listUsers; /* list of users to add/drop */
} AlterGroupStmt;
typedef struct DropGroupStmt
{
NodeTag type;
char *name;
} DropGroupStmt;
/* ----------------------
* Create SEQUENCE Statement
* ----------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment