Commit 561aead3 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Allow parsing expressions with ") -" (scan.l, scan.c only).

Make "TABLE" optional in "LOCK TABLE" command
 and "... INTO TABLE..." clause.
Explicitly parse CREATE SEQUENCE options to allow a negative integer
 as an argument; this is an artifact of unary minus handling in scan.l.
Add "PASSWORD" as an allowed column identifier.
These fixes will require a "make clean install" but not a dump/reload.
parent c530fbfb
This diff is collapsed.
......@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.6 1998/03/07 06:04:59 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.7 1998/03/18 16:50:19 thomas Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
......@@ -170,6 +170,7 @@ Oid param_type(int t); /* used in parse_expr.c */
%type <sortgroupby>
join_using
%type <boolean> opt_union
%type <boolean> opt_table
%type <node> position_expr
%type <list> extract_list, position_list
......@@ -202,6 +203,7 @@ Oid param_type(int t); /* used in parse_expr.c */
%type <list> OptCreateAs, CreateAsList
%type <node> CreateAsElement
%type <value> NumConst
%type <value> IntegerOnly
%type <attr> event_object, attr
%type <sortgroupby> groupby
%type <sortgroupby> sortby
......@@ -277,14 +279,14 @@ Oid param_type(int t); /* used in parse_expr.c */
/* Keywords for Postgres support (not in SQL92 reserved words) */
%token ABORT_TRANS, AFTER, AGGREGATE, ANALYZE,
BACKWARD, BEFORE, BINARY, CLUSTER, COPY,
BACKWARD, BEFORE, BINARY, CACHE, CLUSTER, COPY, CYCLE,
DATABASE, DELIMITERS, DO, EACH, EXPLAIN, EXTEND,
FORWARD, FUNCTION, HANDLER,
INDEX, INHERITS, INSTEAD, ISNULL,
LANCOMPILER, LISTEN, LOAD, LOCK_P, LOCATION, MOVE,
INCREMENT, INDEX, INHERITS, INSTEAD, ISNULL,
LANCOMPILER, LISTEN, LOAD, LOCK_P, LOCATION, MAXVALUE, MINVALUE, MOVE,
NEW, NONE, NOTHING, NOTNULL, OIDS, OPERATOR, PROCEDURAL,
RECIPE, RENAME, RESET, RETURNS, ROW, RULE,
SEQUENCE, SETOF, SHOW, STATEMENT, STDIN, STDOUT, TRUSTED,
SEQUENCE, SETOF, SHOW, START, STATEMENT, STDIN, STDOUT, TRUSTED,
VACUUM, VERBOSE, VERSION
/* Keywords (obsolete; retain through next version for parser - thomas 1997-12-04) */
......@@ -1094,7 +1096,7 @@ CreateAsElement: ColId
*
*****************************************************************************/
CreateSeqStmt: CREATE SEQUENCE relation_name OptSeqList
CreateSeqStmt: CREATE SEQUENCE relation_name OptSeqList
{
CreateSeqStmt *n = makeNode(CreateSeqStmt);
n->seqname = $3;
......@@ -1103,24 +1105,58 @@ CreateSeqStmt: CREATE SEQUENCE relation_name OptSeqList
}
;
OptSeqList:
OptSeqList OptSeqElem
OptSeqList: OptSeqList OptSeqElem
{ $$ = lappend($1, $2); }
| { $$ = NIL; }
| { $$ = NIL; }
;
OptSeqElem: IDENT NumConst
OptSeqElem: CACHE IntegerOnly
{
$$ = makeNode(DefElem);
$$->defname = $1;
$$->defname = "cache";
$$->arg = (Node *)$2;
}
| IDENT
| CYCLE
{
$$ = makeNode(DefElem);
$$->defname = $1;
$$->defname = "cycle";
$$->arg = (Node *)NULL;
}
| INCREMENT IntegerOnly
{
$$ = makeNode(DefElem);
$$->defname = "increment";
$$->arg = (Node *)$2;
}
| MAXVALUE IntegerOnly
{
$$ = makeNode(DefElem);
$$->defname = "maxvalue";
$$->arg = (Node *)$2;
}
| MINVALUE IntegerOnly
{
$$ = makeNode(DefElem);
$$->defname = "minvalue";
$$->arg = (Node *)$2;
}
| START IntegerOnly
{
$$ = makeNode(DefElem);
$$->defname = "start";
$$->arg = (Node *)$2;
}
;
IntegerOnly: Iconst
{
$$ = makeInteger($1);
}
| '-' Iconst
{
$$ = makeInteger($2);
$$->val.ival = - $$->val.ival;
}
;
/*****************************************************************************
......@@ -1856,7 +1892,7 @@ event: SELECT { $$ = CMD_SELECT; }
;
opt_instead: INSTEAD { $$ = TRUE; }
| /*EMPTY*/ { $$ = FALSE; }
| /*EMPTY*/ { $$ = FALSE; }
;
......@@ -2101,10 +2137,8 @@ opt_analyze: ANALYZE { $$ = TRUE; }
| /*EMPTY*/ { $$ = FALSE; }
;
opt_va_list: '(' va_list ')'
{ $$ = $2; }
| /* EMPTY */
{ $$ = NIL; }
opt_va_list: '(' va_list ')' { $$ = $2; }
| /*EMPTY*/ { $$ = NIL; }
;
va_list: name
......@@ -2236,7 +2270,7 @@ DeleteStmt: DELETE FROM relation_name
* Is it worth making this a separate command, with
* its own node type and file. I don't think so. bjm 1998/1/22
*/
LockStmt: LOCK_P relation_name
LockStmt: LOCK_P opt_table relation_name
{
DeleteStmt *n = makeNode(DeleteStmt);
A_Const *c = makeNode(A_Const);
......@@ -2247,7 +2281,7 @@ LockStmt: LOCK_P relation_name
c->typename->name = xlateSqlType("bool");
c->typename->typmod = -1;
n->relname = $2;
n->relname = $3;
n->whereClause = (Node *)c;
$$ = (Node *)n;
}
......@@ -2378,10 +2412,12 @@ SubSelect: SELECT opt_unique res_target_list2
}
;
result: INTO TABLE relation_name
{ $$= $3; }
| /*EMPTY*/
{ $$ = NULL; }
result: INTO opt_table relation_name { $$= $3; }
| /*EMPTY*/ { $$ = NULL; }
;
opt_table: TABLE { $$ = TRUE; }
| /*EMPTY*/ { $$ = FALSE; }
;
opt_union: ALL { $$ = TRUE; }
......@@ -4603,18 +4639,24 @@ TypeId: ColId
ColId: IDENT { $$ = $1; }
| datetime { $$ = $1; }
| ACTION { $$ = "action"; }
| CACHE { $$ = "cache"; }
| CYCLE { $$ = "cycle"; }
| DATABASE { $$ = "database"; }
| DELIMITERS { $$ = "delimiters"; }
| DOUBLE { $$ = "double"; }
| EACH { $$ = "each"; }
| FUNCTION { $$ = "function"; }
| INCREMENT { $$ = "increment"; }
| INDEX { $$ = "index"; }
| KEY { $$ = "key"; }
| LANGUAGE { $$ = "language"; }
| LOCATION { $$ = "location"; }
| MATCH { $$ = "match"; }
| MAXVALUE { $$ = "maxvalue"; }
| MINVALUE { $$ = "minvalue"; }
| OPERATOR { $$ = "operator"; }
| OPTION { $$ = "option"; }
| PASSWORD { $$ = "password"; }
| PRIVILEGES { $$ = "privileges"; }
| RECIPE { $$ = "recipe"; }
| ROW { $$ = "row"; }
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.35 1998/02/11 04:09:54 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.36 1998/03/18 16:50:21 thomas Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -49,6 +49,7 @@ static ScanKeyword ScanKeywords[] = {
{"binary", BINARY},
{"both", BOTH},
{"by", BY},
{"cache", CACHE},
{"cascade", CASCADE},
{"cast", CAST},
{"char", CHAR},
......@@ -71,6 +72,7 @@ static ScanKeyword ScanKeywords[] = {
{"current_timestamp", CURRENT_TIMESTAMP},
{"current_user", CURRENT_USER},
{"cursor", CURSOR},
{"cycle", CYCLE},
{"database", DATABASE},
{"day", DAY_P},
{"decimal", DECIMAL},
......@@ -105,6 +107,7 @@ static ScanKeyword ScanKeywords[] = {
{"having", HAVING},
{"hour", HOUR_P},
{"in", IN},
{"increment", INCREMENT},
{"index", INDEX},
{"inherits", INHERITS},
{"inner", INNER_P},
......@@ -127,7 +130,9 @@ static ScanKeyword ScanKeywords[] = {
{"location", LOCATION},
{"lock", LOCK_P},
{"match", MATCH},
{"maxvalue", MAXVALUE},
{"minute", MINUTE_P},
{"minvalue", MINVALUE},
{"month", MONTH_P},
{"move", MOVE},
{"national", NATIONAL},
......@@ -176,6 +181,7 @@ static ScanKeyword ScanKeywords[] = {
{"set", SET},
{"setof", SETOF},
{"show", SHOW},
{"start", START},
{"statement", STATEMENT},
{"stdin", STDIN},
{"stdout", STDOUT},
......
......@@ -156,69 +156,75 @@ typedef union
#define BACKWARD 383
#define BEFORE 384
#define BINARY 385
#define CLUSTER 386
#define COPY 387
#define DATABASE 388
#define DELIMITERS 389
#define DO 390
#define EACH 391
#define EXPLAIN 392
#define EXTEND 393
#define FORWARD 394
#define FUNCTION 395
#define HANDLER 396
#define INDEX 397
#define INHERITS 398
#define INSTEAD 399
#define ISNULL 400
#define LANCOMPILER 401
#define LISTEN 402
#define LOAD 403
#define LOCK_P 404
#define LOCATION 405
#define MOVE 406
#define NEW 407
#define NONE 408
#define NOTHING 409
#define NOTNULL 410
#define OIDS 411
#define OPERATOR 412
#define PROCEDURAL 413
#define RECIPE 414
#define RENAME 415
#define RESET 416
#define RETURNS 417
#define ROW 418
#define RULE 419
#define SEQUENCE 420
#define SETOF 421
#define SHOW 422
#define STATEMENT 423
#define STDIN 424
#define STDOUT 425
#define TRUSTED 426
#define VACUUM 427
#define VERBOSE 428
#define VERSION 429
#define ARCHIVE 430
#define USER 431
#define PASSWORD 432
#define CREATEDB 433
#define NOCREATEDB 434
#define CREATEUSER 435
#define NOCREATEUSER 436
#define VALID 437
#define UNTIL 438
#define IDENT 439
#define SCONST 440
#define Op 441
#define ICONST 442
#define PARAM 443
#define FCONST 444
#define OP 445
#define UMINUS 446
#define TYPECAST 447
#define REDUCE 448
#define CACHE 386
#define CLUSTER 387
#define COPY 388
#define CYCLE 389
#define DATABASE 390
#define DELIMITERS 391
#define DO 392
#define EACH 393
#define EXPLAIN 394
#define EXTEND 395
#define FORWARD 396
#define FUNCTION 397
#define HANDLER 398
#define INCREMENT 399
#define INDEX 400
#define INHERITS 401
#define INSTEAD 402
#define ISNULL 403
#define LANCOMPILER 404
#define LISTEN 405
#define LOAD 406
#define LOCK_P 407
#define LOCATION 408
#define MAXVALUE 409
#define MINVALUE 410
#define MOVE 411
#define NEW 412
#define NONE 413
#define NOTHING 414
#define NOTNULL 415
#define OIDS 416
#define OPERATOR 417
#define PROCEDURAL 418
#define RECIPE 419
#define RENAME 420
#define RESET 421
#define RETURNS 422
#define ROW 423
#define RULE 424
#define SEQUENCE 425
#define SETOF 426
#define SHOW 427
#define START 428
#define STATEMENT 429
#define STDIN 430
#define STDOUT 431
#define TRUSTED 432
#define VACUUM 433
#define VERBOSE 434
#define VERSION 435
#define ARCHIVE 436
#define USER 437
#define PASSWORD 438
#define CREATEDB 439
#define NOCREATEDB 440
#define CREATEUSER 441
#define NOCREATEUSER 442
#define VALID 443
#define UNTIL 444
#define IDENT 445
#define SCONST 446
#define Op 447
#define ICONST 448
#define PARAM 449
#define FCONST 450
#define OP 451
#define UMINUS 452
#define TYPECAST 453
#define REDUCE 454
extern YYSTYPE yylval;
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.36 1998/02/18 07:22:40 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.37 1998/03/18 16:50:25 thomas Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -148,12 +148,10 @@ self [,()\[\].;$\:\+\-\*\/\<\>\=\|]
op_and_self [\~\!\@\#\%\^\&\|\`\?\$\:\+\-\*\/\<\>\=]
operator {op_and_self}+
xminteger {integer}/-
xmreal {real}/{space}*-{digit}
xmstop -
integer -?{digit}+
real -?{digit}+\.{digit}+([Ee][-+]?{digit}+)?
integer [\-]?{digit}+
real [\-]?{digit}+\.{digit}+([Ee][-+]?{digit}+)?
param \${integer}
......@@ -291,7 +289,8 @@ other .
{typecast} { return TYPECAST; }
{self}/-[\.0-9] {
{self}/{space}*-[\.0-9] {
BEGIN(xm);
return (yytext[0]);
}
{self} { return (yytext[0]); }
......@@ -311,6 +310,7 @@ other .
return (PARAM);
}
{identifier}/{space}*-{number} {
int i;
ScanKeyword *keyword;
......@@ -386,6 +386,8 @@ other .
CheckFloat8Val(yylval.dval);
return (FCONST);
}
{identifier} {
int i;
ScanKeyword *keyword;
......
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