Thread: Patches for gram.y and keywords.c

Patches for gram.y and keywords.c

From
"Thomas G. Lockhart"
Date:
Hi Michael. Here are the patches I just applied to the main parser. I'm
not sure how ecpg builds, but I also updated gram.c and parse.h to get
things properly self-consistant.

Thanks for looking at this...

                       - Tom
*** ../src/backend/parser/gram.y.orig    Fri Sep 25 13:55:16 1998
--- ../src/backend/parser/gram.y    Tue Sep 29 04:42:43 1998
***************
*** 257,313 ****
   */

  /* Keywords (in SQL92 reserved words) */
! %token    ABSOLUTE, ACTION, ADD, ALL, ALTER, AND, ANY AS, ASC,
          BEGIN_TRANS, BETWEEN, BOTH, BY,
          CASCADE, CAST, CHAR, CHARACTER, CHECK, CLOSE, COLLATE, COLUMN, COMMIT,
          CONSTRAINT, CREATE, CROSS, CURRENT, CURRENT_DATE, CURRENT_TIME,
          CURRENT_TIMESTAMP, CURRENT_USER, CURSOR,
          DAY_P, DECIMAL, DECLARE, DEFAULT, DELETE, DESC, DISTINCT, DOUBLE, DROP,
          END_TRANS, EXECUTE, EXISTS, EXTRACT,
!         FETCH, FLOAT, FOR, FOREIGN, FROM, FULL,
          GRANT, GROUP, HAVING, HOUR_P,
          IN, INNER_P, INSENSITIVE, INSERT, INTERVAL, INTO, IS,
          JOIN, KEY, LANGUAGE, LEADING, LEFT, LIKE, LOCAL,
          MATCH, MINUTE_P, MONTH_P, NAMES,
!         NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NOTIFY, NULL_P, NUMERIC,
          OF, ON, ONLY, OPTION, OR, ORDER, OUTER_P,
          PARTIAL, POSITION, PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE, PUBLIC,
          READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
          SCROLL, SECOND_P, SELECT, SET, SUBSTRING,
          TABLE, TIME, TIMESTAMP, TIMEZONE_HOUR, TIMEZONE_MINUTE,
!         TO, TRAILING, TRANSACTION, TRIM,
          UNION, UNIQUE, UPDATE, USER, USING,
          VALUES, VARCHAR, VARYING, VIEW,
          WHERE, WITH, WORK, YEAR_P, ZONE

  /* Keywords (in SQL3 reserved words) */
! %token    FALSE_P, TRIGGER, TRUE_P

  /* Keywords (in SQL92 non-reserved words) */
  %token    TYPE_P

! /* Keywords for Postgres support (not in SQL92 reserved words) */
! %token    ABORT_TRANS, AFTER, AGGREGATE, ANALYZE,
!         BACKWARD, BEFORE, BINARY, CACHE, CLUSTER, COPY, CYCLE,
!         DATABASE, DELIMITERS, DO, EACH, EXPLAIN, EXTEND,
          FORWARD, FUNCTION, HANDLER,
          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, SERIAL, SETOF, SHOW, START, STATEMENT, STDIN, STDOUT, TRUSTED,
!         VACUUM, VERBOSE, VERSION, ENCODING, UNLISTEN
!
! /* Keywords (obsolete; retain through next version for parser - thomas 1997-12-04) */
! %token    ARCHIVE
!
! /*
!  * Tokens for pg_passwd support.  The CREATEDB and CREATEUSER tokens should go away
!  * when some sort of pg_privileges relation is introduced.
!  *
!  *                                    Todd A. Brandys
!  */
! %token    PASSWORD, CREATEDB, NOCREATEDB, CREATEUSER, NOCREATEUSER, VALID, UNTIL

  /* Special keywords, not in the query language - see the "lex" file */
  %token <str>    IDENT, SCONST, Op
--- 257,308 ----
   */

  /* Keywords (in SQL92 reserved words) */
