mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Implement CREATE DATABASE/WITH LOCATION=.
Implement SET keyword = DEFAULT and SET TIME ZONE DEFAULT. Re-enable JOIN= option in CREATE OPERATOR statement (damaged for v6.2). Allow more SQL and/or Postgres reserved words as column identifiers or, if there are shift/reduce problems, at least as column labels.
This commit is contained in:
parent
6210dd5264
commit
acc2843025
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.62 1997/11/02 15:25:26 vadim Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.63 1997/11/07 07:02:07 thomas Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -120,6 +120,8 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr);
|
|||||||
ReplaceStmt, AppendStmt, NotifyStmt, DeleteStmt, ClusterStmt,
|
ReplaceStmt, AppendStmt, NotifyStmt, DeleteStmt, ClusterStmt,
|
||||||
ExplainStmt, VariableSetStmt, VariableShowStmt, VariableResetStmt
|
ExplainStmt, VariableSetStmt, VariableShowStmt, VariableResetStmt
|
||||||
|
|
||||||
|
%type <str> opt_database, location
|
||||||
|
|
||||||
%type <node> SubSelect
|
%type <node> SubSelect
|
||||||
%type <str> join_expr, join_outer, join_spec
|
%type <str> join_expr, join_outer, join_spec
|
||||||
%type <boolean> TriggerActionTime, TriggerForSpec, PLangTrusted
|
%type <boolean> TriggerActionTime, TriggerForSpec, PLangTrusted
|
||||||
@ -240,7 +242,7 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr);
|
|||||||
MATCH, MINUTE_P, MONTH_P,
|
MATCH, MINUTE_P, MONTH_P,
|
||||||
NATIONAL, NATURAL, NCHAR, NO, NOT, NOTIFY, NOTNULL, NULL_P, NUMERIC,
|
NATIONAL, NATURAL, NCHAR, NO, NOT, NOTIFY, NOTNULL, NULL_P, NUMERIC,
|
||||||
ON, OPTION, OR, ORDER, OUTER_P,
|
ON, OPTION, OR, ORDER, OUTER_P,
|
||||||
PARTIAL, PRECISION, POSITION, PRIMARY, PRIVILEGES, PROCEDURE, PUBLIC,
|
PARTIAL, POSITION, PRECISION, PRIMARY, PRIVILEGES, PROCEDURE, PUBLIC,
|
||||||
REFERENCES, REVOKE, RIGHT, ROLLBACK,
|
REFERENCES, REVOKE, RIGHT, ROLLBACK,
|
||||||
SECOND_P, SELECT, SET, SUBSTRING,
|
SECOND_P, SELECT, SET, SUBSTRING,
|
||||||
TABLE, TIME, TIMESTAMP, TO, TRAILING, TRANSACTION, TRIM,
|
TABLE, TIME, TIMESTAMP, TO, TRAILING, TRANSACTION, TRIM,
|
||||||
@ -261,7 +263,7 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr);
|
|||||||
DATABASE, DELIMITERS, DO, EXPLAIN, EXTEND,
|
DATABASE, DELIMITERS, DO, EXPLAIN, EXTEND,
|
||||||
FORWARD, FUNCTION, HANDLER, HEAVY,
|
FORWARD, FUNCTION, HANDLER, HEAVY,
|
||||||
INDEX, INHERITS, INSTEAD, ISNULL,
|
INDEX, INHERITS, INSTEAD, ISNULL,
|
||||||
LANCOMPILER, LIGHT, LISTEN, LOAD, MERGE, MOVE,
|
LANCOMPILER, LIGHT, LISTEN, LOAD, LOCATION, MERGE, MOVE,
|
||||||
NEW, NONE, NOTHING, OIDS, OPERATOR, PROCEDURAL, PURGE,
|
NEW, NONE, NOTHING, OIDS, OPERATOR, PROCEDURAL, PURGE,
|
||||||
RECIPE, RENAME, REPLACE, RESET, RETRIEVE, RETURNS, RULE,
|
RECIPE, RENAME, REPLACE, RESET, RETRIEVE, RETURNS, RULE,
|
||||||
SEQUENCE, SETOF, SHOW, STDIN, STDOUT, STORE, TRUSTED,
|
SEQUENCE, SETOF, SHOW, STDIN, STDOUT, STORE, TRUSTED,
|
||||||
@ -390,9 +392,11 @@ VariableSetStmt: SET ColId TO var_value
|
|||||||
;
|
;
|
||||||
|
|
||||||
var_value: Sconst { $$ = $1; }
|
var_value: Sconst { $$ = $1; }
|
||||||
|
| DEFAULT { $$ = NULL; }
|
||||||
;
|
;
|
||||||
|
|
||||||
zone_value: Sconst { $$ = $1; }
|
zone_value: Sconst { $$ = $1; }
|
||||||
|
| DEFAULT { $$ = NULL; }
|
||||||
| LOCAL { $$ = "default"; }
|
| LOCAL { $$ = "default"; }
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -985,7 +989,8 @@ TriggerFuncArgs: TriggerFuncArg
|
|||||||
{ $$ = lcons($1, NIL); }
|
{ $$ = lcons($1, NIL); }
|
||||||
| TriggerFuncArgs ',' TriggerFuncArg
|
| TriggerFuncArgs ',' TriggerFuncArg
|
||||||
{ $$ = lappend($1, $3); }
|
{ $$ = lappend($1, $3); }
|
||||||
| /* EMPTY */ { $$ = NIL; }
|
| /*EMPTY*/
|
||||||
|
{ $$ = NIL; }
|
||||||
;
|
;
|
||||||
|
|
||||||
TriggerFuncArg: ICONST
|
TriggerFuncArg: ICONST
|
||||||
@ -1051,6 +1056,7 @@ printf("def_type: decoding TYPE_P\n");
|
|||||||
;
|
;
|
||||||
|
|
||||||
def_name: PROCEDURE { $$ = "procedure"; }
|
def_name: PROCEDURE { $$ = "procedure"; }
|
||||||
|
| JOIN { $$ = "join"; }
|
||||||
| ColId { $$ = $1; }
|
| ColId { $$ = $1; }
|
||||||
| MathOp { $$ = $1; }
|
| MathOp { $$ = $1; }
|
||||||
| Op { $$ = $1; }
|
| Op { $$ = $1; }
|
||||||
@ -1830,14 +1836,23 @@ LoadStmt: LOAD file_name
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
CreatedbStmt: CREATE DATABASE database_name
|
CreatedbStmt: CREATE DATABASE database_name opt_database
|
||||||
{
|
{
|
||||||
CreatedbStmt *n = makeNode(CreatedbStmt);
|
CreatedbStmt *n = makeNode(CreatedbStmt);
|
||||||
n->dbname = $3;
|
n->dbname = $3;
|
||||||
|
n->dbpath = $4;
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
opt_database: WITH LOCATION '=' location { $$ = $4; }
|
||||||
|
| /*EMPTY*/ { $$ = NULL; }
|
||||||
|
;
|
||||||
|
|
||||||
|
location: Sconst { $$ = $1; }
|
||||||
|
| DEFAULT { $$ = NULL; }
|
||||||
|
| /*EMPTY*/ { $$ = NULL; }
|
||||||
|
;
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
@ -3479,11 +3494,32 @@ Id: IDENT { $$ = $1; };
|
|||||||
/* Column identifier
|
/* Column identifier
|
||||||
* Include date/time keywords as SQL92 extension.
|
* Include date/time keywords as SQL92 extension.
|
||||||
* Include TYPE as a SQL92 unreserved keyword. - thomas 1997-10-05
|
* Include TYPE as a SQL92 unreserved keyword. - thomas 1997-10-05
|
||||||
|
* Add other keywords. Note that as the syntax expands,
|
||||||
|
* some of these keywords will have to be removed from this
|
||||||
|
* list due to shift/reduce conflicts in yacc. If so, move
|
||||||
|
* down to the ColLabel entity. - thomas 1997-11-06
|
||||||
*/
|
*/
|
||||||
ColId: Id { $$ = $1; }
|
ColId: Id { $$ = $1; }
|
||||||
| datetime { $$ = $1; }
|
| datetime { $$ = $1; }
|
||||||
|
| ACTION { $$ = "action"; }
|
||||||
|
| DATABASE { $$ = "database"; }
|
||||||
|
| DELIMITERS { $$ = "delimiters"; }
|
||||||
|
| FUNCTION { $$ = "function"; }
|
||||||
|
| INDEX { $$ = "index"; }
|
||||||
|
| KEY { $$ = "key"; }
|
||||||
|
| LANGUAGE { $$ = "language"; }
|
||||||
|
| LIGHT { $$ = "light"; }
|
||||||
|
| LOCATION { $$ = "location"; }
|
||||||
|
| MATCH { $$ = "match"; }
|
||||||
|
| OPERATOR { $$ = "operator"; }
|
||||||
|
| OPTION { $$ = "option"; }
|
||||||
|
| PRIVILEGES { $$ = "privileges"; }
|
||||||
|
| RECIPE { $$ = "recipe"; }
|
||||||
| TIME { $$ = "time"; }
|
| TIME { $$ = "time"; }
|
||||||
|
| TRIGGER { $$ = "trigger"; }
|
||||||
| TYPE_P { $$ = "type"; }
|
| TYPE_P { $$ = "type"; }
|
||||||
|
| VERSION { $$ = "version"; }
|
||||||
|
| ZONE { $$ = "zone"; }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Column label
|
/* Column label
|
||||||
@ -3492,8 +3528,24 @@ ColId: Id { $$ = $1; }
|
|||||||
* compatibility. Cannot allow this for column names since the
|
* compatibility. Cannot allow this for column names since the
|
||||||
* syntax would not distinguish between the constant value and
|
* syntax would not distinguish between the constant value and
|
||||||
* a column name. - thomas 1997-10-24
|
* a column name. - thomas 1997-10-24
|
||||||
|
* Add other keywords to this list. Note that they appear here
|
||||||
|
* rather than in ColId if there was a shift/reduce conflict
|
||||||
|
* when used as a full identifier. - thomas 1997-11-06
|
||||||
*/
|
*/
|
||||||
ColLabel: ColId { $$ = $1; }
|
ColLabel: ColId { $$ = $1; }
|
||||||
|
| ARCHIVE { $$ = "archive"; }
|
||||||
|
| CLUSTER { $$ = "cluster"; }
|
||||||
|
| CONSTRAINT { $$ = "constraint"; }
|
||||||
|
| CROSS { $$ = "cross"; }
|
||||||
|
| FOREIGN { $$ = "foreign"; }
|
||||||
|
| GROUP { $$ = "group"; }
|
||||||
|
| LOAD { $$ = "load"; }
|
||||||
|
| ORDER { $$ = "order"; }
|
||||||
|
| POSITION { $$ = "position"; }
|
||||||
|
| PRECISION { $$ = "precision"; }
|
||||||
|
| STORE { $$ = "store"; }
|
||||||
|
| TABLE { $$ = "table"; }
|
||||||
|
| TRANSACTION { $$ = "transaction"; }
|
||||||
| TRUE_P { $$ = "true"; }
|
| TRUE_P { $$ = "true"; }
|
||||||
| FALSE_P { $$ = "false"; }
|
| FALSE_P { $$ = "false"; }
|
||||||
;
|
;
|
||||||
@ -3707,8 +3759,8 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
|
|||||||
static char *
|
static char *
|
||||||
xlateSqlType(char *name)
|
xlateSqlType(char *name)
|
||||||
{
|
{
|
||||||
if (!strcasecmp(name,"int") ||
|
if (!strcasecmp(name,"int")
|
||||||
!strcasecmp(name,"integer"))
|
|| !strcasecmp(name,"integer"))
|
||||||
return "int4";
|
return "int4";
|
||||||
else if (!strcasecmp(name, "smallint"))
|
else if (!strcasecmp(name, "smallint"))
|
||||||
return "int2";
|
return "int2";
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.21 1997/10/28 14:56:10 vadim Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.22 1997/11/07 07:02:10 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -129,6 +129,7 @@ static ScanKeyword ScanKeywords[] = {
|
|||||||
{"listen", LISTEN},
|
{"listen", LISTEN},
|
||||||
{"load", LOAD},
|
{"load", LOAD},
|
||||||
{"local", LOCAL},
|
{"local", LOCAL},
|
||||||
|
{"location", LOCATION},
|
||||||
{"match", MATCH},
|
{"match", MATCH},
|
||||||
{"merge", MERGE},
|
{"merge", MERGE},
|
||||||
{"minute", MINUTE_P},
|
{"minute", MINUTE_P},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user