*** src/backend/parser/gram.y.orig Mon Nov 5 00:00:14 2001 --- src/backend/parser/gram.y Thu Nov 8 19:00:24 2001 *************** *** 257,264 **** %type ParamNo %type Typename, SimpleTypename, ConstTypename ! GenericType, Numeric, Geometric, Character, ConstDatetime, ConstInterval, Bit ! %type character, datetime, bit %type extract_arg %type opt_charset, opt_collate %type opt_float --- 257,264 ---- %type ParamNo %type Typename, SimpleTypename, ConstTypename ! GenericType, Numeric, Character, ConstDatetime, ConstInterval, Bit ! %type character, bit %type extract_arg %type opt_charset, opt_collate %type opt_float *************** *** 268,274 **** %type Iconst %type Sconst, comment_text %type UserId, opt_boolean, var_value, ColId_or_Sconst ! %type ColId, ColLabel, TokenId %type zone_value %type TableConstraint --- 268,274 ---- %type Iconst %type Sconst, comment_text %type UserId, opt_boolean, var_value, ColId_or_Sconst ! %type ColId, TypeFuncId, ColLabel %type zone_value %type TableConstraint *************** *** 1007,1017 **** ; ! constraints_set_namelist: IDENT { $$ = makeList1($1); } ! | constraints_set_namelist ',' IDENT { $$ = lappend($1, $3); } --- 1007,1017 ---- ; ! constraints_set_namelist: ColId { $$ = makeList1($1); } ! | constraints_set_namelist ',' ColId { $$ = lappend($1, $3); } *************** *** 2007,2014 **** } ; def_arg: func_return { $$ = (Node *)$1; } - | TokenId { $$ = (Node *)makeString($1); } | all_Op { $$ = (Node *)makeString($1); } | NumericOnly { $$ = (Node *)$1; } | Sconst { $$ = (Node *)makeString($1); } --- 2007,2014 ---- } ; + /* Note: any simple identifier will be returned as a type name! */ def_arg: func_return { $$ = (Node *)$1; } | all_Op { $$ = (Node *)makeString($1); } | NumericOnly { $$ = (Node *)$1; } | Sconst { $$ = (Node *)makeString($1); } *************** *** 2629,2639 **** } ; func_type: Typename { $$ = $1; } ! | IDENT '.' ColId '%' TYPE_P { $$ = makeNode(TypeName); $$->name = $1; --- 2629,2643 ---- } ; + /* + * We would like to make the second production here be ColId '.' ColId etc, + * but that causes reduce/reduce conflicts. TypeFuncId is next best choice. + */ func_type: Typename { $$ = $1; } ! | TypeFuncId '.' ColId '%' TYPE_P { $$ = makeNode(TypeName); $$->name = $1; *************** *** 4064,4076 **** ConstTypename: GenericType | Numeric - | Geometric | Bit | Character | ConstDatetime ; ! GenericType: IDENT { $$ = makeNode(TypeName); $$->name = xlateSqlType($1); --- 4068,4079 ---- ConstTypename: GenericType | Numeric | Bit | Character | ConstDatetime ; ! GenericType: TypeFuncId { $$ = makeNode(TypeName); $$->name = xlateSqlType($1); *************** *** 4086,4092 **** Numeric: FLOAT opt_float { $$ = makeNode(TypeName); ! $$->name = xlateSqlType($2); $$->typmod = -1; } | DOUBLE PRECISION --- 4089,4095 ---- Numeric: FLOAT opt_float { $$ = makeNode(TypeName); ! $$->name = $2; /* already xlated */ $$->typmod = -1; } | DOUBLE PRECISION *************** *** 4115,4128 **** } ; - Geometric: PATH_P - { - $$ = makeNode(TypeName); - $$->name = xlateSqlType("path"); - $$->typmod = -1; - } - ; - opt_float: '(' Iconst ')' { if ($2 < 1) --- 4118,4123 ---- *************** *** 4299,4311 **** | /*EMPTY*/ { $$ = NULL; } ; ! ConstDatetime: datetime ! { ! $$ = makeNode(TypeName); ! $$->name = xlateSqlType($1); ! $$->typmod = -1; ! } ! | TIMESTAMP '(' Iconst ')' opt_timezone_x { $$ = makeNode(TypeName); if ($5) --- 4294,4300 ---- | /*EMPTY*/ { $$ = NULL; } ; ! ConstDatetime: TIMESTAMP '(' Iconst ')' opt_timezone_x { $$ = makeNode(TypeName); if ($5) *************** *** 4371,4384 **** } ; - datetime: YEAR_P { $$ = "year"; } - | MONTH_P { $$ = "month"; } - | DAY_P { $$ = "day"; } - | HOUR_P { $$ = "hour"; } - | MINUTE_P { $$ = "minute"; } - | SECOND_P { $$ = "second"; } - ; - /* XXX Make the default be WITH TIME ZONE for 7.2 to help with database upgrades * but revert this back to WITHOUT TIME ZONE for 7.3. * Do this by simply reverting opt_timezone_x to opt_timezone - thomas 2001-09-06 --- 4360,4365 ---- *************** *** 5270,5278 **** * - thomas 2001-04-12 */ ! extract_arg: datetime { $$ = $1; } ! | SCONST { $$ = $1; } ! | IDENT { $$ = $1; } ; /* position_list uses b_expr not a_expr to avoid conflict with general IN */ --- 5251,5264 ---- * - thomas 2001-04-12 */ ! extract_arg: IDENT { $$ = $1; } ! | YEAR_P { $$ = "year"; } ! | MONTH_P { $$ = "month"; } ! | DAY_P { $$ = "day"; } ! | HOUR_P { $$ = "hour"; } ! | MINUTE_P { $$ = "minute"; } ! | SECOND_P { $$ = "second"; } ! | SCONST { $$ = $1; } ; /* position_list uses b_expr not a_expr to avoid conflict with general IN */ *************** *** 5555,5586 **** attr_name: ColId { $$ = $1; }; class: ColId { $$ = $1; }; index_name: ColId { $$ = $1; }; - - /* Functions - * Include date/time keywords as SQL92 extension. - * Include TYPE as a SQL92 unreserved keyword. - thomas 1997-10-05 - * Any tokens which show up as operators will screw up the parsing if - * allowed as identifiers, but are acceptable as ColLabels: - * BETWEEN, IN, IS, ISNULL, NOTNULL, OVERLAPS - * Thanks to Tom Lane for pointing this out. - thomas 2000-03-29 - * We need OVERLAPS allowed as a function name to enable the implementation - * of argument type variations on the underlying implementation. These - * variations are done as SQL-language entries in the pg_proc catalog. - * Do not include SUBSTRING here since it has explicit productions - * in a_expr to support the goofy SQL9x argument syntax. - * - thomas 2000-11-28 - */ - func_name: ColId { $$ = xlateSqlFunc($1); } - | BETWEEN { $$ = xlateSqlFunc("between"); } - | ILIKE { $$ = xlateSqlFunc("ilike"); } - | IN { $$ = xlateSqlFunc("in"); } - | IS { $$ = xlateSqlFunc("is"); } - | ISNULL { $$ = xlateSqlFunc("isnull"); } - | LIKE { $$ = xlateSqlFunc("like"); } - | NOTNULL { $$ = xlateSqlFunc("notnull"); } - | OVERLAPS { $$ = xlateSqlFunc("overlaps"); } - ; - file_name: Sconst { $$ = $1; }; /* Constants --- 5541,5546 ---- *************** *** 5692,5718 **** Sconst: SCONST { $$ = $1; }; UserId: ColId { $$ = $1; }; ! /* Column identifier ! * Include date/time keywords as SQL92 extension. ! * 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: IDENT { $$ = $1; } ! | datetime { $$ = $1; } ! | TokenId { $$ = $1; } ! | NATIONAL { $$ = "national"; } | NONE { $$ = "none"; } ! | PATH_P { $$ = "path"; } ; ! /* Parser tokens to be used as identifiers. ! * Tokens involving data types should appear in ColId only, ! * since they will conflict with real TypeName productions. */ ! TokenId: ABSOLUTE { $$ = "absolute"; } | ACCESS { $$ = "access"; } | ACTION { $$ = "action"; } | ADD { $$ = "add"; } --- 5652,5729 ---- Sconst: SCONST { $$ = $1; }; UserId: ColId { $$ = $1; }; ! /* Column identifier --- names that can be column, table, etc names. ! * ! * This contains the TypeFuncId list plus those keywords that conflict ! * only with typename productions, not with other uses. Note that ! * most of these keywords will in fact be recognized as type names too; ! * they just have to have special productions for the purpose. ! * ! * Most of these cannot be in TypeFuncId (ie, are not also usable as function ! * names) because they can be followed by '(' in typename productions, which ! * looks too much like a function call for a LALR(1) parser. ! */ ! ColId: TypeFuncId { $$ = $1; } ! | BIT { $$ = "bit"; } ! | CHAR { $$ = "char"; } ! | CHARACTER { $$ = "character"; } ! | DEC { $$ = "dec"; } ! | DECIMAL { $$ = "decimal"; } ! | FLOAT { $$ = "float"; } ! | INTERVAL { $$ = "interval"; } ! | NCHAR { $$ = "nchar"; } | NONE { $$ = "none"; } ! | NUMERIC { $$ = "numeric"; } ! | SETOF { $$ = "setof"; } ! | TIME { $$ = "time"; } ! | TIMESTAMP { $$ = "timestamp"; } ! | VARCHAR { $$ = "varchar"; } ! ; ! ! /* Function identifier --- names that can be function names. ! * ! * This contains the TypeFuncId list plus some ColLabel keywords ! * that are used as operators in expressions; in general such keywords ! * can't be ColId because they would be ambiguous with variable names, ! * but they are unambiguous as function identifiers. ! * ! * Do not include POSITION, SUBSTRING, etc here since they have explicit ! * productions in a_expr to support the goofy SQL9x argument syntax. ! * - thomas 2000-11-28 ! */ ! func_name: TypeFuncId { $$ = xlateSqlFunc($1); } ! | BETWEEN { $$ = xlateSqlFunc("between"); } ! | BINARY { $$ = xlateSqlFunc("binary"); } ! | CROSS { $$ = xlateSqlFunc("cross"); } ! | FREEZE { $$ = xlateSqlFunc("freeze"); } ! | FULL { $$ = xlateSqlFunc("full"); } ! | ILIKE { $$ = xlateSqlFunc("ilike"); } ! | IN { $$ = xlateSqlFunc("in"); } ! | INNER_P { $$ = xlateSqlFunc("inner"); } ! | IS { $$ = xlateSqlFunc("is"); } ! | ISNULL { $$ = xlateSqlFunc("isnull"); } ! | JOIN { $$ = xlateSqlFunc("join"); } ! | LEFT { $$ = xlateSqlFunc("left"); } ! | LIKE { $$ = xlateSqlFunc("like"); } ! | NATURAL { $$ = xlateSqlFunc("natural"); } ! | NOTNULL { $$ = xlateSqlFunc("notnull"); } ! | OUTER_P { $$ = xlateSqlFunc("outer"); } ! | OVERLAPS { $$ = xlateSqlFunc("overlaps"); } ! | PUBLIC { $$ = xlateSqlFunc("public"); } ! | RIGHT { $$ = xlateSqlFunc("right"); } ! | VERBOSE { $$ = xlateSqlFunc("verbose"); } ; ! /* Type/func identifier --- names that can be type and function names ! * (as well as ColIds --- ie, these are unreserved keywords). ! * ! * Every new keyword should be added to this list unless ! * doing so produces a shift/reduce or reduce/reduce conflict. ! * If so, make it a ColId, or failing that a ColLabel. */ ! TypeFuncId: IDENT { $$ = $1; } ! | ABORT_TRANS { $$ = "abort"; } ! | ABSOLUTE { $$ = "absolute"; } | ACCESS { $$ = "access"; } | ACTION { $$ = "action"; } | ADD { $$ = "add"; } *************** *** 5731,5746 **** --- 5742,5760 ---- | CHARACTERISTICS { $$ = "characteristics"; } | CHECKPOINT { $$ = "checkpoint"; } | CLOSE { $$ = "close"; } + | CLUSTER { $$ = "cluster"; } | COMMENT { $$ = "comment"; } | COMMIT { $$ = "commit"; } | COMMITTED { $$ = "committed"; } | CONSTRAINTS { $$ = "constraints"; } + | COPY { $$ = "copy"; } | CREATE { $$ = "create"; } | CREATEDB { $$ = "createdb"; } | CREATEUSER { $$ = "createuser"; } | CURSOR { $$ = "cursor"; } | CYCLE { $$ = "cycle"; } | DATABASE { $$ = "database"; } + | DAY_P { $$ = "day"; } | DECLARE { $$ = "declare"; } | DEFERRED { $$ = "deferred"; } | DELETE { $$ = "delete"; } *************** *** 5753,5768 **** --- 5767,5786 ---- | ESCAPE { $$ = "escape"; } | EXCLUSIVE { $$ = "exclusive"; } | EXECUTE { $$ = "execute"; } + | EXPLAIN { $$ = "explain"; } | FETCH { $$ = "fetch"; } | FORCE { $$ = "force"; } | FORWARD { $$ = "forward"; } | FUNCTION { $$ = "function"; } + | GLOBAL { $$ = "global"; } | GRANT { $$ = "grant"; } | HANDLER { $$ = "handler"; } + | HOUR_P { $$ = "hour"; } | IMMEDIATE { $$ = "immediate"; } | INCREMENT { $$ = "increment"; } | INDEX { $$ = "index"; } | INHERITS { $$ = "inherits"; } + | INOUT { $$ = "inout"; } | INSENSITIVE { $$ = "insensitive"; } | INSERT { $$ = "insert"; } | INSTEAD { $$ = "instead"; } *************** *** 5771,5782 **** --- 5789,5808 ---- | LANGUAGE { $$ = "language"; } | LANCOMPILER { $$ = "lancompiler"; } | LEVEL { $$ = "level"; } + | LISTEN { $$ = "listen"; } + | LOAD { $$ = "load"; } + | LOCAL { $$ = "local"; } | LOCATION { $$ = "location"; } + | LOCK_P { $$ = "lock"; } | MATCH { $$ = "match"; } | MAXVALUE { $$ = "maxvalue"; } + | MINUTE_P { $$ = "minute"; } | MINVALUE { $$ = "minvalue"; } | MODE { $$ = "mode"; } + | MONTH_P { $$ = "month"; } + | MOVE { $$ = "move"; } | NAMES { $$ = "names"; } + | NATIONAL { $$ = "national"; } | NEXT { $$ = "next"; } | NO { $$ = "no"; } | NOCREATEDB { $$ = "nocreatedb"; } *************** *** 5787,5796 **** --- 5813,5825 ---- | OIDS { $$ = "oids"; } | OPERATOR { $$ = "operator"; } | OPTION { $$ = "option"; } + | OUT { $$ = "out"; } | OWNER { $$ = "owner"; } | PARTIAL { $$ = "partial"; } | PASSWORD { $$ = "password"; } + | PATH_P { $$ = "path"; } | PENDANT { $$ = "pendant"; } + | PRECISION { $$ = "precision"; } | PRIOR { $$ = "prior"; } | PRIVILEGES { $$ = "privileges"; } | PROCEDURAL { $$ = "procedural"; } *************** *** 5800,5805 **** --- 5829,5835 ---- | RELATIVE { $$ = "relative"; } | RENAME { $$ = "rename"; } | REPLACE { $$ = "replace"; } + | RESET { $$ = "reset"; } | RESTRICT { $$ = "restrict"; } | RETURNS { $$ = "returns"; } | REVOKE { $$ = "revoke"; } *************** *** 5808,5818 **** --- 5838,5850 ---- | RULE { $$ = "rule"; } | SCHEMA { $$ = "schema"; } | SCROLL { $$ = "scroll"; } + | SECOND_P { $$ = "second"; } | SESSION { $$ = "session"; } | SEQUENCE { $$ = "sequence"; } | SERIALIZABLE { $$ = "serializable"; } | SET { $$ = "set"; } | SHARE { $$ = "share"; } + | SHOW { $$ = "show"; } | START { $$ = "start"; } | STATEMENT { $$ = "statement"; } | STATISTICS { $$ = "statistics"; } *************** *** 5823,5836 **** --- 5855,5871 ---- | TEMPLATE { $$ = "template"; } | TEMPORARY { $$ = "temporary"; } | TOAST { $$ = "toast"; } + | TRANSACTION { $$ = "transaction"; } | TRIGGER { $$ = "trigger"; } | TRUNCATE { $$ = "truncate"; } | TRUSTED { $$ = "trusted"; } | TYPE_P { $$ = "type"; } | UNENCRYPTED { $$ = "unencrypted"; } + | UNKNOWN { $$ = "unknown"; } | UNLISTEN { $$ = "unlisten"; } | UNTIL { $$ = "until"; } | UPDATE { $$ = "update"; } + | VACUUM { $$ = "vacuum"; } | VALID { $$ = "valid"; } | VALUES { $$ = "values"; } | VARYING { $$ = "varying"; } *************** *** 5839,5859 **** | WITH { $$ = "with"; } | WITHOUT { $$ = "without"; } | WORK { $$ = "work"; } | ZONE { $$ = "zone"; } ; ! /* Column label ! * Allowed labels in "AS" clauses. ! * Include TRUE/FALSE SQL3 reserved words for Postgres backward ! * compatibility. Cannot allow this for column names since the ! * syntax would not distinguish between the constant value and ! * 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; } - | ABORT_TRANS { $$ = "abort"; } | ALL { $$ = "all"; } | ANALYSE { $$ = "analyse"; } /* British */ | ANALYZE { $$ = "analyze"; } --- 5874,5893 ---- | WITH { $$ = "with"; } | WITHOUT { $$ = "without"; } | WORK { $$ = "work"; } + | YEAR_P { $$ = "year"; } | ZONE { $$ = "zone"; } ; ! /* Column label --- allowed labels in "AS" clauses. ! * ! * Keywords should appear here if they could not be distinguished ! * from variable, type, or function names in some contexts. ! * ! * At present, every keyword except "AS" itself should appear in ! * one of ColId, TypeFuncId, or ColLabel. When adding a ColLabel, ! * also consider whether it can be added to func_name. */ ColLabel: ColId { $$ = $1; } | ALL { $$ = "all"; } | ANALYSE { $$ = "analyse"; } /* British */ | ANALYZE { $$ = "analyze"; } *************** *** 5862,5887 **** | ASC { $$ = "asc"; } | BETWEEN { $$ = "between"; } | BINARY { $$ = "binary"; } - | BIT { $$ = "bit"; } | BOTH { $$ = "both"; } | CASE { $$ = "case"; } | CAST { $$ = "cast"; } - | CHAR { $$ = "char"; } - | CHARACTER { $$ = "character"; } | CHECK { $$ = "check"; } - | CLUSTER { $$ = "cluster"; } | COALESCE { $$ = "coalesce"; } | COLLATE { $$ = "collate"; } | COLUMN { $$ = "column"; } | CONSTRAINT { $$ = "constraint"; } - | COPY { $$ = "copy"; } | CROSS { $$ = "cross"; } | CURRENT_DATE { $$ = "current_date"; } | CURRENT_TIME { $$ = "current_time"; } | CURRENT_TIMESTAMP { $$ = "current_timestamp"; } | CURRENT_USER { $$ = "current_user"; } - | DEC { $$ = "dec"; } - | DECIMAL { $$ = "decimal"; } | DEFAULT { $$ = "default"; } | DEFERRABLE { $$ = "deferrable"; } | DESC { $$ = "desc"; } --- 5896,5914 ---- *************** *** 5891,5915 **** | END_TRANS { $$ = "end"; } | EXCEPT { $$ = "except"; } | EXISTS { $$ = "exists"; } - | EXPLAIN { $$ = "explain"; } | EXTRACT { $$ = "extract"; } | FALSE_P { $$ = "false"; } - | FLOAT { $$ = "float"; } | FOR { $$ = "for"; } | FOREIGN { $$ = "foreign"; } | FREEZE { $$ = "freeze"; } | FROM { $$ = "from"; } | FULL { $$ = "full"; } - | GLOBAL { $$ = "global"; } | GROUP { $$ = "group"; } | HAVING { $$ = "having"; } | ILIKE { $$ = "ilike"; } | IN { $$ = "in"; } | INITIALLY { $$ = "initially"; } | INNER_P { $$ = "inner"; } - | INOUT { $$ = "inout"; } | INTERSECT { $$ = "intersect"; } - | INTERVAL { $$ = "interval"; } | INTO { $$ = "into"; } | IS { $$ = "is"; } | ISNULL { $$ = "isnull"; } --- 5918,5937 ---- *************** *** 5918,5936 **** | LEFT { $$ = "left"; } | LIKE { $$ = "like"; } | LIMIT { $$ = "limit"; } - | LISTEN { $$ = "listen"; } - | LOAD { $$ = "load"; } - | LOCAL { $$ = "local"; } - | LOCK_P { $$ = "lock"; } - | MOVE { $$ = "move"; } | NATURAL { $$ = "natural"; } - | NCHAR { $$ = "nchar"; } | NEW { $$ = "new"; } | NOT { $$ = "not"; } | NOTNULL { $$ = "notnull"; } | NULLIF { $$ = "nullif"; } | NULL_P { $$ = "null"; } - | NUMERIC { $$ = "numeric"; } | OFF { $$ = "off"; } | OFFSET { $$ = "offset"; } | OLD { $$ = "old"; } --- 5940,5951 ---- *************** *** 5938,5975 **** | ONLY { $$ = "only"; } | OR { $$ = "or"; } | ORDER { $$ = "order"; } - | OUT { $$ = "out"; } | OUTER_P { $$ = "outer"; } | OVERLAPS { $$ = "overlaps"; } | POSITION { $$ = "position"; } - | PRECISION { $$ = "precision"; } | PRIMARY { $$ = "primary"; } | PUBLIC { $$ = "public"; } | REFERENCES { $$ = "references"; } - | RESET { $$ = "reset"; } | RIGHT { $$ = "right"; } | SELECT { $$ = "select"; } | SESSION_USER { $$ = "session_user"; } - | SETOF { $$ = "setof"; } - | SHOW { $$ = "show"; } | SOME { $$ = "some"; } | SUBSTRING { $$ = "substring"; } | TABLE { $$ = "table"; } | THEN { $$ = "then"; } - | TIME { $$ = "time"; } - | TIMESTAMP { $$ = "timestamp"; } | TO { $$ = "to"; } | TRAILING { $$ = "trailing"; } - | TRANSACTION { $$ = "transaction"; } | TRIM { $$ = "trim"; } | TRUE_P { $$ = "true"; } | UNION { $$ = "union"; } | UNIQUE { $$ = "unique"; } - | UNKNOWN { $$ = "unknown"; } | USER { $$ = "user"; } | USING { $$ = "using"; } - | VACUUM { $$ = "vacuum"; } - | VARCHAR { $$ = "varchar"; } | VERBOSE { $$ = "verbose"; } | WHEN { $$ = "when"; } | WHERE { $$ = "where"; } --- 5953,5979 ----