! %token    ABSOLUTE, ACTION, ADD, ALL, ALTER, AND, ANY, AS, ASC,
          BEGIN_TRANS, BETWEEN, BOTH, BY,
          CASCADE, CAST, CHAR, CHARACTER, CHECK, CLOSE, COLLATE, COLUMN, COMMIT,
          CONSTRAINT, CREATE, CROSS, CURRENT, CURRENT_DATE, CURRENT_TIME,
          CURRENT_TIMESTAMP, CURRENT_USER, CURSOR,
          DAY_P, DECIMAL, DECLARE, DEFAULT, DELETE, DESC, DISTINCT, DOUBLE, DROP,
          END_TRANS, EXECUTE, EXISTS, EXTRACT,
!         FALSE_P, FETCH, FLOAT, FOR, FOREIGN, FROM, FULL,
          GRANT, GROUP, HAVING, HOUR_P,
          IN, INNER_P, INSENSITIVE, INSERT, INTERVAL, INTO, IS,
          JOIN, KEY, LANGUAGE, LEADING, LEFT, LIKE, LOCAL,
          MATCH, MINUTE_P, MONTH_P, NAMES,
!         NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NULL_P, NUMERIC,
          OF, ON, ONLY, OPTION, OR, ORDER, OUTER_P,
          PARTIAL, POSITION, PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE, PUBLIC,
          READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
          SCROLL, SECOND_P, SELECT, SET, SUBSTRING,
          TABLE, TIME, TIMESTAMP, TIMEZONE_HOUR, TIMEZONE_MINUTE,
!         TO, TRAILING, TRANSACTION, TRIM, TRUE_P,
          UNION, UNIQUE, UPDATE, USER, USING,
          VALUES, VARCHAR, VARYING, VIEW,
          WHERE, WITH, WORK, YEAR_P, ZONE

  /* Keywords (in SQL3 reserved words) */
! %token    TRIGGER

  /* Keywords (in SQL92 non-reserved words) */
  %token    TYPE_P

! /* Keywords for Postgres support (not in SQL92 reserved words)
!  *
!  * The CREATEDB and CREATEUSER tokens should go away
!  * when some sort of pg_privileges relation is introduced.
!  * - Todd A. Brandys 1998-01-01?
!  */
! %token    ABORT_TRANS, AFTER, AGGREGATE, ANALYZE, BACKWARD, BEFORE, BINARY,
!         CACHE, CLUSTER, COPY, CREATEDB, CREATEUSER, CYCLE,
!         DATABASE, DELIMITERS, DO, EACH, ENCODING, EXPLAIN, EXTEND,
          FORWARD, FUNCTION, HANDLER,
          INCREMENT, INDEX, INHERITS, INSTEAD, ISNULL,
!         LANCOMPILER, LISTEN, LOAD, LOCATION, LOCK_P, MAXVALUE, MINVALUE, MOVE,
!         NEW, NOCREATEDB, NOCREATEUSER, NONE, NOTHING, NOTIFY, NOTNULL,
!         OIDS, OPERATOR, PASSWORD, PROCEDURAL,
          RECIPE, RENAME, RESET, RETURNS, ROW, RULE,
          SEQUENCE, SERIAL, SETOF, SHOW, START, STATEMENT, STDIN, STDOUT, TRUSTED,
!         UNLISTEN, UNTIL, VACUUM, VALID, VERBOSE, VERSION

  /* Special keywords, not in the query language - see the "lex" file */
  %token <str>    IDENT, SCONST, Op
***************
*** 709,715 ****
   *****************************************************************************/

  CreateStmt:  CREATE TABLE relation_name '(' OptTableElementList ')'
