1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-22 23:02:54 +03:00

Simplify optional WITH handling in CREATE USER, ALTER USER, CREATE

GROUP.  Make WITH optional in CREATE DATABASE for consistency.
This commit is contained in:
Bruce Momjian 2002-06-17 05:40:32 +00:00
parent 0daee96ed1
commit f91ee129a7
2 changed files with 50 additions and 65 deletions

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_database.sgml,v 1.27 2002/04/21 19:02:39 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_database.sgml,v 1.28 2002/06/17 05:40:32 momjian Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
@ -22,7 +22,7 @@ PostgreSQL documentation
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
[ WITH [ OWNER [=] <replaceable class="parameter">dbowner</replaceable> ] [ [ WITH ] [ OWNER [=] <replaceable class="parameter">dbowner</replaceable> ]
[ LOCATION [=] '<replaceable class="parameter">dbpath</replaceable>' ] [ LOCATION [=] '<replaceable class="parameter">dbpath</replaceable>' ]
[ TEMPLATE [=] <replaceable class="parameter">template</replaceable> ] [ TEMPLATE [=] <replaceable class="parameter">template</replaceable> ]
[ ENCODING [=] <replaceable class="parameter">encoding</replaceable> ] ] [ ENCODING [=] <replaceable class="parameter">encoding</replaceable> ] ]

View File

@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.323 2002/06/15 03:00:03 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.324 2002/06/17 05:40:32 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
@ -201,7 +201,7 @@ static void doNegateFloat(Value *v);
%type <list> stmtblock, stmtmulti, %type <list> stmtblock, stmtmulti,
OptTableElementList, OptInherit, definition, opt_distinct, OptTableElementList, OptInherit, definition, opt_distinct,
opt_with, func_args, func_args_list, func_as, createfunc_opt_list opt_definition, func_args, func_args_list, func_as, createfunc_opt_list
oper_argtypes, RuleActionList, RuleActionMulti, oper_argtypes, RuleActionList, RuleActionMulti,
opt_column_list, columnList, opt_name_list, opt_column_list, columnList, opt_name_list,
sort_clause, sortby_list, index_params, index_list, name_list, sort_clause, sortby_list, index_params, index_list, name_list,
@ -232,7 +232,7 @@ static void doNegateFloat(Value *v);
%type <ival> opt_interval %type <ival> opt_interval
%type <node> overlay_placing, substr_from, substr_for %type <node> overlay_placing, substr_from, substr_for
%type <boolean> opt_binary, opt_using, opt_instead, opt_cursor %type <boolean> opt_binary, opt_using, opt_instead, opt_cursor, opt_with
%type <boolean> opt_with_copy, index_opt_unique, opt_verbose, opt_full %type <boolean> opt_with_copy, index_opt_unique, opt_verbose, opt_full
%type <boolean> opt_freeze, analyze_keyword %type <boolean> opt_freeze, analyze_keyword
@ -518,14 +518,7 @@ stmt : AlterDatabaseSetStmt
* *
*****************************************************************************/ *****************************************************************************/
CreateUserStmt: CREATE USER UserId OptUserList CreateUserStmt: CREATE USER UserId opt_with OptUserList
{
CreateUserStmt *n = makeNode(CreateUserStmt);
n->user = $3;
n->options = $4;
$$ = (Node *)n;
}
| CREATE USER UserId WITH OptUserList
{ {
CreateUserStmt *n = makeNode(CreateUserStmt); CreateUserStmt *n = makeNode(CreateUserStmt);
n->user = $3; n->user = $3;
@ -534,6 +527,11 @@ CreateUserStmt: CREATE USER UserId OptUserList
} }
; ;
opt_with: WITH { $$ = TRUE; }
| /*EMPTY*/ { $$ = TRUE; }
;
/***************************************************************************** /*****************************************************************************
* *
* Alter a postgresql DBMS user * Alter a postgresql DBMS user
@ -541,14 +539,7 @@ CreateUserStmt: CREATE USER UserId OptUserList
* *
*****************************************************************************/ *****************************************************************************/
AlterUserStmt: ALTER USER UserId OptUserList AlterUserStmt: ALTER USER UserId opt_with OptUserList
{
AlterUserStmt *n = makeNode(AlterUserStmt);
n->user = $3;
n->options = $4;
$$ = (Node *)n;
}
| ALTER USER UserId WITH OptUserList
{ {
AlterUserStmt *n = makeNode(AlterUserStmt); AlterUserStmt *n = makeNode(AlterUserStmt);
n->user = $3; n->user = $3;
@ -680,14 +671,7 @@ user_list: user_list ',' UserId
* *
*****************************************************************************/ *****************************************************************************/
CreateGroupStmt: CREATE GROUP_P UserId OptGroupList CreateGroupStmt: CREATE GROUP_P UserId opt_with OptGroupList
{
CreateGroupStmt *n = makeNode(CreateGroupStmt);
n->name = $3;
n->options = $4;
$$ = (Node *)n;
}
| CREATE GROUP_P UserId WITH OptGroupList
{ {
CreateGroupStmt *n = makeNode(CreateGroupStmt); CreateGroupStmt *n = makeNode(CreateGroupStmt);
n->name = $3; n->name = $3;
@ -2775,7 +2759,7 @@ RecipeStmt: EXECUTE RECIPE recipe_name
*****************************************************************************/ *****************************************************************************/
CreateFunctionStmt: CREATE opt_or_replace FUNCTION func_name func_args CreateFunctionStmt: CREATE opt_or_replace FUNCTION func_name func_args
RETURNS func_return createfunc_opt_list opt_with RETURNS func_return createfunc_opt_list opt_definition
{ {
CreateFunctionStmt *n = makeNode(CreateFunctionStmt); CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
n->replace = $2; n->replace = $2;
@ -2951,7 +2935,7 @@ func_as: Sconst
{ $$ = makeList2(makeString($1), makeString($3)); } { $$ = makeList2(makeString($1), makeString($3)); }
; ;
opt_with: WITH definition { $$ = $2; } opt_definition: WITH definition { $$ = $2; }
| /*EMPTY*/ { $$ = NIL; } | /*EMPTY*/ { $$ = NIL; }
; ;
@ -3324,7 +3308,7 @@ LoadStmt: LOAD file_name
* *
*****************************************************************************/ *****************************************************************************/
CreatedbStmt: CREATE DATABASE database_name WITH createdb_opt_list CreatedbStmt: CREATE DATABASE database_name opt_with createdb_opt_list
{ {
CreatedbStmt *n = makeNode(CreatedbStmt); CreatedbStmt *n = makeNode(CreatedbStmt);
List *l; List *l;
@ -3437,7 +3421,8 @@ createdb_opt_item: LOCATION opt_equal Sconst
/* /*
* Though the equals sign doesn't match other WITH options, pg_dump uses * Though the equals sign doesn't match other WITH options, pg_dump uses
* equals for backward compability, and it doesn't seem worth remove it. * equals for backward compability, and it doesn't seem worth removing it.
* 2002-02-25
*/ */
opt_equal: '=' { $$ = TRUE; } opt_equal: '=' { $$ = TRUE; }
| /*EMPTY*/ { $$ = FALSE; } | /*EMPTY*/ { $$ = FALSE; }