Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit99b8f84

Browse files
committed
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 arestill 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
1 parent4cb1fb6 commit99b8f84

File tree

8 files changed

+682
-19
lines changed

8 files changed

+682
-19
lines changed

‎src/backend/commands/user.c

Lines changed: 527 additions & 2 deletions
Large diffs are not rendered by default.

‎src/backend/parser/gram.y

Lines changed: 93 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.122 1999/12/14 00:08:15 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.123 1999/12/16 17:24:14 momjian Exp $
1414
*
1515
* HISTORY
1616
* AUTHORDATEMAJOR EVENT
@@ -129,6 +129,7 @@ static Node *doNegate(Node *n);
129129
ClusterStmt, ExplainStmt, VariableSetStmt, VariableShowStmt, VariableResetStmt,
130130
CreateUserStmt, AlterUserStmt, DropUserStmt, RuleActionStmt,
131131
RuleActionStmtOrEmpty, ConstraintsSetStmt,
132+
CreateGroupStmt, AlterGroupStmt, DropGroupStmt
132133

133134
%type <str>opt_database1, opt_database2, location, encoding
134135

@@ -139,7 +140,7 @@ static Node *doNegate(Node *n);
139140
%type <str>user_passwd_clause
140141
%type <ival> sysid_clause
141142
%type <str>user_valid_clause
142-
%type <list>user_group_list, user_group_clause
143+
%type <list>user_group_list, user_group_clause, users_in_new_group_clause
143144

144145
%type <boolean>TriggerActionTime, TriggerForSpec, PLangTrusted
145146

@@ -391,11 +392,13 @@ stmtmulti: stmtmulti ';' stmt
391392
;
392393

393394
stmt : AddAttrStmt
395+
| AlterGroupStmt
394396
| AlterUserStmt
395397
| ClosePortalStmt
396398
| CopyStmt
397399
| CreateStmt
398400
| CreateAsStmt
401+
| CreateGroupStmt
399402
| CreateSeqStmt
400403
| CreatePLangStmt
401404
| CreateTrigStmt
@@ -405,6 +408,7 @@ stmt : AddAttrStmt
405408
| DropStmt
406409
| TruncateStmt
407410
| CommentStmt
411+
| DropGroupStmt
408412
| DropPLangStmt
409413
| DropTrigStmt
410414
| DropUserStmt
@@ -575,20 +579,99 @@ user_group_list: user_group_list ',' UserId
575579
}
576580
;
577581

578-
user_group_clause: IN GROUP user_group_list
579-
{
580-
/* the backend doesn't actually process this,
581-
* so an error message is probably fairer */
582-
yyerror("IN GROUP is not implemented");
583-
/* $$ = $3; */
584-
}
585-
| /*EMPTY*/{ $$ = NULL; }
582+
user_group_clause: IN GROUP user_group_list { $$ = $3; }
583+
| /*EMPTY*/ { $$ = NULL; }
586584
;
587585

588586
user_valid_clause: VALID UNTIL SCONST{ $$ = $3; }
589587
| /*EMPTY*/{ $$ = NULL; }
590588
;
591589