!                 OptInherit OptArchiveType
                  {
                      CreateStmt *n = makeNode(CreateStmt);
                      n->relname = $3;
--- 704,710 ----
   *****************************************************************************/

  CreateStmt:  CREATE TABLE relation_name '(' OptTableElementList ')'
!                 OptInherit
                  {
                      CreateStmt *n = makeNode(CreateStmt);
                      n->relname = $3;
***************
*** 1197,1210 ****
          | /*EMPTY*/                                        { $$ = NIL; }
          ;

- /*
-  *    "ARCHIVE" keyword was removed in 6.3, but we keep it for now
-  *  so people can upgrade with old pg_dump scripts. - momjian 1997-11-20(?)
-  */
- OptArchiveType:  ARCHIVE '=' NONE                        { }
-         | /*EMPTY*/                                        { }
-         ;
-
  CreateAsStmt:  CREATE TABLE relation_name OptCreateAs AS SubSelect
                  {
                      SelectStmt *n = (SelectStmt *)$6;
--- 1192,1197 ----
***************
*** 4646,4688 ****
--- 4633,4700 ----
          | datetime                        { $$ = $1; }
          | ABSOLUTE                        { $$ = "absolute"; }
          | ACTION                        { $$ = "action"; }
+         | AFTER                            { $$ = "after"; }
+         | AGGREGATE                        { $$ = "aggregate"; }
+         | BACKWARD                        { $$ = "backward"; }
+         | BEFORE                        { $$ = "before"; }
          | CACHE                            { $$ = "cache"; }
+         | CREATEDB                        { $$ = "createdb"; }
+         | CREATEUSER                    { $$ = "createuser"; }
          | CYCLE                            { $$ = "cycle"; }
          | DATABASE                        { $$ = "database"; }
          | DELIMITERS                    { $$ = "delimiters"; }
          | DOUBLE                        { $$ = "double"; }
          | EACH                            { $$ = "each"; }
          | ENCODING                        { $$ = "encoding"; }
+         | FORWARD                        { $$ = "forward"; }
          | FUNCTION                        { $$ = "function"; }
+         | HANDLER                        { $$ = "handler"; }
          | INCREMENT                        { $$ = "increment"; }
          | INDEX                            { $$ = "index"; }
+         | INHERITS                        { $$ = "inherits"; }
          | INSENSITIVE                    { $$ = "insensitive"; }
+         | INSTEAD                        { $$ = "instead"; }
+         | ISNULL                        { $$ = "isnull"; }
          | KEY                            { $$ = "key"; }
          | LANGUAGE                        { $$ = "language"; }
+         | LANCOMPILER                    { $$ = "lancompiler"; }
          | LOCATION                        { $$ = "location"; }
          | MATCH                            { $$ = "match"; }
          | MAXVALUE                        { $$ = "maxvalue"; }
          | MINVALUE                        { $$ = "minvalue"; }
          | NEXT                            { $$ = "next"; }
+         | NOCREATEDB                    { $$ = "nocreatedb"; }
+         | NOCREATEUSER                    { $$ = "nocreateuser"; }
+         | NOTHING                        { $$ = "nothing"; }
+         | NOTNULL                        { $$ = "notnull"; }
          | OF                            { $$ = "of"; }
+         | OIDS                            { $$ = "oids"; }
          | ONLY                            { $$ = "only"; }
          | OPERATOR                        { $$ = "operator"; }
          | OPTION                        { $$ = "option"; }
          | PASSWORD                        { $$ = "password"; }
          | PRIOR                            { $$ = "prior"; }
          | PRIVILEGES                    { $$ = "privileges"; }
+         | PROCEDURAL                    { $$ = "procedural"; }
          | READ                            { $$ = "read"; }
          | RECIPE                        { $$ = "recipe"; }
          | RELATIVE                        { $$ = "relative"; }
+         | RENAME                        { $$ = "rename"; }
+         | RETURNS                        { $$ = "returns"; }
          | ROW                            { $$ = "row"; }
+         | RULE                            { $$ = "rule"; }
          | SCROLL                        { $$ = "scroll"; }
+         | SEQUENCE                        { $$ = "sequence"; }
          | SERIAL                        { $$ = "serial"; }
          | START                            { $$ = "start"; }
          | STATEMENT                        { $$ = "statement"; }
+         | STDIN                            { $$ = "stdin"; }
+         | STDOUT                        { $$ = "stdout"; }
          | TIME                            { $$ = "time"; }
          | TIMEZONE_HOUR                    { $$ = "timezone_hour"; }
          | TIMEZONE_MINUTE                { $$ = "timezone_minute"; }
          | TRIGGER                        { $$ = "trigger"; }
+         | TRUSTED                        { $$ = "trusted"; }
          | TYPE_P                        { $$ = "type"; }
          | VALID                            { $$ = "valid"; }
          | VERSION                        { $$ = "version"; }
***************
*** 4700,4719 ****
   *  when used as a full identifier. - thomas 1997-11-06
   */
  ColLabel:  ColId                        { $$ = $1; }
!         | ARCHIVE                        { $$ = "archive"; }
          | CLUSTER                        { $$ = "cluster"; }
          | CONSTRAINT                    { $$ = "constraint"; }
          | CROSS                            { $$ = "cross"; }
          | FOREIGN                        { $$ = "foreign"; }
          | GROUP                            { $$ = "group"; }
          | LOAD                            { $$ = "load"; }
          | ORDER                            { $$ = "order"; }
          | POSITION                        { $$ = "position"; }
          | PRECISION                        { $$ = "precision"; }
          | TABLE                            { $$ = "table"; }
          | TRANSACTION                    { $$ = "transaction"; }
          | TRUE_P                        { $$ = "true"; }
!         | FALSE_P                        { $$ = "false"; }
          ;

  SpecialRuleRelation:  CURRENT
--- 4712,4748 ----
   *  when used as a full identifier. - thomas 1997-11-06
   */
  ColLabel:  ColId                        { $$ = $1; }
!         | ABORT_TRANS                    { $$ = "abort"; }
!         | ANALYZE                        { $$ = "analyze"; }
!         | BINARY                        { $$ = "binary"; }
          | CLUSTER                        { $$ = "cluster"; }
          | CONSTRAINT                    { $$ = "constraint"; }
+         | COPY                            { $$ = "copy"; }
          | CROSS                            { $$ = "cross"; }
+         | CURRENT                        { $$ = "current"; }
+         | DO                            { $$ = "do"; }
+         | EXPLAIN                        { $$ = "explain"; }
+         | EXTEND                        { $$ = "extend"; }
+         | FALSE_P                        { $$ = "false"; }
          | FOREIGN                        { $$ = "foreign"; }
          | GROUP                            { $$ = "group"; }
+         | LISTEN                        { $$ = "listen"; }
          | LOAD                            { $$ = "load"; }
+         | LOCK_P                        { $$ = "lock"; }
+         | MOVE                            { $$ = "move"; }
+         | NEW                            { $$ = "new"; }
+         | NONE                            { $$ = "none"; }
          | ORDER                            { $$ = "order"; }
          | POSITION                        { $$ = "position"; }
          | PRECISION                        { $$ = "precision"; }
+         | RESET                            { $$ = "reset"; }
+         | SETOF                            { $$ = "setof"; }
+         | SHOW                            { $$ = "show"; }
          | TABLE                            { $$ = "table"; }
          | TRANSACTION                    { $$ = "transaction"; }
          | TRUE_P                        { $$ = "true"; }
!         | VACUUM                        { $$ = "vacuum"; }
!         | VERBOSE                        { $$ = "verbose"; }
          ;

  SpecialRuleRelation:  CURRENT
*** ../src/backend/parser/keywords.c.orig    Sun Sep 13 04:35:12 1998
--- ../src/backend/parser/keywords.c    Mon Sep 28 05:59:20 1998
***************
*** 40,46 ****
      {"analyze", ANALYZE},
      {"and", AND},
      {"any", ANY},
-     {"archive", ARCHIVE},
      {"as", AS},
      {"asc", ASC},
      {"backward", BACKWARD},
--- 40,45 ----
***************
*** 116,121 ****
--- 115,121 ----
      {"inherits", INHERITS},
      {"inner", INNER_P},
      {"insert", INSERT},
+     {"insensitive", INSENSITIVE},
      {"instead", INSTEAD},
      {"interval", INTERVAL},
      {"into", INTO},
***************
*** 202,207 ****
--- 202,208 ----
      {"substring", SUBSTRING},
      {"table", TABLE},
      {"time", TIME},
+     {"timestamp", TIMESTAMP},
      {"timezone_hour", TIMEZONE_HOUR},
      {"timezone_minute", TIMEZONE_MINUTE},
      {"to", TO},