590+
591+
/*****************************************************************************
592+
*
593+
* Create a postresql group
594+
*
595+
*
596+
*****************************************************************************/
597+
598+
CreateGroupStmt: CREATE GROUP UserId
599+
{
600+
CreateGroupStmt *n = makeNode(CreateGroupStmt);
601+
n->name = $3;
602+
n->sysid = -1;
603+
n->initUsers = NULL;
604+
$$ = (Node *)n;
605+
}
606+
|
607+
CREATE GROUP UserId WITH sysid_clause users_in_new_group_clause
608+
{
609+
CreateGroupStmt *n = makeNode(CreateGroupStmt);
610+
n->name = $3;
611+
n->sysid = $5;
612+
n->initUsers = $6;
613+
$$ = (Node *)n;
614+
}
615+
;
616+
617+
users_in_new_group_clause: USER user_group_list { $$ = $2; }
618+
| /* EMPTY */ { $$ = NULL; }
619+
;
620+
621+
/*****************************************************************************
622+
*
623+
* Alter a postresql group
624+
*
625+
*
626+
*****************************************************************************/
627+
628+
AlterGroupStmt: ALTER GROUP UserId WITH SYSID Iconst
629+
{
630+
AlterGroupStmt *n = makeNode(AlterGroupStmt);
631+
n->name = $3;
632+
n->sysid = $6;
633+
n->action = 0;
634+
n->listUsers = NULL;
635+
$$ = (Node *)n;
636+
}
637+
|
638+
ALTER GROUP UserId ADD USER user_group_list
639+
{
640+
AlterGroupStmt *n = makeNode(AlterGroupStmt);
641+
n->name = $3;
642+
n->sysid = -1;
643+
n->action = +1;
644+
n->listUsers = $6;
645+
$$ = (Node *)n;
646+
}
647+
|
648+
ALTER GROUP UserId DROP USER user_group_list
649+
{
650+
AlterGroupStmt *n = makeNode(AlterGroupStmt);
651+
n->name = $3;
652+
n->sysid = -1;
653+
n->action = -1;
654+
n->listUsers = $6;
655+
$$ = (Node *)n;
656+
}
657+
;
658+
659+
/*****************************************************************************
660+
*
661+
* Drop a postresql group
662+
*
663+
*
664+
*****************************************************************************/
665+
666+
DropGroupStmt: DROP GROUP UserId
667+
{
668+
DropGroupStmt *n = makeNode(DropGroupStmt);
669+
n->name = $3;
670+
$$ = (Node *)n;
671+
}
672+
;
673+
674+
592675
/*****************************************************************************
593676
*
594677
* Set PG internal variable

‎src/backend/tcop/utility.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.74 1999/12/14 00:08:17 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.75 1999/12/16 17:24:15 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -809,6 +809,26 @@ ProcessUtility(Node *parsetree,
809809
DeferredTriggerSetState((ConstraintsSetStmt*)parsetree);
810810
break;
811811

812+
caseT_CreateGroupStmt:
813+
PS_SET_STATUS(commandTag="CREATE GROUP");
814+
CHECK_IF_ABORTED();
815+
816+
CreateGroup((CreateGroupStmt*)parsetree,dest);
817+
break;
818+
819+
caseT_AlterGroupStmt:
820+
PS_SET_STATUS(commandTag="ALTER GROUP");
821+
CHECK_IF_ABORTED();
822+
823+
AlterGroup((AlterGroupStmt*)parsetree,dest);
824+
break;
825+
826+
caseT_DropGroupStmt:
827+
PS_SET_STATUS(commandTag="DROP GROUP");
828+
CHECK_IF_ABORTED();
829+
830+
DropGroup((DropGroupStmt*)parsetree,dest);
831+
break;
812832

813833
/*
814834
* ******************************** default ********************************

‎src/include/catalog/pg_class.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_class.h,v 1.30 1999/09/29 16:06:16 wieck Exp $
10+
* $Id: pg_class.h,v 1.31 1999/12/16 17:24:17 momjian Exp $
1111
*
1212
* NOTES
1313
* ``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
136136
DESCR("");
137137
DATA(insertOID=1260 (pg_shadow86PGUID000ftr800000ff_null_ ));
138138
DESCR("");
139-
DATA(insertOID=1261 (pg_group87PGUID000fts300000ff_null_ ));
139+
DATA(insertOID=1261 (pg_group87PGUID000ftr300000ff_null_ ));
140140
DESCR("");
141141
DATA(insertOID=1262 (pg_database88PGUID000ftr400000ff_null_ ));
142142
DESCR("");

‎src/include/catalog/pg_group.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_group.h,v 1.6 1999/02/13 23:21:09 momjian Exp $
9+
* $Id: pg_group.h,v 1.7 1999/12/16 17:24:17 momjian Exp $
1010
*
1111
* NOTES
1212
* the genbki.sh script reads this file and generates .bki
@@ -35,7 +35,7 @@ CATALOG(pg_group) BOOTSTRAP
3535

3636
typedefFormData_pg_group*Form_pg_group;
3737

38-
#defineNatts_pg_group1
38+
#defineNatts_pg_group3
3939
#defineAnum_pg_group_groname1
4040
#defineAnum_pg_group_grosysid2
4141
#defineAnum_pg_group_grolist3

‎src/include/commands/user.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ extern void DefineUser(CreateUserStmt *stmt, CommandDest);
1717
externvoidAlterUser(AlterUserStmt*stmt,CommandDest);
1818
externvoidRemoveUser(char*user,CommandDest);
1919

20+
externvoidCreateGroup(CreateGroupStmt*stmt,CommandDestdest);
21+
externvoidAlterGroup(AlterGroupStmt*stmt,CommandDestdest);
22+
externvoidDropGroup(DropGroupStmt*stmt,CommandDestdest);
23+
2024
#endif/* USER_H */

‎src/include/nodes/nodes.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: nodes.h,v 1.58 1999/12/10 03:56:09 momjian Exp $
9+
* $Id: nodes.h,v 1.59 1999/12/16 17:24:19 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -189,6 +189,9 @@ typedef enum NodeTag
189189
T_DropUserStmt,
190190
T_LockStmt,
191191
T_ConstraintsSetStmt,
192+
T_CreateGroupStmt,
193+
T_AlterGroupStmt,
194+
T_DropGroupStmt,
192195

193196
T_A_Expr=700,
194197
T_Attr,

‎src/include/nodes/parsenodes.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: parsenodes.h,v 1.91 1999/12/14 00:08:21 momjian Exp $
9+
* $Id: parsenodes.h,v 1.92 1999/12/16 17:24:19 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -285,6 +285,34 @@ typedef struct DropUserStmt
285285
}DropUserStmt;
286286

287287

288+
/* ----------------------
289+
* Create/Alter/Drop Group Statements
290+
* ----------------------
291+
*/
292+
typedefstructCreateGroupStmt
293+
{
294+
NodeTagtype;
295+
char*name;/* name of the new group */
296+
intsysid;/* group id (-1 if pick default) */
297+
List*initUsers;/* list of initial users */
298+
}CreateGroupStmt;
299+
300+
typedefstructAlterGroupStmt
301+
{
302+
NodeTagtype;
303+
char*name;/* name of group to alter */
304+
intaction;/* +1 = add, -1 = drop, 0 = other (HACK!) */
305+
intsysid;/* sysid change */
306+
List*listUsers;/* list of users to add/drop */
307+
}AlterGroupStmt;
308+
309+
typedefstructDropGroupStmt
310+
{
311+
NodeTagtype;
312+
char*name;
313+
}DropGroupStmt;
314+
315+
288316
/* ----------------------
289317
*Create SEQUENCE Statement
290318
* ----------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp