-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.319 2006/02/04 20:54:42 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.348 2007/07/25 16:10:41 meskes Exp $ */
/* Copyright comment */
%{
#include "postgres_fe.h"
#include "extern.h"
+#include <unistd.h>
+
+/* Location tracking support --- simpler than bison's default */
+#define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do { \
+ if (N) \
+ (Current) = (Rhs)[1]; \
+ else \
+ (Current) = (Rhs)[0]; \
+ } while (0)
+
+/*
+ * The %name-prefix option below will make bison call base_yylex, but we
+ * really want it to call filtered_base_yylex (see parser.c).
+ */
+#define base_yylex filtered_base_yylex
/*
* Variables containing simple states.
struct ECPGtype ecpg_query = {ECPGt_char_variable, 0L, NULL, {NULL}};
+/* INFORMIX workaround, no longer needed
static struct inf_compat_col
{
char *name;
char *val;
struct inf_compat_val *next;
} *informix_val;
+*/
/*
* Handle parsing errors and warnings
ret_value = error_code;
break;
case ET_FATAL:
+ fclose(yyin);
+ fclose(yyout);
+ if (unlink(output_filename) != 0 && *output_filename != '-')
+ fprintf(stderr, "Could not remove output file %s!\n", output_filename);
exit(error_code);
}
}
mmerror(PARSE_ERROR, ET_ERROR, "trying to access an undeclared cursor %s\n", name);
return NULL;
}
+
if (insert)
{
/* add all those input variables that were given earlier
}
%}
+%name-prefix="base_yy"
+%locations
+
%union {
double dval;
char *str;
/* special embedded SQL token */
%token SQL_ALLOCATE SQL_AUTOCOMMIT SQL_BOOL SQL_BREAK
SQL_CALL SQL_CARDINALITY SQL_CONNECT
- SQL_CONTINUE SQL_COUNT SQL_CURRENT SQL_DATA
+ SQL_CONTINUE SQL_COUNT SQL_DATA
SQL_DATETIME_INTERVAL_CODE
SQL_DATETIME_INTERVAL_PRECISION SQL_DESCRIBE
- SQL_DESCRIPTOR SQL_DISCONNECT SQL_ENUM SQL_FOUND
+ SQL_DESCRIPTOR SQL_DISCONNECT SQL_FOUND
SQL_FREE SQL_GO SQL_GOTO SQL_IDENTIFIED
SQL_INDICATOR SQL_KEY_MEMBER SQL_LENGTH
- SQL_LONG SQL_NAME SQL_NULLABLE SQL_OCTET_LENGTH
+ SQL_LONG SQL_NULLABLE SQL_OCTET_LENGTH
SQL_OPEN SQL_OUTPUT SQL_REFERENCE
SQL_RETURNED_LENGTH SQL_RETURNED_OCTET_LENGTH SQL_SCALE
SQL_SECTION SQL_SHORT SQL_SIGNED SQL_SQL SQL_SQLERROR
SQL_SQLPRINT SQL_SQLWARNING SQL_START SQL_STOP
- SQL_STRUCT SQL_UNSIGNED SQL_VALUE SQL_VAR SQL_WHENEVER
+ SQL_STRUCT SQL_UNSIGNED SQL_VAR SQL_WHENEVER
/* C token */
%token S_ADD S_AND S_ANYTHING S_AUTO S_CONST S_DEC S_DIV
/* ordinary key words in alphabetical order */
%token <keyword> ABORT_P ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER
- AGGREGATE ALL ALSO ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC
+ AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC
ASSERTION ASSIGNMENT ASYMMETRIC AT AUTHORIZATION
BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
BOOLEAN_P BOTH BY
- CACHE CALLED CASCADE CASE CAST CHAIN CHAR_P
+ CACHE CALLED CASCADE CASCADED CASE CAST CHAIN CHAR_P
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT
- COMMITTED CONNECTION CONSTRAINT CONSTRAINTS CONVERSION_P CONVERT COPY CREATE CREATEDB
- CREATEROLE CREATEUSER CROSS CSV CURRENT_DATE CURRENT_ROLE CURRENT_TIME
- CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
+ COMMITTED CONCURRENTLY CONNECTION CONSTRAINT CONSTRAINTS
+ CONTENT_P CONVERSION_P CONVERT COPY COST CREATE CREATEDB
+ CREATEROLE CREATEUSER CROSS CSV CURRENT_P CURRENT_DATE CURRENT_ROLE
+ CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS
- DESC DISABLE_P DISTINCT DO DOMAIN_P DOUBLE_P DROP
+ DESC DISABLE_P DISCARD DISTINCT DO DOCUMENT_P DOMAIN_P DOUBLE_P DROP
- EACH ELSE ENABLE_P ENCODING ENCRYPTED END_P ESCAPE EXCEPT EXCLUSIVE EXCLUDING
+ EACH ELSE ENABLE_P ENCODING ENCRYPTED END_P ENUM_P ESCAPE EXCEPT EXCLUSIVE EXCLUDING
EXECUTE EXISTS EXPLAIN EXTERNAL EXTRACT
- FALSE_P FETCH FIRST_P FLOAT_P FOR FORCE FOREIGN FORWARD FREEZE FROM
+ FALSE_P FAMILY FETCH FIRST_P FLOAT_P FOR FORCE FOREIGN FORWARD FREEZE FROM
FULL FUNCTION
GET GLOBAL GRANT GRANTED GREATEST GROUP_P
HANDLER HAVING HEADER_P HOLD HOUR_P
IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IN_P INCLUDING INCREMENT
- INDEX INHERIT INHERITS INITIALLY INNER_P INOUT INPUT_P
+ INDEX INDEXES INHERIT INHERITS INITIALLY INNER_P INOUT INPUT_P
INSENSITIVE INSERT INSTEAD INT_P INTEGER INTERSECT
INTERVAL INTO INVOKER IS ISNULL ISOLATION
MATCH MAXVALUE MINUTE_P MINVALUE MODE MONTH_P MOVE
- NAMES NATIONAL NATURAL NCHAR NEW NEXT NO NOCREATEDB
+ NAME_P NAMES NATIONAL NATURAL NCHAR NEW NEXT NO NOCREATEDB
NOCREATEROLE NOCREATEUSER NOINHERIT NOLOGIN_P NONE NOSUPERUSER
- NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF NUMERIC
+ NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF NULLS_P NUMERIC
OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OR ORDER
OUT_P OUTER_P OVERLAPS OVERLAY OWNED OWNER
- PARTIAL PASSWORD PLACING POSITION
+ PARTIAL PASSWORD PLACING PLANS POSITION
PRECISION PRESERVE PREPARE PREPARED PRIMARY
PRIOR PRIVILEGES PROCEDURAL PROCEDURE
QUOTE
READ REAL REASSIGN RECHECK REFERENCES REINDEX RELATIVE_P RELEASE RENAME
- REPEATABLE REPLACE RESET RESTART RESTRICT RETURNS REVOKE RIGHT
- ROLE ROLLBACK ROW ROWS RULE
+ REPEATABLE REPLACE REPLICA RESET RESTART RESTRICT RETURNING RETURNS REVOKE
+ RIGHT ROLE ROLLBACK ROW ROWS RULE
SAVEPOINT SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE
SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE
- SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT
- STATISTICS STDIN STDOUT STORAGE STRICT_P SUBSTRING SUPERUSER_P SYMMETRIC
- SYSID SYSTEM_P
+ SHOW SIMILAR SIMPLE SMALLINT SOME STABLE STANDALONE_P START STATEMENT
+ STATISTICS STDIN STDOUT STORAGE STRICT_P STRIP_P SUBSTRING SUPERUSER_P
+ SYMMETRIC SYSID SYSTEM_P
- TABLE TABLESPACE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP TO TOAST
+ TABLE TABLESPACE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP TO
TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P TRUNCATE TRUSTED TYPE_P
UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNTIL
UPDATE USER USING
- VACUUM VALID VALIDATOR VALUES VARCHAR VARYING VERBOSE VIEW VOLATILE
- WHEN WHERE WITH WITHOUT WORK WRITE
- YEAR_P
+ VACUUM VALID VALIDATOR VALUE_P VALUES VARCHAR VARYING
+ VERBOSE VERSION_P VIEW VOLATILE
+ WHEN WHERE WHITESPACE_P WITH WITHOUT WORK WRITE
+
+ XML_P XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLFOREST XMLPARSE
+ XMLPI XMLROOT XMLSERIALIZE
+
+ YEAR_P YES_P
+
ZONE
/* The grammar thinks these are keywords, but they are not in the keywords.c
* list and so can never be entered directly. The filter in parser.c
* creates these tokens when required.
*/
-%token UNIONJOIN
+%token NULLS_FIRST NULLS_LAST WITH_CASCADED WITH_LOCAL WITH_CHECK
/* Special token types, not actually keywords - see the "lex" file */
-%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE IP BCONST XCONST
+%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE IP BCONST XCONST DOLCONST
%token <ival> ICONST PARAM
%token <dval> FCONST
/* precedence: lowest to highest */
+%nonassoc SET /* see relation_expr_opt_alias */
%left UNION EXCEPT
%left INTERSECT
%left OR
%left '(' ')'
%left TYPECAST
%left '.'
-%left JOIN UNIONJOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
+%left JOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
+/* kluge to keep xml_whitespace_option from causing shift/reduce conflicts */
+%right PRESERVE STRIP_P
%type <str> Iconst Fconst Sconst TransactionStmt CreateStmt RoleId
%type <str> CreateAsElement OptCreateAs CreateAsList CreateAsStmt
%type <str> key_match ColLabel SpecialRuleRelation ColId columnDef
%type <str> ColConstraint ColConstraintElem drop_type Bconst Iresult
%type <str> TableConstraint OptTableElementList Xconst opt_transaction
-%type <str> ConstraintElem key_actions ColQualList type_name
-%type <str> target_list target_el update_target_list alias_clause
-%type <str> update_target_el qualified_name database_name alter_using
+%type <str> ConstraintElem key_actions ColQualList cluster_index_specification
+%type <str> target_list target_el alias_clause type_func_name_keyword
+%type <str> qualified_name database_name alter_using type_function_name
%type <str> access_method attr_name index_name name func_name
%type <str> file_name AexprConst c_expr ConstTypename var_list
%type <str> a_expr b_expr TruncateStmt CommentStmt OnCommitOption opt_by
%type <str> opt_indirection expr_list extract_list extract_arg
%type <str> position_list substr_list substr_from alter_column_default
%type <str> trim_list in_expr substr_for attrs TableFuncElement
-%type <str> Typename SimpleTypename Numeric opt_float opt_numeric
-%type <str> opt_decimal Character character opt_varying opt_charset
+%type <str> Typename SimpleTypename Numeric opt_float DiscardStmt
+%type <str> Character character opt_varying opt_charset enum_val_list
%type <str> opt_timezone opt_interval table_ref fetch_direction
%type <str> ConstDatetime AlterDomainStmt AlterSeqStmt alter_rel_cmds
%type <str> SelectStmt into_clause OptTemp ConstraintAttributeSpec
%type <str> sortby qualified_name_list name_list ColId_or_Sconst
%type <str> group_clause having_clause from_clause opt_distinct opt_hold
%type <str> join_outer where_clause relation_expr sub_type arg_class
-%type <str> opt_column_list insert_rest InsertStmt WithOidsAs param_name
+%type <str> opt_column_list insert_rest InsertStmt param_name
%type <str> columnList DeleteStmt UpdateStmt DeclareCursorStmt
-%type <str> NotifyStmt columnElem UnlistenStmt TableElement rowdefinition
+%type <str> NotifyStmt columnElem UnlistenStmt TableElement
%type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary
-%type <str> FetchStmt from_in CreateOpClassStmt like_including_defaults
+%type <str> FetchStmt from_in CreateOpClassStmt returning_clause
%type <str> ClosePortalStmt DropStmt VacuumStmt AnalyzeStmt opt_verbose
-%type <str> opt_full func_arg OptWithOids opt_freeze alter_table_cmd
+%type <str> opt_full func_arg OptWith opt_freeze alter_table_cmd
%type <str> analyze_keyword opt_name_list ExplainStmt index_params
%type <str> index_elem opt_class access_method_clause alter_table_cmds
%type <str> index_opt_unique IndexStmt func_return ConstInterval
%type <str> opt_instead event RuleActionList opt_using CreateAssertStmt
%type <str> RuleActionStmtOrEmpty RuleActionMulti func_as reindex_type
%type <str> RuleStmt opt_column oper_argtypes NumConst var_name
-%type <str> MathOp RemoveFuncStmt aggr_argtype ECPGunreserved_con
+%type <str> MathOp RemoveFuncStmt ECPGunreserved_con opt_database_name
%type <str> RemoveAggrStmt opt_procedural select_no_parens CreateCastStmt
%type <str> RemoveOperStmt RenameStmt all_Op opt_trusted opt_lancompiler
%type <str> VariableSetStmt var_value zone_value VariableShowStmt
%type <str> CreatePLangStmt TriggerFuncArgs TriggerFuncArg simple_select
%type <str> ViewStmt LoadStmt CreatedbStmt createdb_opt_item ExplainableStmt
%type <str> createdb_opt_list opt_encoding OptInherit opt_equal
-%type <str> privilege_list privilege privilege_target
+%type <str> privilege_list privilege privilege_target opt_if_exists
%type <str> opt_grant_grant_option cursor_options DropOwnedStmt
%type <str> transaction_mode_list_or_empty transaction_mode_list
%type <str> function_with_argtypes_list function_with_argtypes IntConstVar
%type <str> select_clause opt_select_limit select_limit_value opt_recheck
%type <str> ConstraintTimeSpec AlterDatabaseSetStmt DropAssertStmt
%type <str> select_offset_value ReindexStmt join_type opt_boolean
-%type <str> join_qual joined_table opclass_item
-%type <str> lock_type array_expr_list ReassignOwnedStmt
+%type <str> join_qual joined_table opclass_item relation_expr_opt_alias
+%type <str> lock_type array_expr_list ReassignOwnedStmt for_locking_item
%type <str> OptConstrFromTable OptTempTableName StringConst array_expr
-%type <str> constraints_set_mode comment_type
+%type <str> constraints_set_mode comment_type opt_check_option
%type <str> CreateGroupStmt AlterGroupStmt DropGroupStmt key_delete
%type <str> opt_force key_update CreateSchemaStmt PosIntStringConst
%type <str> IntConst PosIntConst grantee_list func_type opt_or_replace
-%type <str> select_limit CheckPointStmt ECPGColId
+%type <str> select_limit CheckPointStmt ECPGColId old_aggr_list
%type <str> OptSchemaName OptSchemaEltList schema_stmt opt_drop_behavior
%type <str> handler_name any_name_list any_name opt_as insert_column_list
-%type <str> columnref function_name insert_target_el AllConstVar
-%type <str> insert_target_list insert_column_item DropRuleStmt
+%type <str> columnref values_clause AllConstVar where_or_current_clause
+%type <str> insert_column_item DropRuleStmt ctext_expr
%type <str> createfunc_opt_item set_rest var_list_or_default alter_rel_cmd
%type <str> CreateFunctionStmt createfunc_opt_list func_table
%type <str> DropUserStmt copy_from copy_opt_list copy_opt_item
%type <str> ECPGAllocateDescr ECPGDeallocateDescr symbol opt_output
%type <str> ECPGGetDescriptorHeader ECPGColLabel single_var_declaration
%type <str> reserved_keyword unreserved_keyword ecpg_interval opt_ecpg_using
-%type <str> col_name_keyword func_name_keyword precision opt_scale
-%type <str> ECPGTypeName using_list ECPGColLabelCommon UsingConst
-%type <str> inf_val_list inf_col_list using_descriptor into_descriptor
+%type <str> col_name_keyword precision opt_scale
+%type <str> ECPGTypeName using_list ECPGColLabelCommon UsingConst
+%type <str> using_descriptor into_descriptor opt_nulls_order opt_asc_desc
%type <str> prepared_name struct_union_type_with_symbol OptConsTableSpace
%type <str> ECPGunreserved ECPGunreserved_interval cvariable opt_bit_field
%type <str> AlterOwnerStmt OptTableSpaceOwner CreateTableSpaceStmt
%type <str> opt_grant_admin_option AlterFunctionStmt alterfunc_opt_list opt_restrict
%type <str> AlterObjectSchemaStmt alterdb_opt_list for_locking_clause opt_for_locking_clause
%type <str> locked_rels_list opt_granted_by RevokeRoleStmt alterdb_opt_item using_clause
-%type <str> GrantRoleStmt opt_asymmetric
+%type <str> GrantRoleStmt opt_asymmetric aggr_args old_aggr_definition
+%type <str> old_aggr_elem for_locking_items TableLikeOptionList TableLikeOption
+%type <str> set_target_list set_clause_list set_clause multiple_set_clause
+%type <str> ctext_expr_list ctext_row single_set_clause set_target opt_type_modifiers
+%type <str> opclass_drop_list opclass_drop DropOpFamilyStmt opt_opfamily
+%type <str> CreateOpFamilyStmt AlterOpFamilyStmt create_as_target
+%type <str> xml_attributes xml_attribute_list document_or_content xml_whitespace_option
+%type <str> opt_xml_root_standalone xml_root_version xml_attribute_el
%type <struct_union> s_struct_union_symbol
| '}' { remove_typedefs(braces_open); remove_variables(braces_open--); fputs("}", yyout); }
;
-opt_at: AT connection_target
+opt_at: AT connection_object
{
connection = $2;
/*
| ClusterStmt { output_statement($1, 0, connection); }
| CommentStmt { output_statement($1, 0, connection); }
| ConstraintsSetStmt { output_statement($1, 0, connection); }
- | CopyStmt { output_statement($1, 0, connection); }
+ | CopyStmt { output_statement($1, 0, connection); }
| CreateAsStmt { output_statement($1, 0, connection); }
| CreateAssertStmt { output_statement($1, 0, connection); }
| CreateCastStmt { output_statement($1, 0, connection); }
| CreateGroupStmt { output_statement($1, 0, connection); }
| CreatePLangStmt { output_statement($1, 0, connection); }
| CreateOpClassStmt { output_statement($1, 0, connection); }
+ | CreateOpFamilyStmt { output_statement($1, 0, connection); }
+ | AlterOpFamilyStmt { output_statement($1, 0, connection); }
| CreateRoleStmt { output_statement($1, 0, connection); }
| CreateSchemaStmt { output_statement($1, 0, connection); }
| CreateSeqStmt { output_statement($1, 0, connection); }
| DeclareCursorStmt { output_simple_statement($1); }
| DefineStmt { output_statement($1, 0, connection); }
| DeleteStmt { output_statement($1, 1, connection); }
+ | DiscardStmt { output_statement($1, 1, connection); }
| DropAssertStmt { output_statement($1, 0, connection); }
| DropCastStmt { output_statement($1, 0, connection); }
| DropGroupStmt { output_statement($1, 0, connection); }
| DropOpClassStmt { output_statement($1, 0, connection); }
+ | DropOpFamilyStmt { output_statement($1, 0, connection); }
| DropOwnedStmt { output_statement($1, 0, connection); }
| DropPLangStmt { output_statement($1, 0, connection); }
| DropRoleStmt { output_statement($1, 0, connection); }
| DropRuleStmt { output_statement($1, 0, connection); }
- | DropStmt { output_statement($1, 0, connection); }
+ | DropStmt { output_statement($1, 0, connection); }
| DropTableSpaceStmt { output_statement($1, 0, connection); }
| DropTrigStmt { output_statement($1, 0, connection); }
| DropUserStmt { output_statement($1, 0, connection); }
struct cursor *ptr;
if ((ptr = add_additional_variables($1, true)) != NULL)
+ {
output_statement(mm_strdup(ptr->command), 0,
ptr->connection ? mm_strdup(ptr->connection) : NULL);
- ptr->opened = true;
+ ptr->opened = true;
+ }
}
| ECPGPrepare
{
*****************************************************************************/
DropRoleStmt: DROP ROLE name_list
{ $$ = cat2_str(make_str("drop role"), $3);}
+ | DROP ROLE IF_P EXISTS name_list
+ { $$ = cat2_str(make_str("drop role if exists"), $5);}
;
/*****************************************************************************
*****************************************************************************/
DropUserStmt: DROP USER name_list
{ $$ = cat2_str(make_str("drop user"), $3);}
+ | DROP USER IF_P EXISTS name_list
+ { $$ = cat2_str(make_str("drop user if exists"), $5);}
+
;
/*****************************************************************************
*****************************************************************************/
DropGroupStmt: DROP GROUP_P name_list
{ $$ = cat2_str(make_str("drop group"), $3); }
+ | DROP GROUP_P IF_P EXISTS name_list
+ { $$ = cat2_str(make_str("drop group if exists"), $5); }
;
/*****************************************************************************
{ $$ = cat2_str(make_str("session authorization"), $3); }
| SESSION AUTHORIZATION DEFAULT
{ $$ = make_str("session authorization default"); }
+ | XML_P OPTION document_or_content
+ { $$ = cat2_str(make_str("xml option"), $3); }
;
var_name: ECPGColId { $$ = $1; }
| StringConst { $$ = $1; }
;
-VariableShowStmt: SHOW var_name
+VariableShowStmt: SHOW var_name ecpg_into
{ $$ = cat2_str(make_str("show"), $2); }
- | SHOW TIME ZONE
+ | SHOW TIME ZONE ecpg_into
{ $$ = make_str("show time zone"); }
- | SHOW TRANSACTION ISOLATION LEVEL
+ | SHOW TRANSACTION ISOLATION LEVEL ecpg_into
{ $$ = make_str("show transaction isolation level"); }
- | SHOW SESSION AUTHORIZATION
+ | SHOW SESSION AUTHORIZATION ecpg_into
{ $$ = make_str("show session authorization"); }
| SHOW ALL
- { $$ = make_str("show all"); }
+ { mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL not implemented"); }
;
VariableResetStmt: RESET var_name
constraints_set_list: ALL
{ $$ = make_str("all"); }
- | name_list
+ | qualified_name_list
{ $$ = $1; }
;
CheckPointStmt: CHECKPOINT { $$= make_str("checkpoint"); }
;
+DiscardStmt:
+ DISCARD ALL { $$ = make_str("discard all"); }
+ | DISCARD TEMP { $$ = make_str("discard temp"); }
+ | DISCARD TEMPORARY { $$ = make_str("discard temporary"); }
+ | DISCARD PLANS { $$ = make_str("discard plans"); }
+ ;
/*****************************************************************************
*
/* ALTER TABLE <relation> SET WITHOUT OIDS */
| SET WITHOUT OIDS
{ $$ = make_str("set without oids"); }
- /* ALTER TABLE <name> CREATE TOAST TABLE */
- | CREATE TOAST TABLE
- { $$ = make_str("create toast table"); }
/* ALTER TABLE <name> CLUSTER ON <indexname> */
| CLUSTER ON name
{ $$ = cat_str(2, make_str("cluster on"), $3); }
/* ALTER TABLE <name> ENABLE TRIGGER <trig> */
| ENABLE_P TRIGGER name
{ $$ = cat2_str(make_str("enable trigger"), $3); }
+/* ALTER TABLE <name> ENABLE ALWAYS TRIGGER <trig> */
+ | ENABLE_P ALWAYS TRIGGER name
+ { $$ = cat2_str(make_str("enable always trigger"), $4); }
+/* ALTER TABLE <name> ENABLE REPLICA TRIGGER <trig> */
+ | ENABLE_P REPLICA TRIGGER name
+ { $$ = cat2_str(make_str("enable replica trigger"), $4); }
/* ALTER TABLE <name> ENABLE TRIGGER ALL */
| ENABLE_P TRIGGER ALL
{ $$ = make_str("enable trigger all"); }
/* ALTER TABLE <name> DISABLE TRIGGER USER */
| DISABLE_P TRIGGER USER
{ $$ = make_str("disable trigger user"); }
+/* ALTER TABLE <name> ENABLE RULE <rule> */
+ | ENABLE_P RULE name
+ { $$ = cat2_str(make_str("enable rule"), $3); }
+/* ALTER TABLE <name> ENABLE ALWAYS RULE <rule> */
+ | ENABLE_P ALWAYS RULE name
+ { $$ = cat2_str(make_str("enable always rule"), $4); }
+/* ALTER TABLE <name> ENABLE REPLICA RULE <rule> */
+ | ENABLE_P REPLICA RULE name
+ { $$ = cat2_str(make_str("enable replica rule"), $4); }
+/* ALTER TABLE <name> DISABLE RULE <rule> */
+ | DISABLE_P RULE name
+ { $$ = cat2_str(make_str("disable rule"), $3); }
+/* ALTER TABLE <name> ALTER INHERITS ADD <parent> */
+ | INHERIT qualified_name
+ { $$ = cat2_str(make_str("inherit"), $2); }
+/* ALTER TABLE <name> NO INHERITS <parent> */
+ | NO INHERIT qualified_name
+ { $$ = cat2_str(make_str("no inherit"), $3); }
+ | alter_rel_cmd
+ { $$ = $1; }
;
alter_rel_cmds: alter_rel_cmd { $$ = $1; }
alter_rel_cmd:
/* ALTER [TABLE|INDEX] <name> OWNER TO RoleId */
OWNER TO RoleId
- { $$ = cat_str(2, make_str("owner to"), $3); }
+ { $$ = cat2_str(make_str("owner to"), $3); }
/* ALTER [TABLE|INDEX] <name> SET TABLESPACE <tablespacename> */
| SET TABLESPACE name
- { $$ = cat_str(2, make_str("set tablespace"), $3); }
+ { $$ = cat2_str(make_str("set tablespace"), $3); }
+ | SET definition
+ { $$ = cat2_str(make_str("set"), $2); }
+ | RESET definition
+ { $$ = cat2_str(make_str("reset"), $2); }
;
alter_column_default:
ClosePortalStmt: CLOSE name
{ $$ = cat2_str(make_str("close"), $2); }
+ | CLOSE ALL
+ { $$ = make_str("close all"); }
;
-/*****************************************************************************
- *
- * QUERY :
- * COPY [BINARY] <relname> FROM/TO
- * [USING DELIMITERS <delimiter>]
- *
- *****************************************************************************/
-
CopyStmt: COPY opt_binary qualified_name opt_oids copy_from
copy_file_name copy_delimiter opt_with copy_opt_list
- { $$ = cat_str(9, make_str("copy"), $2, $3, $4, $5, $6, $7, $8, $9); }
+ {
+ if (strcmp($5, "to") == 0 && strcmp($6, "stdin") == 0)
+ mmerror(PARSE_ERROR, ET_ERROR, "copy to stdin not possible.\n");
+ else if (strcmp($5, "from") == 0 && strcmp($6, "stdout") == 0)
+ mmerror(PARSE_ERROR, ET_ERROR, "copy from stdout not possible.\n");
+ else if (strcmp($5, "from") == 0 && strcmp($6, "stdin") == 0)
+ mmerror(PARSE_ERROR, ET_WARNING, "copy from stdin not implemented.\n");
+
+ $$ = cat_str(9, make_str("copy"), $2, $3, $4, $5, $6, $7, $8, $9);
+ }
+ | COPY select_with_parens TO copy_file_name opt_with copy_opt_list
+ {
+ if (strcmp($4, "stdin") == 0)
+ mmerror(PARSE_ERROR, ET_ERROR, "copy to stdin not possible.\n");
+
+ $$ = cat_str(6, make_str("copy"), $2, make_str("to"), $4, $5, $6);
+ }
;
copy_from: TO { $$ = make_str("to"); }
| FROM { $$ = make_str("from"); }
;
-/*
- * copy_file_name NULL indicates stdio is used. Whether stdin or stdout is
- * used depends on the direction. (It really doesn't make sense to copy from
- * stdout. We silently correct the "typo". - AY 9/94
- */
-copy_file_name: StringConst { $$ = $1; }
+copy_file_name: StringConst { $$ = $1; }
| STDIN { $$ = make_str("stdin"); }
| STDOUT { $$ = make_str("stdout"); }
;
*****************************************************************************/
CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
- OptInherit OptWithOids OnCommitOption OptTableSpace
+ OptInherit OptWith OnCommitOption OptTableSpace
{ $$ = cat_str(11, make_str("create"), $2, make_str("table"), $4, make_str("("), $6, make_str(")"), $8, $9, $10, $11); }
| CREATE OptTemp TABLE qualified_name OF qualified_name
- '(' OptTableElementList ')' OptWithOids OnCommitOption OptTableSpace
+ '(' OptTableElementList ')' OptWith OnCommitOption OptTableSpace
{ $$ = cat_str(12, make_str("create"), $2, make_str("table"), $4, make_str("of"), $6, make_str("("), $8, make_str(")"), $10, $11, $12); }
;
{ $$ = make_str("not null"); }
| NULL_P
{ $$ = make_str("null"); }
- | UNIQUE OptConsTableSpace
- { $$ = cat2_str(make_str("unique"), $2); }
- | PRIMARY KEY OptConsTableSpace
- { $$ = cat2_str(make_str("primary key"), $3); }
+ | UNIQUE opt_definition OptConsTableSpace
+ { $$ = cat_str(3, make_str("unique"), $2, $3); }
+ | PRIMARY KEY opt_definition OptConsTableSpace
+ { $$ = cat_str(3, make_str("primary key"), $3, $4); }
| CHECK '(' a_expr ')'
{ $$ = cat_str(3, make_str("check ("), $3, make_str(")")); }
| DEFAULT b_expr
* there is no parsing conflict.
*/
ConstraintAttr: DEFERRABLE { $$ = make_str("deferrable"); }
- | NOT DEFERRABLE { $$ = make_str("not deferrable"); }
+ | NOT DEFERRABLE { $$ = make_str("not deferrable"); }
| INITIALLY DEFERRED { $$ = make_str("initially deferred"); }
| INITIALLY IMMEDIATE { $$ = make_str("initially immediate"); }
;
-TableLikeClause: LIKE qualified_name like_including_defaults
+TableLikeClause: LIKE qualified_name TableLikeOptionList
{$$ = cat_str(3, make_str("like"), $2, $3); }
;
-like_including_defaults:
+TableLikeOptionList: TableLikeOptionList TableLikeOption
+ { $$ = cat2_str($1, $2); }
+ | /* EMPTY */ { $$ = EMPTY; }
+ ;
+
+TableLikeOption:
INCLUDING DEFAULTS { $$ = make_str("including defaults"); }
| EXCLUDING DEFAULTS { $$ = make_str("excluding defaults"); }
- | /* EMPTY */ { $$ = EMPTY; }
+ | INCLUDING CONSTRAINTS { $$ = make_str("including constraints"); }
+ | EXCLUDING CONSTRAINTS { $$ = make_str("excluding constraints"); }
+ | INCLUDING INDEXES { $$ = make_str("including indexes"); }
+ | EXCLUDING INDEXES { $$ = make_str("excluding indexes"); }
;
/* ConstraintElem specifies constraint syntax which is not embedded into
ConstraintElem: CHECK '(' a_expr ')'
{ $$ = cat_str(3, make_str("check("), $3, make_str(")")); }
- | UNIQUE '(' columnList ')' OptConsTableSpace
- { $$ = cat_str(4, make_str("unique("), $3, make_str(")"), $5); }
- | PRIMARY KEY '(' columnList ')' OptConsTableSpace
- { $$ = cat_str(4, make_str("primary key("), $4, make_str(")"), $6); }
+ | UNIQUE '(' columnList ')' opt_definition OptConsTableSpace
+ { $$ = cat_str(5, make_str("unique("), $3, make_str(")"), $5, $6); }
+ | PRIMARY KEY '(' columnList ')' opt_definition OptConsTableSpace
+ { $$ = cat_str(5, make_str("primary key("), $4, make_str(")"), $6, $7); }
| FOREIGN KEY '(' columnList ')' REFERENCES qualified_name opt_column_list
key_match key_actions ConstraintAttributeSpec
{ $$ = cat_str(8, make_str("foreign key("), $4, make_str(") references"), $7, $8, $9, $10, $11); }
{ $$ = EMPTY; }
;
-OptWithOids: WITH OIDS { $$ = make_str("with oids"); }
- | WITHOUT OIDS { $$ = make_str("without oids"); }
- | /*EMPTY*/ { $$ = EMPTY; }
+OptWith: WITH definition { $$ = cat2_str(make_str("with"), $2); }
+ | WITH OIDS { $$ = make_str("with oids"); }
+ | WITHOUT OIDS { $$ = make_str("without oids"); }
+ | /*EMPTY*/ { $$ = EMPTY; }
;
OnCommitOption: ON COMMIT DROP { $$ = make_str("on commit drop"); }
* SELECT ... INTO.
*/
-CreateAsStmt: CREATE OptTemp TABLE qualified_name OptCreateAs WithOidsAs
+CreateAsStmt: CREATE OptTemp TABLE create_as_target AS
{ FoundInto = 0; }
SelectStmt
{
if (FoundInto == 1)
- mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE / AS SELECT may not specify INTO");
+ mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE / AS SELECT cannot specify INTO");
- $$ = cat_str(7, make_str("create"), $2, make_str("table"), $4, $5, $6, $8);
+ $$ = cat_str(6, make_str("create"), $2, make_str("table"), $4, make_str("as"), $7);
}
;
-/*
- * To avoid a shift/reduce conflict in CreateAsStmt, we need to
- * include the 'AS' terminal in the parsing of WITH/WITHOUT
- * OIDS. Unfortunately that means this production is effectively a
- * duplicate of OptWithOids.
- */
-WithOidsAs:
- WITH OIDS AS { $$ = make_str("with oids as"); }
- | WITHOUT OIDS AS { $$ = make_str("without oids as"); }
- | AS { $$ = make_str("as"); }
+create_as_target: qualified_name OptCreateAs OptWith OnCommitOption OptTableSpace
+ {
+ $$ = cat_str(5, $1, $2, $3, $4, $5);
+ }
;
-
OptCreateAs: '(' CreateAsList ')'
{ $$ = cat_str(3, make_str("("), $2, make_str(")")); }
| /*EMPTY*/
{ $$ = make_str("no maxvalue"); }
| NO MINVALUE
{ $$ = make_str("no minvalue"); }
+ | OWNED BY any_name
+ { $$ = cat2_str(make_str("owned by"), $3); }
| START opt_with NumConst
{ $$ = cat_str(3, make_str("start"), $2, $3); }
| RESTART opt_with NumConst
DropPLangStmt: DROP opt_procedural LANGUAGE StringConst opt_drop_behavior
{ $$ = cat_str(5, make_str("drop"), $2, make_str("language"), $4, $5); }
+ | DROP opt_procedural LANGUAGE IF_P EXISTS StringConst opt_drop_behavior
+ { $$ = cat_str(5, make_str("drop"), $2, make_str("language if exists"), $6, $7); }
;
opt_procedural: PROCEDURAL { $$ = make_str("prcedural"); }
DropTableSpaceStmt: DROP TABLESPACE name
{ $$ = cat2_str(make_str("drop tablespace"), $3); }
+ | DROP TABLESPACE IF_P EXISTS name
+ { $$ = cat2_str(make_str("drop tablespace if exists"), $5); }
;
DropTrigStmt: DROP TRIGGER name ON qualified_name opt_drop_behavior
{ $$ = cat_str(5, make_str("drop trigger"), $3, make_str("on"), $5, $6); }
+ | DROP TRIGGER IF_P EXISTS name ON qualified_name opt_drop_behavior
+ { $$ = cat_str(5, make_str("drop trigger if exists"), $5, make_str("on"), $7, $8); }
;
/*****************************************************************************
*
*****************************************************************************/
-DefineStmt: CREATE AGGREGATE func_name definition
+DefineStmt: CREATE AGGREGATE func_name aggr_args definition
+ { $$ = cat_str(4, make_str("create aggregate"), $3, $4, $5); }
+ | CREATE AGGREGATE func_name old_aggr_definition
{ $$ = cat_str(3, make_str("create aggregate"), $3, $4); }
| CREATE OPERATOR all_Op definition
{ $$ = cat_str(3, make_str("create operator"), $3, $4); }
| CREATE TYPE_P any_name definition
{ $$ = cat_str(3, make_str("create type"), $3, $4); }
- | CREATE TYPE_P any_name AS rowdefinition
- { $$ = cat_str(4, make_str("create type"), $3, make_str("as"), $5); }
- ;
-
-rowdefinition: '(' TableFuncElementList ')'
- { $$ = cat_str(3, make_str("("), $2, make_str(")"));}
+ | CREATE TYPE_P any_name
+ { $$ = cat2_str(make_str("create type"), $3); }
+ | CREATE TYPE_P any_name AS '(' TableFuncElementList ')'
+ { $$ = cat_str(5, make_str("create type"), $3, make_str("as ("), $6, make_str(")")); }
+ | CREATE TYPE_P any_name AS ENUM_P '(' enum_val_list ')'
+ { $$ = cat_str(5, make_str("create type"), $3, make_str("as enum ("), $7, make_str(")")); }
;
definition: '(' def_list ')'
/* Note: any simple identifier will be returned as a type name! */
def_arg: func_type { $$ = $1; }
+ | reserved_keyword { $$ = $1; }
| qual_all_Op { $$ = $1; }
- | AllConst { $$ = $1; }
+ | AllConst { $$ = $1; }
+ ;
+
+aggr_args: '(' type_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
+ | '(' '*' ')' { $$ = make_str("(*)"); }
+ ;
+
+old_aggr_definition: '(' old_aggr_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
+ ;
+
+old_aggr_list: old_aggr_elem { $$ = $1; }
+ | old_aggr_list ',' old_aggr_elem { $$ = cat_str(3, $1, make_str(","), $3); }
+ ;
+
+old_aggr_elem: ident '=' def_arg { $$ = cat_str(3, $1, make_str("="), $3); }
+ ;
+
+enum_val_list: StringConst { $$ = $1; }
+ | enum_val_list ',' StringConst { $$ = cat_str(3, $1, make_str(","), $3);}
;
CreateOpClassStmt: CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P Typename
- USING access_method AS opclass_item_list
+ USING access_method opt_opfamily AS opclass_item_list
{
- $$ = cat_str(9, make_str("create operator class"), $4, $5, make_str("for type"), $8, make_str("using"), $10, make_str("as"), $12);
+ $$ = cat_str(10, make_str("create operator class"), $4, $5, make_str("for type"), $8, make_str("using"), $10, $11, make_str("as"), $13);
}
;
{ $$ = cat_str(7, make_str("operator"), $2, $3, make_str("("), $5, make_str(")"), $7); }
| FUNCTION PosIntConst func_name func_args
{ $$ = cat_str(4, make_str("function"), $2, $3, $4); }
+ | FUNCTION PosIntConst '(' type_list ')' func_name func_args
+ { $$ = cat_str(7, make_str("function"), $2, make_str("("), $4, make_str(")"), $6, $7); }
| STORAGE Typename
{ $$ = cat2_str(make_str("storage"), $2); }
;
| /*EMPTY*/ { $$ = EMPTY; }
;
+opt_opfamily: FAMILY any_name { $$ = cat2_str(make_str("family"), $2); }
+ | /*EMPTY*/ { $$ = EMPTY; }
+ ;
+
opt_recheck: RECHECK { $$ = make_str("recheck"); }
| /*EMPTY*/ { $$ = EMPTY; }
;
+CreateOpFamilyStmt: CREATE OPERATOR FAMILY any_name USING access_method
+ { $$ = cat_str(4, make_str("create operator family"), $4, make_str("using"), $6); }
+ ;
+
+AlterOpFamilyStmt: ALTER OPERATOR FAMILY any_name USING access_method ADD_P opclass_item_list
+ { $$ = cat_str(6, make_str("alter operator family"), $4, make_str("using"), $6, make_str("add"), $8); }
+ | ALTER OPERATOR FAMILY any_name USING access_method DROP opclass_drop_list
+ { $$ = cat_str(6, make_str("alter operator family"), $4, make_str("using"), $6, make_str("drop"), $8); }
+ ;
+
+opclass_drop_list: opclass_drop { $$ = $1; }
+ | opclass_drop_list ',' opclass_drop { $$ = cat_str(3, $1, make_str(","), $3); }
+ ;
+
+opclass_drop:
+ OPERATOR PosIntConst '(' type_list ')'
+ { $$ = cat_str(5, make_str("operator"), $2, make_str("("), $4, make_str(")")); }
+ | FUNCTION PosIntConst '(' type_list ')'
+ { $$ = cat_str(5, make_str("function"), $2, make_str("("), $4, make_str(")")); }
+ ;
+
DropOpClassStmt: DROP OPERATOR CLASS any_name USING access_method opt_drop_behavior
{ $$ = cat_str(5,make_str("drop operator class"), $4, make_str("using"), $6, $7); }
+ | DROP OPERATOR CLASS IF_P EXISTS any_name USING access_method opt_drop_behavior
+ { $$ = cat_str(5,make_str("drop operator class if exists"), $6, make_str("using"), $8, $9); }
+ ;
+
+DropOpFamilyStmt: DROP OPERATOR FAMILY any_name USING access_method opt_drop_behavior
+ { $$ = cat_str(5,make_str("drop operator family"), $4, make_str("using"), $6, $7); }
+ | DROP OPERATOR FAMILY IF_P EXISTS any_name USING access_method opt_drop_behavior
+ { $$ = cat_str(5,make_str("drop operator family if exists"), $6, make_str("using"), $8, $9); }
;
/*****************************************************************************
* truncate table relname1, relname2, ....
*
*****************************************************************************/
-TruncateStmt: TRUNCATE opt_table qualified_name_list
- { $$ = cat_str(3, make_str("truncate table"), $2, $3); }
+TruncateStmt: TRUNCATE opt_table qualified_name_list opt_drop_behavior
+ { $$ = cat_str(4, make_str("truncate table"), $2, $3, $4); }
;
/*****************************************************************************
CommentStmt: COMMENT ON comment_type name IS comment_text
{ $$ = cat_str(5, make_str("comment on"), $3, $4, make_str("is"), $6); }
- | COMMENT ON AGGREGATE func_name '(' aggr_argtype ')' IS comment_text
- { $$ = cat_str(6, make_str("comment on aggregate"), $4, make_str("("), $6, make_str(") is"), $9); }
+ | COMMENT ON AGGREGATE func_name aggr_args IS comment_text
+ { $$ = cat_str(5, make_str("comment on aggregate"), $4, $5, make_str("is"), $7); }
| COMMENT ON FUNCTION func_name func_args IS comment_text
{ $$ = cat_str(5, make_str("comment on function"), $4, $5, make_str("is"), $7); }
| COMMENT ON OPERATOR all_Op '(' oper_argtypes ')' IS comment_text
{ $$ = cat_str(4, make_str("comment on rule"), $4, make_str("is"), $6); }
| COMMENT ON OPERATOR CLASS any_name USING access_method IS comment_text
{ $$ = cat_str(6, make_str("comment on operator class"), $5, make_str("using"), $7, make_str("is"), $9); }
+ | COMMENT ON OPERATOR FAMILY any_name USING access_method IS comment_text
+ { $$ = cat_str(6, make_str("comment on operator family"), $5, make_str("using"), $7, make_str("is"), $9); }
| COMMENT ON LARGE_P OBJECT_P NumConst IS comment_text
{ $$ = cat_str(4, make_str("comment on large object"), $5, make_str("is"), $7); }
| COMMENT ON CAST '(' Typename AS Typename ')' IS comment_text
| DOMAIN_P { $$ = make_str("domain"); }
| TYPE_P { $$ = make_str("type"); }
| VIEW { $$ = make_str("view"); }
- | CONVERSION_P { $$ = make_str("conversion"); }
+ | CONVERSION_P { $$ = make_str("conversion"); }
+ | TABLESPACE { $$ = make_str("tablespace"); }
+ | ROLE { $$ = make_str("role"); }
;
comment_text: StringConst { $$ = $1; }
{ $$ = $1; }
| TABLE qualified_name_list
{ $$ = cat2_str(make_str("table"), $2); }
+ | SEQUENCE qualified_name_list
+ { $$ = cat2_str(make_str("sequence"), $2); }
| FUNCTION function_with_argtypes_list
{ $$ = cat2_str(make_str("function"), $2); }
| DATABASE name_list
/*****************************************************************************
*
* QUERY:
- * create index <indexname> on <relname>
- * [ using <access> ] "(" ( <col> | using <opclass> ] )+ ")"
- * [ tablespace <tablespacename> ] [ where <predicate> ]
+ * QUERY: CREATE INDEX
+ *
+ * Note: we can't factor CONCURRENTLY into a separate production without
+ * making it a reserved word.
+ *
+ * Note: we cannot put TABLESPACE clause after WHERE clause unless we are
+ * willing to make TABLESPACE a fully reserved word.
*
*****************************************************************************/
IndexStmt: CREATE index_opt_unique INDEX index_name ON qualified_name
- access_method_clause '(' index_params ')' OptTableSpace where_clause
- { $$ = cat_str(12, make_str("create"), $2, make_str("index"), $4, make_str("on"), $6, $7, make_str("("), $9, make_str(")"), $11, $12); }
+ access_method_clause '(' index_params ')' opt_definition OptTableSpace where_clause
+ { $$ = cat_str(13, make_str("create"), $2, make_str("index"), $4, make_str("on"), $6, $7, make_str("("), $9, make_str(")"), $11, $12, $13); }
+ | CREATE index_opt_unique INDEX CONCURRENTLY index_name ON qualified_name
+ access_method_clause '(' index_params ')' opt_definition OptTableSpace where_clause
+ { $$ = cat_str(13, make_str("create"), $2, make_str("index concurrently"), $5, make_str("on"), $7, $8, make_str("("), $10, make_str(")"), $12, $13, $14); }
;
index_opt_unique: UNIQUE { $$ = make_str("unique"); }
| index_params ',' index_elem { $$ = cat_str(3, $1, make_str(","), $3); }
;
-index_elem: ColId opt_class
- { $$ = cat2_str($1, $2); }
- | func_expr opt_class
- { $$ = cat2_str($1, $2); }
- | '(' a_expr ')' opt_class
- { $$ = cat_str(4, make_str("("), $2, make_str(")"), $4); }
+index_elem: ColId opt_class opt_asc_desc opt_nulls_order
+ { $$ = cat_str(4, $1, $2, $3, $4); }
+ | func_expr opt_class opt_asc_desc opt_nulls_order
+ { $$ = cat_str(4, $1, $2, $3, $4); }
+ | '(' a_expr ')' opt_class opt_asc_desc opt_nulls_order
+ { $$ = cat_str(6, make_str("("), $2, make_str(")"), $4, $5, $6); }
;
opt_class: any_name { $$ = $1; }
| /*EMPTY*/ { $$ = EMPTY; }
;
+opt_asc_desc: ASC { $$ = make_str("asc"); }
+ | DESC { $$ = make_str("desc"); }
+ | /*EMPTY*/ { $$ = EMPTY; }
+ ;
+
+opt_nulls_order: NULLS_FIRST { $$ = make_str("nulls first"); }
+ | NULLS_LAST { $$ = make_str("nulls last"); }
+ | /*EMPTY*/ { $$ = EMPTY; }
+ ;
+
CreateFunctionStmt: CREATE opt_or_replace FUNCTION func_name func_args
RETURNS func_return createfunc_opt_list opt_definition
{ $$ = cat_str(8, make_str("create"), $2, make_str("function"), $4, $5, make_str("returns"), $7, $8); }
{ $$ = cat_str(3, $1, make_str(","), $3); }
;
-param_name: function_name { $$ = $1; };
+param_name: type_function_name { $$ = $1; };
func_return: func_type
{
func_type: Typename
{ $$ = $1; }
- | type_name attrs '%' TYPE_P
+ | type_function_name attrs '%' TYPE_P
{ $$ = cat_str(3, $1, $2, make_str("% type")); }
+ | SETOF type_function_name attrs '%' TYPE_P
+ { $$ = cat_str(4, make_str("setof"), $2, $3, make_str("% type")); }
;
{ $$ = make_str("security definer"); }
| SECURITY INVOKER
{ $$ = make_str("security invoker"); }
+ | COST NumConst
+ { $$ = cat2_str(make_str("cost"), $2); }
+ | ROWS NumConst
+ { $$ = cat2_str(make_str("rows"), $2); }
;
createfunc_opt_item: AS func_as
{ $$ = cat2_str(make_str("as"), $2); }
* QUERY:
*
* DROP FUNCTION funcname (arg1, arg2, ...)
- * DROP AGGREGATE aggname (aggtype)
+ * DROP AGGREGATE (arg1, ...) [ RESTRICT | CASCADE ]
* DROP OPERATOR opname (leftoperand_typ rightoperand_typ)
*
*****************************************************************************/
RemoveFuncStmt: DROP FUNCTION func_name func_args opt_drop_behavior
{ $$ = cat_str(4, make_str("drop function"), $3, $4, $5); }
+ | DROP FUNCTION IF_P EXISTS func_name func_args opt_drop_behavior
+ { $$ = cat_str(4, make_str("drop function if exists"), $5, $6, $7); }
;
-RemoveAggrStmt: DROP AGGREGATE func_name '(' aggr_argtype ')' opt_drop_behavior
- { $$ = cat_str(6, make_str("drop aggregate"), $3, make_str("("), $5, make_str(")"), $7); }
+RemoveAggrStmt: DROP AGGREGATE func_name aggr_args opt_drop_behavior
+ { $$ = cat_str(4, make_str("drop aggregate"), $3, $4, $5); }
+ | DROP AGGREGATE IF_P EXISTS func_name aggr_args opt_drop_behavior
+ { $$ = cat_str(4, make_str("drop aggregate if exists"), $5, $6, $7); }
;
-aggr_argtype: Typename { $$ = $1; }
- | '*' { $$ = make_str("*"); }
- ;
-
-
RemoveOperStmt: DROP OPERATOR all_Op '(' oper_argtypes ')' opt_drop_behavior
{ $$ = cat_str(6, make_str("drop operator"), $3, make_str("("), $5, make_str(")"), $7); }
+ | DROP OPERATOR IF_P EXISTS any_operator '(' oper_argtypes ')' opt_drop_behavior
+ { $$ = cat_str(6, make_str("drop operator if exists"), $5, make_str("("), $7, make_str(")"), $9); }
;
oper_argtypes: Typename
;
-DropCastStmt: DROP CAST '(' Typename AS Typename ')' opt_drop_behavior
- { $$ = cat_str(6, make_str("drop cast ("), $4, make_str("as"), $6, make_str(")"), $8); }
+DropCastStmt: DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_behavior
+ { $$ = cat_str(8, make_str("drop cast"), $3, make_str("("), $5, make_str("as"), $7, make_str(")"), $9); }
+ ;
+
+opt_if_exists: IF_P EXISTS { $$ = make_str("if exists"); }
+ | /* EMPTY */ { $$ = EMPTY; }
;
/*****************************************************************************
*
*****************************************************************************/
-RenameStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' RENAME TO name
- { $$ = cat_str(6, make_str("alter aggregate"), $3, make_str("("), $5, make_str(") rename to"), $9); }
+RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name
+ { $$ = cat_str(5, make_str("alter aggregate"), $3, $4, make_str("rename to"), $7); }
| ALTER CONVERSION_P any_name RENAME TO name
{ $$ = cat_str(4, make_str("alter conversion"), $3, make_str("rename to"), $6); }
| ALTER DATABASE database_name RENAME TO database_name
{ $$ = cat_str(5, make_str("alter function"), $3, $4, make_str("rename to"), $7); }
| ALTER GROUP_P RoleId RENAME TO RoleId
{ $$ = cat_str(4, make_str("alter group"), $3, make_str("rename to"), $6); }
- | ALTER LANGUAGE name RENAME TO name
- { $$ = cat_str(4, make_str("alter language"), $3, make_str("rename to"), $6); }
+ | ALTER opt_procedural LANGUAGE name RENAME TO name
+ { $$ = cat_str(6, make_str("alter"), $2, make_str("language"), $4, make_str("rename to"), $7); }
| ALTER OPERATOR CLASS any_name USING access_method RENAME TO name
{ $$ = cat_str(6, make_str("alter operator class"), $4, make_str("using"), $6, make_str("rename to"), $9); }
+ | ALTER OPERATOR FAMILY any_name USING access_method RENAME TO name
+ { $$ = cat_str(6, make_str("alter operator family"), $4, make_str("using"), $6, make_str("rename to"), $9); }
| ALTER SCHEMA name RENAME TO name
{ $$ = cat_str(4, make_str("alter schema"), $3, make_str("rename to"), $6); }
| ALTER TABLE relation_expr RENAME TO name
{ $$ = cat_str(4, make_str("alter table"), $3, make_str("rename to"), $6); }
+ | ALTER SEQUENCE relation_expr RENAME TO name
+ { $$ = cat_str(4, make_str("alter sequence"), $3, make_str("rename to"), $6); }
+ | ALTER VIEW relation_expr RENAME TO name
+ { $$ = cat_str(4, make_str("alter view"), $3, make_str("rename to"), $6); }
| ALTER INDEX relation_expr RENAME TO name
{ $$ = cat_str(4, make_str("alter index"), $3, make_str("rename to"), $6); }
| ALTER TABLE relation_expr RENAME opt_column name TO name
*****************************************************************************/
AlterObjectSchemaStmt:
- ALTER AGGREGATE func_name '(' aggr_argtype ')' SET SCHEMA name
- { $$ = cat_str(6, make_str("alter aggregate"), $3, make_str("("), $5, make_str(") set schema"), $9); }
+ ALTER AGGREGATE func_name aggr_args SET SCHEMA name
+ { $$ = cat_str(5, make_str("alter aggregate"), $3, $4, make_str("set schema"), $7); }
| ALTER DOMAIN_P any_name SET SCHEMA name
{ $$ = cat_str(4, make_str("alter domain"), $3, make_str("set schema"), $6); }
| ALTER FUNCTION func_name func_args SET SCHEMA name
*
*****************************************************************************/
-AlterOwnerStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' OWNER TO RoleId
- { $$ = cat_str(6, make_str("alter aggregate"), $3, make_str("("), $5, make_str(") owner to"), $9); }
+AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleId
+ { $$ = cat_str(5, make_str("alter aggregate"), $3, $4, make_str("owner to"), $7); }
| ALTER CONVERSION_P any_name OWNER TO RoleId
{ $$ = cat_str(4, make_str("alter conversion"), $3, make_str("owner to"), $6); }
| ALTER DATABASE database_name OWNER TO RoleId
{ $$ = cat_str(4, make_str("alter domain"), $3, make_str("owner to"), $6); }
| ALTER FUNCTION func_name func_args OWNER TO RoleId
{ $$ = cat_str(5, make_str("alter function"), $3, $4, make_str("owner to"), $7); }
+ | ALTER opt_procedural LANGUAGE name OWNER TO RoleId
+ { $$ = cat_str(6, make_str("alter"), $2, make_str("language"), $4, make_str("owner to"), $7); }
| ALTER OPERATOR any_operator '(' oper_argtypes ')' OWNER TO RoleId
{ $$ = cat_str(6, make_str("alter operator"), $3, make_str("("), $5, make_str(") owner to"), $9); }
| ALTER OPERATOR CLASS any_name USING access_method OWNER TO RoleId
{ $$ = cat_str(6, make_str("alter operator class"), $4, make_str("using"), $6, make_str("owner to"), $9); }
+ | ALTER OPERATOR FAMILY any_name USING access_method OWNER TO RoleId
+ { $$ = cat_str(6, make_str("alter operator family"), $4, make_str("using"), $6, make_str("owner to"), $9); }
| ALTER SCHEMA name OWNER TO RoleId
{ $$ = cat_str(4, make_str("alter schema"), $3, make_str("owner to"), $6); }
| ALTER TYPE_P any_name OWNER TO RoleId
DropRuleStmt: DROP RULE name ON qualified_name opt_drop_behavior
{ $$ = cat_str(5, make_str("drop rule"), $3, make_str("on"), $5, $6);}
+ | DROP RULE IF_P EXISTS name ON qualified_name opt_drop_behavior
+ { $$ = cat_str(5, make_str("drop rule if exists"), $5, make_str("on"), $7, $8);}
;
/*****************************************************************************
*
*****************************************************************************/
-NotifyStmt: NOTIFY qualified_name
+NotifyStmt: NOTIFY ColId
{ $$ = cat2_str(make_str("notify"), $2); }
;
-ListenStmt: LISTEN qualified_name
+ListenStmt: LISTEN ColId
{ $$ = cat2_str(make_str("listen"), $2); }
;
-UnlistenStmt: UNLISTEN qualified_name
+UnlistenStmt: UNLISTEN ColId
{ $$ = cat2_str(make_str("unlisten"), $2); }
| UNLISTEN '*'
{ $$ = make_str("unlisten *"); }
/*****************************************************************************
*
* QUERY:
- * CREATE [ OR REPLACE ] [ TEMP ] VIEW <viewname> '('target-list ')' AS <query>
+ * CREATE [ OR REPLACE ] [ TEMP ] VIEW <viewname> '('target-list ')'
+ * AS <query> [ WITH [ CASCADED | LOCAL ] CHECK OPTION ]
*
*****************************************************************************/
-ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list AS SelectStmt
- { $$ = cat_str(7, make_str("create"), $2, make_str("view"), $4, $5, make_str("as"), $7); }
- | CREATE OR REPLACE OptTemp VIEW qualified_name opt_column_list AS SelectStmt
- { $$ = cat_str(7, make_str("create or replace"), $4, make_str("view"), $6, $7, make_str("as"), $9); }
+ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list AS SelectStmt opt_check_option
+ { $$ = cat_str(8, make_str("create"), $2, make_str("view"), $4, $5, make_str("as"), $7, $8); }
+ | CREATE OR REPLACE OptTemp VIEW qualified_name opt_column_list AS SelectStmt opt_check_option
+ { $$ = cat_str(8, make_str("create or replace"), $4, make_str("view"), $6, $7, make_str("as"), $9, $10); }
;
+/*
+ * We use merged tokens here to avoid creating shift/reduce conflicts against
+ * a whole lot of other uses of WITH.
+ */
+opt_check_option:
+ WITH_CHECK OPTION
+ {
+ mmerror(PARSE_ERROR, ET_ERROR, "WITH CHECK OPTION not implemented");
+ $$ = EMPTY;
+ }
+ | WITH_CASCADED CHECK OPTION
+ {
+ mmerror(PARSE_ERROR, ET_ERROR, "WITH CHECK OPTION not implemented");
+ $$ = EMPTY;
+ }
+ | WITH_LOCAL CHECK OPTION
+ {
+ mmerror(PARSE_ERROR, ET_ERROR, "WITH CHECK OPTION not implemented");
+ $$ = EMPTY;
+ }
+ | /* EMPTY */
+ { $$ = EMPTY; }
+ ;
/*****************************************************************************
*
*
*****************************************************************************/
-ClusterStmt: CLUSTER index_name ON qualified_name
- { $$ = cat_str(4, make_str("cluster"), $2, make_str("on"), $4); }
- | CLUSTER qualified_name
- { $$ = cat2_str(make_str("cluster"), $2); }
+ClusterStmt: CLUSTER qualified_name cluster_index_specification
+ { $$ = cat_str(3,make_str("cluster"), $2, $3); }
| CLUSTER
{ $$ = make_str("cluster"); }
+ | CLUSTER qualified_name ON qualified_name
+ { $$ = cat_str(4, make_str("cluster"), $2, make_str("on"), $4); }
;
+cluster_index_specification:
+ USING index_name { $$ = cat2_str(make_str("using"), $2); }
+ | /*EMPTY*/ { $$ = EMPTY; }
+ ;
/*****************************************************************************
*
;
analyze_keyword: ANALYZE { $$ = make_str("analyze"); }
- | ANALYSE { $$ = make_str("analyse"); }
+ | ANALYSE { $$ = make_str("analyse"); }
;
opt_verbose: VERBOSE { $$ = make_str("verbose"); }
| DeleteStmt
;
-prep_type_clause: '(' prep_type_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
+prep_type_clause: '(' type_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
| /* EMPTY * / { $$ = EMPTY; }
;
-prep_type_list: Typename { $$ = $1; }
- | prep_type_list ',' Typename { $$ = cat_str(3, $1, make_str(","), $3); }
- ;
-
ExecuteStmt: EXECUTE name execute_param_clause
{ $$ = cat_str(3, make_str("execute"), $2, $3); }
- | CREATE OptTemp TABLE qualified_name OptCreateAs AS EXECUTE name execute_param_clause
- { $$ = cat_str(8, make_str("create"), $2, make_str("table"), $4, $5, make_str("as execute"), $8, $9); }
+ | CREATE OptTemp TABLE create_as_target AS
+ EXECUTE name execute_param_clause
+ { $$ = cat_str(11, make_str("create"), $2, make_str("table"), $4, $5, $6, $7, $8, make_str("as execute"), $11, $12); }
;
execute_param_clause: '(' expr_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
DeallocateStmt: DEALLOCATE name { $$ = cat2_str(make_str("deallocate"), $2); }
| DEALLOCATE PREPARE name { $$ = cat2_str(make_str("deallocate prepare"), $3); }
+ | DEALLOCATE ALL { $$ = make_str("deallocate all"); }
+ | DEALLOCATE PREPARE ALL { $$ = make_str("deallocate prepare all"); }
;
*/
*
*****************************************************************************/
-InsertStmt: INSERT INTO qualified_name insert_rest
- { $$ = cat_str(3, make_str("insert into"), $3, $4); }
+InsertStmt: INSERT INTO qualified_name insert_rest returning_clause
+ { $$ = cat_str(4, make_str("insert into"), $3, $4, $5); }
;
-insert_rest: VALUES '(' insert_target_list ')'
- { $$ = cat_str(3, make_str("values("), $3, make_str(")")); }
- | DEFAULT VALUES
- { $$ = make_str("default values"); }
- | SelectStmt
+insert_rest:
+ SelectStmt
{ $$ = $1; }
- | '(' insert_column_list ')' VALUES '(' insert_target_list ')'
- { $$ = cat_str(5, make_str("("), $2, make_str(") values ("), $6, make_str(")")); }
| '(' insert_column_list ')' SelectStmt
{ $$ = cat_str(4, make_str("("), $2, make_str(")"), $4); }
+ | DEFAULT VALUES
+ { $$ = make_str("default values"); }
;
insert_column_list: insert_column_list ',' insert_column_item
{ $$ = cat2_str($1, $2); }
;
+returning_clause: RETURNING target_list { $$ = cat2_str(make_str("returning"), $2); }
+ | /* EMPTY */ { $$ = EMPTY; }
+ ;
/*****************************************************************************
*
*
*****************************************************************************/
-DeleteStmt: DELETE_P FROM relation_expr using_clause where_clause
- { $$ = cat_str(4, make_str("delete from"), $3, $4, $5); }
+DeleteStmt: DELETE_P FROM relation_expr_opt_alias using_clause where_or_current_clause returning_clause
+ { $$ = cat_str(5, make_str("delete from"), $3, $4, $5, $6); }
;
using_clause: USING from_list { cat2_str(make_str("using"), $2); }
*
*****************************************************************************/
-UpdateStmt: UPDATE relation_expr
- SET update_target_list
+UpdateStmt: UPDATE relation_expr_opt_alias
+ SET set_clause_list
from_clause
- where_clause
- {$$ = cat_str(6, make_str("update"), $2, make_str("set"), $4, $5, $6); }
+ where_or_current_clause
+ returning_clause
+ {$$ = cat_str(7, make_str("update"), $2, make_str("set"), $4, $5, $6, $7); }
+ ;
+
+set_clause_list:
+ set_clause { $$ = $1; }
+ | set_clause_list ',' set_clause { $$ = cat_str(3, $1, make_str(","), $3); }
+ ;
+
+set_clause:
+ single_set_clause { $$ = $1; }
+ | multiple_set_clause { $$ = $1; }
;
+single_set_clause:
+ set_target '=' ctext_expr { $$ = cat_str(3, $1, make_str("="), $3); };
+
+multiple_set_clause:
+ '(' set_target_list ')' '=' ctext_row { $$ = cat_str(4, make_str("("), $2, make_str(")="), $5); };
+
+set_target:
+ ColId opt_indirection { $$ = cat2_str($1, $2); };
+
+set_target_list:
+ set_target { $$ = $1; }
+ | set_target_list ',' set_target { $$ = cat_str(3, $1, make_str(","), $3); }
+ ;
/*****************************************************************************
*
into_clause from_clause where_clause
group_clause having_clause
{ $$ = cat_str(8, make_str("select"), $2, $3, $4, $5, $6, $7, $8); }
+ | values_clause
+ { $$ = $1; }
| select_clause UNION opt_all select_clause
{ $$ = cat_str(4, $1, make_str("union"), $3, $4); }
| select_clause INTERSECT opt_all select_clause
| sortby_list ',' sortby { $$ = cat_str(3, $1, make_str(","), $3); }
;
-sortby: a_expr USING qual_all_Op
- { $$ = cat_str(3, $1, make_str("using"), $3); }
- | a_expr ASC
- { $$ = cat2_str($1, make_str("asc")); }
- | a_expr DESC
- { $$ = cat2_str($1, make_str("desc")); }
- | a_expr
- { $$ = $1; }
+sortby: a_expr USING qual_all_Op opt_nulls_order
+ { $$ = cat_str(4, $1, make_str("using"), $3, $4); }
+ | a_expr opt_asc_desc opt_nulls_order
+ { $$ = cat_str(3, $1, $2, $3); }
;
select_limit: LIMIT select_limit_value OFFSET select_offset_value
{ $$ = EMPTY; }
;
-for_locking_clause: FOR UPDATE locked_rels_list opt_nowait
+for_locking_clause:
+ for_locking_items { $$ = $1; }
+ | FOR READ ONLY { $$ = make_str("for read only");}
+ ;
+
+opt_for_locking_clause:
+ for_locking_clause { $$ = $1; }
+ | /* EMPTY */ { $$ = EMPTY; }
+ ;
+
+for_locking_items:
+ for_locking_item { $$ = $1; }
+ | for_locking_items for_locking_item { $$ = cat2_str($1, $2); }
+ ;
+
+for_locking_item:
+ FOR UPDATE locked_rels_list opt_nowait
{ $$ = cat_str(3, make_str("for update"), $3, $4); }
| FOR SHARE locked_rels_list opt_nowait
{ $$ = cat_str(3, make_str("for share"), $3, $4); }
- | FOR READ ONLY
- { $$ = make_str("for read only"); }
- ;
-
-opt_for_locking_clause: for_locking_clause { $$ = $1; }
- | /* EMPTY */ { $$ = EMPTY; }
;
locked_rels_list:
| /* EMPTY */ { $$ = EMPTY; }
;
+values_clause: VALUES ctext_row
+ { $$ = cat2_str(make_str("values"), $2); }
+ | values_clause ',' ctext_row
+ { $$ = cat_str(3, $1, make_str(","), $3); }
+ ;
+
/*****************************************************************************
*
* clauses common to all Optimizable Stmts:
{ $$ = cat_str(3, make_str("("), $2, make_str(")")); }
| table_ref CROSS JOIN table_ref
{ $$ = cat_str(3, $1, make_str("cross join"), $4); }
- | table_ref UNIONJOIN table_ref
- { $$ = cat_str(3, $1, make_str("unionjoin"), $3); }
| table_ref join_type JOIN table_ref join_qual
{ $$ = cat_str(5, $1, $2, make_str("join"), $4, $5); }
| table_ref JOIN table_ref join_qual
{ /* inheritance query */ $$ = cat_str(3, make_str("only ("), $3, make_str(")")); }
;
+relation_expr_opt_alias: relation_expr %prec UMINUS
+ { $$ = $1; }
+ | relation_expr ColId
+ { $$ = cat2_str($1, $2); }
+ | relation_expr AS ColId
+ { $$ = cat_str(3, $1, make_str("as"), $3); }
+ ;
+
func_table: func_expr { $$ = $1; }
;
| /*EMPTY*/ { $$ = EMPTY; /* no qualifiers */ }
;
+where_or_current_clause: WHERE a_expr { $$ = cat2_str(make_str("where"), $2); }
+ | WHERE CURRENT_P OF name { $$ = cat2_str(make_str("where current of"), $4); }
+ | WHERE CURRENT_P OF PARAM { $$ = make_str("where current of param"); }
+ | /*EMPTY*/ { $$ = EMPTY; /* no qualifiers */ }
+ ;
+
TableFuncElementList: TableFuncElement
{ $$ = $1; }
| TableFuncElementList ',' TableFuncElement
{ $$ = cat2_str($1, $2); }
| ConstInterval '(' PosIntConst ')' opt_interval
{ $$ = cat_str(5, $1, make_str("("), $3, make_str(")"), $5); }
- | type_name attrs
- { $$ = cat2_str($1, $2);}
;
-ConstTypename: GenericType { $$ = $1; }
- | ConstDatetime { $$ = $1; }
- | Numeric { $$ = $1; }
+ConstTypename: Numeric { $$ = $1; }
| ConstBit { $$ = $1; }
| ConstCharacter { $$ = $1; }
+ | ConstDatetime { $$ = $1; }
;
-GenericType: type_name { $$ = $1; }
+GenericType: type_function_name opt_type_modifiers { $$ = cat2_str($1, $2); }
+ | type_function_name attrs opt_type_modifiers { $$ = cat_str(3, $1, $2, $3); }
;
+opt_type_modifiers: '(' expr_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
+ | /* EMPTY */ { $$ = EMPTY; }
+ ;
+
/* SQL92 numeric data types
* Check FLOAT() precision limits assuming IEEE floating types.
* Provide real DECIMAL() and NUMERIC() implementations now - Jan 1998-12-30
{ $$ = cat2_str(make_str("float"), $2); }
| DOUBLE_P PRECISION
{ $$ = make_str("double precision"); }
- | DECIMAL_P opt_decimal
+ | DECIMAL_P opt_type_modifiers
{ $$ = cat2_str(make_str("decimal"), $2); }
- | DEC opt_decimal
+ | DEC opt_type_modifiers
{ $$ = cat2_str(make_str("dec"), $2); }
- | NUMERIC opt_numeric
+ | NUMERIC opt_type_modifiers
{ $$ = cat2_str(make_str("numeric"), $2); }
| BOOLEAN_P
{ $$ = make_str("boolean"); }
{ $$ = EMPTY; }
;
-opt_numeric: '(' PosIntConst ',' PosIntConst ')'
- { $$ = cat_str(5, make_str("("), $2, make_str(","), $4, make_str(")")); }
- | '(' PosIntConst ')'
- { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
- | /*EMPTY*/
- { $$ = EMPTY; }
- ;
-
-opt_decimal: '(' PosIntConst ',' PosIntConst ')'
- { $$ = cat_str(5, make_str("("), $2, make_str(","), $4, make_str(")")); }
- | '(' PosIntConst ')'
- { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
- | /*EMPTY*/
- { $$ = EMPTY; }
- ;
-
/*
* SQL92 bit-field data types
* The following implements BIT() and BIT VARYING().
| BitWithoutLength { $$ = $1; }
;
-BitWithLength: BIT opt_varying '(' PosIntConst ')'
+BitWithLength: BIT opt_varying '(' expr_list ')'
{ $$ = cat_str(5, make_str("bit"), $2, make_str("("), $4, make_str(")")); }
;
{ $$ = cat2_str($1, make_str("notnull")); }
| a_expr IS NOT NULL_P
{ $$ = cat2_str($1, make_str("is not null")); }
+ | row OVERLAPS row
+ { $$ = cat_str(3, $1, make_str("overlaps"), $3); }
/* IS TRUE, IS FALSE, etc used to be function calls
* but let's make them expressions to allow the optimizer
* a chance to eliminate them if a_expr is a constant string.
{ $$ = cat_str(4, $1, $2, $3, $4); }
| a_expr subquery_Op sub_type '(' a_expr ')' %prec Op
{ $$ = cat_str(6, $1, $2, $3, make_str("("), $5, make_str(")")); }
- | UNIQUE select_with_parens %prec Op
+ | UNIQUE select_with_parens
{ $$ = cat2_str(make_str("unique"), $2); }
+ | a_expr IS DOCUMENT_P
+ { $$ = cat2_str($1, make_str("is document")); }
+ | a_expr IS NOT DOCUMENT_P
+ { $$ = cat2_str($1, make_str("is not document")); }
;
/* Restricted expressions
{ $$ = cat_str(4, $1, make_str("is of ("), $5, make_str(")")); }
| b_expr IS NOT OF '(' b_expr ')' %prec IS
{ $$ = cat_str(4, $1, make_str("is not of ("), $6, make_str(")")); }
+ | b_expr IS DOCUMENT_P
+ { $$ = cat2_str($1, make_str("is document")); }
+ | b_expr IS NOT DOCUMENT_P
+ { $$ = cat2_str($1, make_str("is not document")); }
;
/*
{ $$ = cat_str(3, make_str("greatest("), $3, make_str(")")); }
| LEAST '(' expr_list ')'
{ $$ = cat_str(3, make_str("least("), $3, make_str(")")); }
+ | XMLCONCAT '(' expr_list ')'
+ { $$ = cat_str(3, make_str("xmlconcat("), $3, make_str(")")); }
+ | XMLELEMENT '(' NAME_P ColLabel ')'
+ { $$ = cat_str(3, make_str("xmlelement( name"), $4, make_str(")")); }
+ | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ')'
+ { $$ = cat_str(5, make_str("xmlelement( name"), $4, make_str(","), $6, make_str(")")); }
+ | XMLELEMENT '(' NAME_P ColLabel ',' expr_list ')'
+ { $$ = cat_str(5, make_str("xmlelement( name"), $4, make_str(","), $6, make_str(")")); }
+ | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ',' expr_list ')'
+ { $$ = cat_str(7, make_str("xmlelement( name"), $4, make_str(","), $6, make_str(","), $8, make_str(")")); }
+ | XMLFOREST '(' xml_attribute_list ')'
+ { $$ = cat_str(3, make_str("xmlforest("), $3, make_str(")")); }
+ | XMLPARSE '(' document_or_content a_expr xml_whitespace_option ')'
+ { $$ = cat_str(5, make_str("xmlparse("), $3, $4, $5, make_str(")")); }
+ | XMLPI '(' NAME_P ColLabel ')'
+ { $$ = cat_str(3, make_str("xmlpi( name"), $4, make_str(")")); }
+ | XMLPI '(' NAME_P ColLabel ',' a_expr ')'
+ { $$ = cat_str(5, make_str("xmlpi( name"), $4, make_str(","), $6, make_str(")")); }
+ | XMLROOT '(' a_expr ',' xml_root_version opt_xml_root_standalone ')'
+ { $$ = cat_str(6, make_str("xmlroot("), $3, make_str(","), $5, $6, make_str(")")); }
+ ;
+
+/*
+ * SQL/XML support
+ */
+
+xml_root_version: VERSION_P a_expr
+ { $$ = cat2_str(make_str("version"), $2); }
+ | VERSION_P NO VALUE_P
+ { $$ = make_str("version no value"); }
+ ;
+
+opt_xml_root_standalone: ',' STANDALONE_P YES_P
+ { $$ = make_str(", standalone yes"); }
+ | ',' STANDALONE_P NO
+ { $$ = make_str(", standalone no"); }
+ | ',' STANDALONE_P NO VALUE_P
+ { $$ = make_str(", standalone no value"); }
+ | /*EMPTY*/
+ { $$ = EMPTY; }
+ ;
+
+xml_attributes: XMLATTRIBUTES '(' xml_attribute_list ')'
+ { $$ = cat_str(3, make_str("xmlattributes("), $3, make_str(")")); }
+ ;
+
+xml_attribute_list: xml_attribute_el
+ { $$ = $1; }
+ | xml_attribute_list ',' xml_attribute_el
+ { $$ = cat_str(3, $1, make_str(","), $3); }
+ ;
+
+xml_attribute_el: a_expr AS ColLabel
+ { $$ = cat_str(3, $1, make_str("as"), $3); }
+ | a_expr
+ { $$ = $1; }
;
+document_or_content: DOCUMENT_P { $$ = make_str("document"); }
+ | CONTENT_P { $$ = make_str("content"); }
+ ;
+
+xml_whitespace_option: PRESERVE WHITESPACE_P { $$ = make_str("preserve whitespace"); }
+ | STRIP_P WHITESPACE_P { $$ = make_str("strip whitespace"); }
+ | /*EMPTY*/ { $$ = EMPTY; }
+ ;
row: ROW '(' expr_list ')'
{ $$ = cat_str(3, make_str("row ("), $3, make_str(")")); }
{ $$ = EMPTY; }
;
-type_list: type_list ',' Typename
- { $$ = cat_str(3, $1, ',', $3); }
- | Typename
+type_list: Typename
{ $$ = $1; }
+ | type_list ',' Typename
+ { $$ = cat_str(3, $1, ',', $3); }
;
array_expr_list: array_expr { $$ = $1; }
| /*EMPTY*/ { $$ = EMPTY; }
;
+ctext_expr:
+ a_expr { $$ = $1; }
+ | DEFAULT { $$ = make_str("default"); }
+ ;
+
+ctext_expr_list:
+ ctext_expr { $$ = $1; }
+ | ctext_expr_list ',' ctext_expr { $$ = cat_str(3, $1, make_str(","), $3); }
+ ;
+
+ctext_row: '(' ctext_expr_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")"));};
+
/*****************************************************************************
*
- * target lists for SELECT, UPDATE, INSERT
+ * target lists for SELECT
*
*****************************************************************************/
{ $$ = make_str("*"); }
;
-/* Target list as found in UPDATE table SET ... */
-update_target_list: update_target_list ',' update_target_el
- { $$ = cat_str(3, $1, make_str(","),$3); }
- | '(' inf_col_list ')' '=' '(' inf_val_list ')'
+/* INFORMIX workaround, no longer needed
+update_target_list: '(' inf_col_list ')' '=' '(' inf_val_list ')'
{
struct inf_compat_col *ptrc;
struct inf_compat_val *ptrv;
vals = cat_str( 3, vals, ptrv->val, make_str(")") );
}
$$ = cat_str( 3, cols, make_str("="), vals );
- }
- | update_target_el
- { $$ = $1; }
+ }
;
inf_col_list: ColId opt_indirection
informix_val = ptr;
}
;
-
-update_target_el: ColId opt_indirection '=' a_expr
- { $$ = cat_str(4, $1, $2, make_str("="), $4); }
- | ColId opt_indirection '=' DEFAULT
- { $$ = cat_str(3, $1, $2, make_str("= default")); }
- ;
-
-insert_target_list: insert_target_list ',' insert_target_el
- { $$ = cat_str(3, $1, make_str(","), $3); }
- | insert_target_el
- { $$ = $1; }
- ;
-
-insert_target_el: a_expr { $$ = $1; }
- | DEFAULT { $$ = make_str("default"); }
- ;
-
+*/
/*****************************************************************************
*
file_name: StringConst { $$ = $1; };
-func_name: function_name
+func_name: type_function_name
{ $$ = $1; }
| relation_name indirection
{ $$ = cat2_str($1, $2); }
$$[strlen($1)+2]='\0';
free($1);
}
- ;
+ | DOLCONST
+ {
+ $$ = $1;
+ }
+ ;
PosIntConst: Iconst { $$ = $1; }
| civar { $$ = $1; }
| NumConst { $$ = $1; }
;
-PosAllConst: Sconst { $$ = $1; }
- | Fconst { $$ = $1; }
- | Iconst { $$ = $1; }
- | Bconst { $$ = $1; }
- | Xconst { $$ = $1; }
- | civar { $$ = $1; }
+PosAllConst: Sconst { $$ = $1; }
+ | Fconst { $$ = $1; }
+ | Iconst { $$ = $1; }
+ | Bconst { $$ = $1; }
+ | Xconst { $$ = $1; }
+ | func_name Sconst { $$ = cat2_str($1, $2); }
+ | func_name '(' expr_list ')' Sconst
+ { $$ = cat_str(5, $1, make_str("("), $3, make_str(")"), $5); }
+ | civar { $$ = $1; }
;
RoleId: ColId { $$ = $1;};
ECPGConnect: SQL_CONNECT TO connection_target opt_connection_name opt_user
{ $$ = cat_str(5, $3, make_str(","), $5, make_str(","), $4); }
| SQL_CONNECT TO DEFAULT
- { $$ = make_str("NULL,NULL,NULL,\"DEFAULT\""); }
+ { $$ = make_str("NULL, NULL, NULL, \"DEFAULT\""); }
/* also allow ORACLE syntax */
| SQL_CONNECT ora_user
- { $$ = cat_str(3, make_str("NULL,"), $2, make_str(",NULL")); }
+ { $$ = cat_str(3, make_str("NULL,"), $2, make_str(", NULL")); }
| DATABASE connection_target
- { $$ = cat2_str($2, make_str(",NULL,NULL,NULL")); }
+ { $$ = cat2_str($2, make_str(", NULL, NULL, NULL")); }
;
-connection_target: database_name opt_server opt_port
+connection_target: opt_database_name opt_server opt_port
{
/* old style: dbname[@server][:port] */
if (strlen($2) > 0 && *($2) != '@')
mmerror(PARSE_ERROR, ET_ERROR, "Expected '@', found '%s'", $2);
-
- $$ = make3_str(make_str("\""), make3_str($1, $2, $3), make_str("\""));
+
+ /* C strings need to be handled differently */
+ if ($1[0] == '\"')
+ $$ = $1;
+ else
+ $$ = make3_str(make_str("\""), make3_str($1, $2, $3), make_str("\""));
}
- | db_prefix ':' server opt_port '/' database_name opt_options
+ | db_prefix ':' server opt_port '/' opt_database_name opt_options
{
/* new style: <tcp|unix>:postgresql://server[:port][/dbname] */
if (strncmp($1, "unix:postgresql", strlen("unix:postgresql")) != 0 && strncmp($1, "tcp:postgresql", strlen("tcp:postgresql")) != 0)
if (strncmp($1, "unix", strlen("unix")) == 0 &&
strncmp($3 + strlen("//"), "localhost", strlen("localhost")) != 0 &&
strncmp($3 + strlen("//"), "127.0.0.1", strlen("127.0.0.1")) != 0)
- mmerror(PARSE_ERROR, ET_ERROR, "unix domain sockets only work on 'localhost' but not on '%9.9s'", $3 + strlen("//"));
+ mmerror(PARSE_ERROR, ET_ERROR, "unix domain sockets only work on 'localhost' but not on '%s'", $3 + strlen("//"));
$$ = make3_str(make3_str(make_str("\""), $1, make_str(":")), $3, make3_str(make3_str($4, make_str("/"), $6), $7, make_str("\"")));
}
- | Sconst
+ | char_variable
{
- if ($1[0] == '\"')
- $$ = $1;
- else
- $$ = make3_str(make_str("\""), $1, make_str("\""));
+ $$ = $1;
}
- | char_variable
+ | Sconst
{
+ /* We can only process double quoted strings not single quotes ones,
+ * so we change the quotes.
+ * Note, that the rule for Sconst adds these single quotes. */
+ $1[0] = '\"';
+ $1[strlen($1)-1] = '\"';
$$ = $1;
}
;
+opt_database_name: database_name { $$ = $1; }
+ | /*EMPTY*/ { $$ = EMPTY; }
+ ;
+
db_prefix: ident cvariable
{
if (strcmp($2, "postgresql") != 0 && strcmp($2, "postgres") != 0)
;
opt_port: ':' PosIntConst { $$ = make2_str(make_str(":"), $2); }
- | /*EMPTY*/ { $$ = EMPTY; }
+ | /*EMPTY*/ { $$ = EMPTY; }
;
-opt_connection_name: AS connection_target { $$ = $2; }
+opt_connection_name: AS connection_object { $$ = $2; }
| /*EMPTY*/ { $$ = make_str("NULL"); }
;
opt_user: USER ora_user { $$ = $2; }
- | /*EMPTY*/ { $$ = make_str("NULL,NULL"); }
+ | /*EMPTY*/ { $$ = make_str("NULL, NULL"); }
;
ora_user: user_name
actual_startline[struct_level] = hashline_number();
}
- variable_list opt_bit_field';'
+ variable_list ';'
{
- $$ = cat_str(6, actual_startline[struct_level], $1, $2.type_str, $4, $5, make_str(";\n"));
+ $$ = cat_str(5, actual_startline[struct_level], $1, $2.type_str, $4, make_str(";\n"));
}
| var_type
{
actual_startline[struct_level] = hashline_number();
}
- variable_list opt_bit_field';'
+ variable_list ';'
{
- $$ = cat_str(5, actual_startline[struct_level], $1.type_str, $3, $4, make_str(";\n"));
+ $$ = cat_str(4, actual_startline[struct_level], $1.type_str, $3, make_str(";\n"));
}
| struct_union_type_with_symbol ';'
{
;
vt_declarations: var_declaration { $$ = $1; }
- | type_declaration { $$ = $1; }
+ | type_declaration { $$ = $1; }
| vt_declarations var_declaration { $$ = cat2_str($1, $2); }
| vt_declarations type_declaration { $$ = cat2_str($1, $2); }
- | vt_declarations CPP_LINE { $$ = cat2_str($1, $2); }
+ | vt_declarations CPP_LINE { $$ = cat2_str($1, $2); }
;
variable_declarations: var_declaration { $$ = $1; }
actual_startline[struct_level] = hashline_number();
}
- variable_list opt_bit_field';'
+ variable_list ';'
{
- $$ = cat_str(6, actual_startline[struct_level], $1, $2.type_str, $4, $5, make_str(";\n"));
+ $$ = cat_str(5, actual_startline[struct_level], $1, $2.type_str, $4, make_str(";\n"));
}
| var_type
{
actual_startline[struct_level] = hashline_number();
}
- variable_list opt_bit_field';'
+ variable_list ';'
{
- $$ = cat_str(5, actual_startline[struct_level], $1.type_str, $3, $4, make_str(";\n"));
+ $$ = cat_str(4, actual_startline[struct_level], $1.type_str, $3, make_str(";\n"));
}
| struct_union_type_with_symbol ';'
{
}
;
-enum_type: SQL_ENUM symbol enum_definition
+enum_type: ENUM_P symbol enum_definition
{ $$ = cat_str(3, make_str("enum"), $2, $3); }
- | SQL_ENUM enum_definition
+ | ENUM_P enum_definition
{ $$ = cat2_str(make_str("enum"), $2); }
- | SQL_ENUM symbol
+ | ENUM_P symbol
{ $$ = cat2_str(make_str("enum"), $2); }
;
{ $$ = cat_str(3, $1, make_str(","), $3); }
;
-variable: opt_pointer ECPGColLabel opt_array_bounds opt_initializer
+variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer
{
struct ECPGtype * type;
char *dimension = $3.index1; /* dimension of array */
else
type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_sizeof), dimension);
- $$ = cat_str(4, $1, mm_strdup($2), $3.str, $4);
+ $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
break;
case ECPGt_varchar:
mmerror(PARSE_ERROR, ET_ERROR, "pointer to varchar are not implemented");
if (strcmp(dimension, "0") == 0)
- $$ = cat_str(6, make2_str(make_str(" struct varchar_"), mm_strdup($2)), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } *"), mm_strdup($2), $4);
+ $$ = cat_str(7, make2_str(make_str(" struct varchar_"), mm_strdup($2)), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } *"), mm_strdup($2), $4, $5);
else
- $$ = cat_str(7, make2_str(make_str(" struct varchar_"), mm_strdup($2)), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } "), mm_strdup($2), mm_strdup(dim), $4);
+ $$ = cat_str(8, make2_str(make_str(" struct varchar_"), mm_strdup($2)), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } "), mm_strdup($2), mm_strdup(dim), $4, $5);
break;
case ECPGt_char:
case ECPGt_unsigned_char:
if (atoi(dimension) == -1)
+ {
+ int i = strlen($5);
+
+ if (atoi(length) == -1 && i > 0) /* char <var>[] = "string" */
+ {
+ /* if we have an initializer but no string size set, let's use the initializer's length */
+ free(length);
+ length = mm_alloc(i+sizeof("sizeof()"));
+ sprintf(length, "sizeof(%s)", $5+2);
+ }
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
+ }
else
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length), dimension);
- $$ = cat_str(4, $1, mm_strdup($2), $3.str, $4);
+ $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
break;
default:
else
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, make_str("1")), dimension);
- $$ = cat_str(4, $1, mm_strdup($2), $3.str, $4);
+ $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
break;
}
ECPGDisconnect: SQL_DISCONNECT dis_name { $$ = $2; }
;
-dis_name: connection_object { $$ = $1; }
- | SQL_CURRENT { $$ = make_str("\"CURRENT\""); }
- | ALL { $$ = make_str("\"ALL\""); }
- | /*EMPTY*/ { $$ = make_str("\"CURRENT\""); }
+dis_name: connection_object { $$ = $1; }
+ | CURRENT_P { $$ = make_str("\"CURRENT\""); }
+ | ALL { $$ = make_str("\"ALL\""); }
+ | /* EMPTY */ { $$ = make_str("\"CURRENT\""); }
;
-connection_object: connection_target { $$ = $1; }
- | DEFAULT { $$ = make_str("\"DEFAULT\""); }
+connection_object: database_name { $$ = make3_str(make_str("\""), $1, make_str("\"")); }
+ | DEFAULT { $$ = make_str("\"DEFAULT\""); }
+ | char_variable { $$ = $1; }
;
/*
* manipulate a descriptor
*/
-ECPGGetDescriptor: GET SQL_DESCRIPTOR quoted_ident_stringvar SQL_VALUE IntConstVar ECPGGetDescItems
+ECPGGetDescriptor: GET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGGetDescItems
{ $$.str = $5; $$.name = $3; }
;
ECPGGetDescItem: cvariable '=' descriptor_item { push_assignment($1, $3); };
-ECPGSetDescriptor: SET SQL_DESCRIPTOR quoted_ident_stringvar SQL_VALUE IntConstVar ECPGSetDescItems
+ECPGSetDescriptor: SET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGSetDescItems
{ $$.str = $5; $$.name = $3; }
;
descriptor_item: SQL_CARDINALITY { $$ = ECPGd_cardinality; }
- | SQL_DATA { $$ = ECPGd_data; }
+ | SQL_DATA { $$ = ECPGd_data; }
| SQL_DATETIME_INTERVAL_CODE { $$ = ECPGd_di_code; }
| SQL_DATETIME_INTERVAL_PRECISION { $$ = ECPGd_di_precision; }
- | SQL_INDICATOR { $$ = ECPGd_indicator; }
- | SQL_KEY_MEMBER { $$ = ECPGd_key_member; }
- | SQL_LENGTH { $$ = ECPGd_length; }
- | SQL_NAME { $$ = ECPGd_name; }
- | SQL_NULLABLE { $$ = ECPGd_nullable; }
- | SQL_OCTET_LENGTH { $$ = ECPGd_octet; }
- | PRECISION { $$ = ECPGd_precision; }
- | SQL_RETURNED_LENGTH { $$ = ECPGd_length; }
- | SQL_RETURNED_OCTET_LENGTH { $$ = ECPGd_ret_octet; }
- | SQL_SCALE { $$ = ECPGd_scale; }
- | TYPE_P { $$ = ECPGd_type; }
+ | SQL_INDICATOR { $$ = ECPGd_indicator; }
+ | SQL_KEY_MEMBER { $$ = ECPGd_key_member; }
+ | SQL_LENGTH { $$ = ECPGd_length; }
+ | NAME_P { $$ = ECPGd_name; }
+ | SQL_NULLABLE { $$ = ECPGd_nullable; }
+ | SQL_OCTET_LENGTH { $$ = ECPGd_octet; }
+ | PRECISION { $$ = ECPGd_precision; }
+ | SQL_RETURNED_LENGTH { $$ = ECPGd_length; }
+ | SQL_RETURNED_OCTET_LENGTH { $$ = ECPGd_ret_octet; }
+ | SQL_SCALE { $$ = ECPGd_scale; }
+ | TYPE_P { $$ = ECPGd_type; }
;
{
when_warn.code = $<action>3.code;
when_warn.command = $<action>3.command;
- $$ = cat_str(3, make_str("/* exec sql whenever sql_warning "), $3.str, make_str("; */\n"));
+ $$ = cat_str(3, make_str("/* exec sql whenever sql_warning "), $3.str, make_str("; */"));
}
;
| SQL_CALL name
{
$<action>$.code = W_DO;
- $<action>$.command = cat_str(3, $2, make_str("("), make_str(")"));
+ $<action>$.command = cat2_str($2, make_str("()"));
$<action>$.str = cat2_str(make_str("call"), mm_strdup($<action>$.command));
}
;
| SQL_INDICATOR { $$ = make_str("indicator"); }
| SQL_KEY_MEMBER { $$ = make_str("key_member"); }
| SQL_LENGTH { $$ = make_str("length"); }
- | SQL_NAME { $$ = make_str("name"); }
| SQL_NULLABLE { $$ = make_str("nullable"); }
| SQL_OCTET_LENGTH { $$ = make_str("octet_length"); }
| SQL_RETURNED_LENGTH { $$ = make_str("returned_length"); }
| SQL_SQLPRINT { $$ = make_str("sqlprint"); }
| SQL_SQLWARNING { $$ = make_str("sqlwarning"); }
| SQL_STOP { $$ = make_str("stop"); }
- | SQL_VALUE { $$ = make_str("value"); }
;
ECPGKeywords_rest: SQL_CONNECT { $$ = make_str("connect"); }
* is chosen in part to make keywords acceptable as names wherever possible.
*/
-ECPGColId:ident { $$ = $1; }
+ECPGColId:ident { $$ = $1; }
| ECPGunreserved_interval { $$ = $1; }
| ECPGunreserved_con { $$ = $1; }
- | col_name_keyword { $$ = $1; }
- | ECPGKeywords { $$ = $1; }
- | ECPGCKeywords { $$ = $1; }
- | CHAR_P { $$ = make_str("char"); }
+ | col_name_keyword { $$ = $1; }
+ | ECPGKeywords { $$ = $1; }
+ | ECPGCKeywords { $$ = $1; }
+ | CHAR_P { $$ = make_str("char"); }
+ | VALUES { $$ = make_str("values"); }
;
/* Column identifier --- names that can be column, table, etc names.
*/
-ColId: ident { $$ = $1; }
+ColId: ident { $$ = $1; }
| unreserved_keyword { $$ = $1; }
- | col_name_keyword { $$ = $1; }
- | ECPGKeywords { $$ = $1; }
- | ECPGCKeywords { $$ = $1; }
- | CHAR_P { $$ = make_str("char"); }
+ | col_name_keyword { $$ = $1; }
+ | ECPGKeywords { $$ = $1; }
+ | ECPGCKeywords { $$ = $1; }
+ | CHAR_P { $$ = make_str("char"); }
+ | VALUES { $$ = make_str("values"); }
;
-
-/* Type identifier --- names that can be type names.
+/* Type/function identifier --- names that can be type names.
*/
-type_name: ident { $$ = $1; }
+type_function_name: ident { $$ = $1; }
| unreserved_keyword { $$ = $1; }
+ | type_func_name_keyword { $$ = $1; }
| ECPGKeywords { $$ = $1; }
| ECPGTypeName { $$ = $1; }
| ECPGCKeywords { $$ = $1; }
;
-/* Function identifier --- names that can be function names.
- */
-function_name: ident { $$ = $1; }
- | unreserved_keyword { $$ = $1; }
- | func_name_keyword { $$ = $1; }
- | ECPGKeywords { $$ = $1; }
- | ECPGCKeywords { $$ = $1; }
- ;
-
/* Column label --- allowed labels in "AS" clauses.
* This presently includes *all* Postgres keywords.
*/
ColLabel: ECPGColLabel { $$ = $1; }
- | ECPGTypeName { $$ = $1; }
- | CHAR_P { $$ = make_str("char"); }
- | INPUT_P { $$ = make_str("input"); }
- | INT_P { $$ = make_str("int"); }
- | UNION { $$ = make_str("union"); }
- | TO { $$ = make_str("to"); }
- | ECPGCKeywords { $$ = $1; }
+ | ECPGTypeName { $$ = $1; }
+ | CHAR_P { $$ = make_str("char"); }
+ | INPUT_P { $$ = make_str("input"); }
+ | INT_P { $$ = make_str("int"); }
+ | UNION { $$ = make_str("union"); }
+ | TO { $$ = make_str("to"); }
+ | ECPGCKeywords { $$ = $1; }
| ECPGunreserved_interval { $$ = $1; }
;
ECPGColLabelCommon: ident { $$ = $1; }
- | col_name_keyword { $$ = $1; }
- | func_name_keyword { $$ = $1; }
+ | col_name_keyword { $$ = $1; }
+ | type_func_name_keyword { $$ = $1; }
| ECPGKeywords_vanames { $$ = $1; }
;
ECPGColLabel: ECPGColLabelCommon { $$ = $1; }
- | reserved_keyword { $$ = $1; }
- | ECPGunreserved { $$ = $1; }
- | ECPGKeywords_rest { $$ = $1; }
+ | reserved_keyword { $$ = $1; }
+ | ECPGunreserved { $$ = $1; }
+ | ECPGKeywords_rest { $$ = $1; }
;
ECPGCKeywords: S_AUTO { $$ = make_str("auto"); }
| AGGREGATE { $$ = make_str("aggregate"); }
| ALSO { $$ = make_str("also"); }
| ALTER { $$ = make_str("alter"); }
+ | ALWAYS { $$ = make_str("always"); }
| ASSERTION { $$ = make_str("assertion"); }
| ASSIGNMENT { $$ = make_str("assignment"); }
| AT { $$ = make_str("at"); }
| BY { $$ = make_str("by"); }
| CACHE { $$ = make_str("cache"); }
| CASCADE { $$ = make_str("cascade"); }
+ | CASCADED { $$ = make_str("cascaded"); }
| CHAIN { $$ = make_str("chain"); }
| CHARACTERISTICS { $$ = make_str("characteristics"); }
| CHECKPOINT { $$ = make_str("checkpoint"); }
| COMMENT { $$ = make_str("comment"); }
| COMMIT { $$ = make_str("commit"); }
| COMMITTED { $$ = make_str("committed"); }
+ | CONCURRENTLY { $$ = make_str("concurrently"); }
/* | CONNECTION { $$ = make_str("connection"); }*/
| CONSTRAINTS { $$ = make_str("constraints"); }
+ | CONTENT_P { $$ = make_str("content"); }
| CONVERSION_P { $$ = make_str("conversion"); }
| COPY { $$ = make_str("copy"); }
+ | COST { $$ = make_str("cost"); }
| CREATEDB { $$ = make_str("createdb"); }
| CREATEROLE { $$ = make_str("createrole"); }
| CREATEUSER { $$ = make_str("createuser"); }
| DELIMITER { $$ = make_str("delimiter"); }
| DELIMITERS { $$ = make_str("delimiters"); }
| DISABLE_P { $$ = make_str("disable"); }
+ | DISCARD { $$ = make_str("discard"); }
+ | DOCUMENT_P { $$ = make_str("document"); }
| DOMAIN_P { $$ = make_str("domain"); }
| DOUBLE_P { $$ = make_str("double"); }
| DROP { $$ = make_str("drop"); }
| EACH { $$ = make_str("each"); }
- | ENABLE_P { $$ = make_str("ensable"); }
+ | ENABLE_P { $$ = make_str("enable"); }
| ENCODING { $$ = make_str("encoding"); }
| ENCRYPTED { $$ = make_str("encrypted"); }
+/* | ENUM_P { $$ = make_str("enum"); }*/
| ESCAPE { $$ = make_str("escape"); }
| EXCLUDING { $$ = make_str("excluding"); }
| EXCLUSIVE { $$ = make_str("exclusive"); }
| EXECUTE { $$ = make_str("execute"); }
| EXPLAIN { $$ = make_str("explain"); }
+ | EXTERNAL { $$ = make_str("external"); }
+ | FAMILY { $$ = make_str("family"); }
| FETCH { $$ = make_str("fetch"); }
| FIRST_P { $$ = make_str("first"); }
| FORCE { $$ = make_str("force"); }
| INCLUDING { $$ = make_str("including"); }
| INCREMENT { $$ = make_str("increment"); }
| INDEX { $$ = make_str("index"); }
+ | INDEXES { $$ = make_str("indexes"); }
| INHERIT { $$ = make_str("inherit"); }
| INHERITS { $$ = make_str("inherits"); }
| INSENSITIVE { $$ = make_str("insensitive"); }
| MODE { $$ = make_str("mode"); }
/* | MONTH_P { $$ = make_str("month"); }*/
| MOVE { $$ = make_str("move"); }
+ | NAME_P { $$ = make_str("name"); }
| NAMES { $$ = make_str("names"); }
| NEXT { $$ = make_str("next"); }
| NO { $$ = make_str("no"); }
| NOTHING { $$ = make_str("nothing"); }
| NOTIFY { $$ = make_str("notify"); }
| NOWAIT { $$ = make_str("nowait"); }
+ | NULLS_P { $$ = make_str("nulls"); }
| OBJECT_P { $$ = make_str("object"); }
| OF { $$ = make_str("of"); }
| OIDS { $$ = make_str("oids"); }
| OWNER { $$ = make_str("owner"); }
| PARTIAL { $$ = make_str("partial"); }
| PASSWORD { $$ = make_str("password"); }
+ | PLANS { $$ = make_str("plans"); }
| PREPARE { $$ = make_str("prepare"); }
| PREPARED { $$ = make_str("prepared"); }
| PRESERVE { $$ = make_str("preserver"); }
| RENAME { $$ = make_str("rename"); }
| REPEATABLE { $$ = make_str("repeatable"); }
| REPLACE { $$ = make_str("replace"); }
+ | REPLICA { $$ = make_str("replica"); }
| RESET { $$ = make_str("reset"); }
| RESTART { $$ = make_str("restart"); }
| RESTRICT { $$ = make_str("restrict"); }
| SHOW { $$ = make_str("show"); }
| SIMPLE { $$ = make_str("simple"); }
| STABLE { $$ = make_str("stable"); }
+ | STANDALONE_P { $$ = make_str("standalone"); }
| START { $$ = make_str("start"); }
| STATEMENT { $$ = make_str("statement"); }
| STATISTICS { $$ = make_str("statistics"); }
| STDIN { $$ = make_str("stdin"); }
| STDOUT { $$ = make_str("stdout"); }
| STORAGE { $$ = make_str("storage"); }
- | SUPERUSER_P { $$ = make_str("superuser"); }
| STRICT_P { $$ = make_str("strict"); }
+ | STRIP_P { $$ = make_str("strip"); }
+ | SUPERUSER_P { $$ = make_str("superuser"); }
| SYSTEM_P { $$ = make_str("system"); }
| SYSID { $$ = make_str("sysid"); }
| TABLESPACE { $$ = make_str("tablespace"); }
| TEMP { $$ = make_str("temp"); }
| TEMPLATE { $$ = make_str("template"); }
| TEMPORARY { $$ = make_str("temporary"); }
- | TOAST { $$ = make_str("toast"); }
| TRANSACTION { $$ = make_str("transaction"); }
| TRIGGER { $$ = make_str("trigger"); }
| TRUNCATE { $$ = make_str("truncate"); }
| UPDATE { $$ = make_str("update"); }
| VACUUM { $$ = make_str("vacuum"); }
| VALID { $$ = make_str("valid"); }
- | VALUES { $$ = make_str("values"); }
+ | VALIDATOR { $$ = make_str("validator"); }
+ | VALUE_P { $$ = make_str("value"); }
| VARYING { $$ = make_str("varying"); }
+ | VERSION_P { $$ = make_str("version"); }
| VIEW { $$ = make_str("view"); }
+ | VOLATILE { $$ = make_str("volatile"); }
+ | WHITESPACE_P { $$ = make_str("whitespace"); }
| WITH { $$ = make_str("with"); }
| WITHOUT { $$ = make_str("without"); }
| WORK { $$ = make_str("work"); }
| WRITE { $$ = make_str("write"); }
+ | XML_P { $$ = make_str("xml"); }
+ | YES_P { $$ = make_str("yes"); }
/* | YEAR_P { $$ = make_str("year"); }*/
| ZONE { $$ = make_str("zone"); }
;
| TIMESTAMP { $$ = make_str("timestamp"); }
| TREAT { $$ = make_str("treat"); }
| TRIM { $$ = make_str("trim"); }
+ /* VALUES creates a shift/reduce problem if listed here
+ | VALUES { $$ = make_str("values"); } */
| VARCHAR { $$ = make_str("varchar"); }
+ | XMLATTRIBUTES { $$ = make_str("xmlattributes"); }
+ | XMLCONCAT { $$ = make_str("xmlconcat"); }
+ | XMLELEMENT { $$ = make_str("xmlelement"); }
+ | XMLFOREST { $$ = make_str("xmlforest"); }
+ | XMLPARSE { $$ = make_str("xmlparse"); }
+ | XMLPI { $$ = make_str("xmlpi"); }
+ | XMLROOT { $$ = make_str("xmlroot"); }
+ | XMLSERIALIZE { $$ = make_str("xmlserialize"); }
;
/* Function identifier --- keywords that can be function names.
* productions in a_expr to support the goofy SQL9x argument syntax.
* - thomas 2000-11-28
*/
-func_name_keyword:
+type_func_name_keyword:
AUTHORIZATION { $$ = make_str("authorization"); }
| BETWEEN { $$ = make_str("between"); }
| BINARY { $$ = make_str("binary"); }
| COLUMN { $$ = make_str("column"); }
| CONSTRAINT { $$ = make_str("constraint"); }
| CREATE { $$ = make_str("create"); }
+ | CURRENT_P { $$ = make_str("current"); }
| CURRENT_DATE { $$ = make_str("current_date"); }
| CURRENT_TIME { $$ = make_str("current_time"); }
| CURRENT_TIMESTAMP { $$ = make_str("current_timestamp"); }
| OR { $$ = make_str("or"); }
| ORDER { $$ = make_str("order"); }
| PRIMARY { $$ = make_str("primary"); }
- | REFERENCES { $$ = make_str("references"); }
+ | REFERENCES { $$ = make_str("references"); }
+ | RETURNING { $$ = make_str("returning"); }
| SELECT { $$ = make_str("select"); }
- | SESSION_USER { $$ = make_str("session_user"); }
+ | SESSION_USER { $$ = make_str("session_user"); }
| SOME { $$ = make_str("some"); }
| SYMMETRIC { $$ = make_str("symmetric"); }
| TABLE { $$ = make_str("table"); }
}
;
ident: IDENT { $$ = $1; }
- | CSTRING { $$ = make3_str(make_str("\""), $1, make_str("\"")); }
+ | CSTRING { $$ = make3_str(make_str("\""), $1, make_str("\"")); }
;
quoted_ident_stringvar: name
{ $$ = cat_str(3, make_str("("), $2, make_str(")")); }
;
-c_stuff: c_stuff_item { $$ = $1; }
+c_stuff: c_stuff_item { $$ = $1; }
| c_stuff c_stuff_item
{ $$ = cat2_str($1, $2); }
;
| '{' c_list '}' { $$ = cat_str(3, make_str("{"), $2, make_str("}")); }
;
-c_thing: c_anything { $$ = $1; }
- | '(' { $$ = make_str("("); }
- | ')' { $$ = make_str(")"); }
- | ',' { $$ = make_str(","); }
- | ';' { $$ = make_str(";"); }
- | ':' { $$ = make_str(":"); }
+c_thing: c_anything { $$ = $1; }
+ | '(' { $$ = make_str("("); }
+ | ')' { $$ = make_str(")"); }
+ | ',' { $$ = make_str(","); }
+ | ';' { $$ = make_str(";"); }
;
-c_anything: IDENT { $$ = $1; }
+c_anything: IDENT { $$ = $1; }
| CSTRING { $$ = make3_str(make_str("\""), $1, make_str("\"")); }
| Iconst { $$ = $1; }
| Fconst { $$ = $1; }
| NULL_P { $$ = make_str("NULL"); }
| S_ADD { $$ = make_str("+="); }
| S_AND { $$ = make_str("&&"); }
- | S_ANYTHING { $$ = make_name(); }
+ | S_ANYTHING { $$ = make_name(); }
| S_AUTO { $$ = make_str("auto"); }
| S_CONST { $$ = make_str("const"); }
| S_DEC { $$ = make_str("--"); }
| S_DIV { $$ = make_str("/="); }
- | S_DOTPOINT { $$ = make_str(".*"); }
+ | S_DOTPOINT { $$ = make_str(".*"); }
| S_EQUAL { $$ = make_str("=="); }
| S_EXTERN { $$ = make_str("extern"); }
| S_INC { $$ = make_str("++"); }
| S_LSHIFT { $$ = make_str("<<"); }
| S_MEMBER { $$ = make_str("->"); }
- | S_MEMPOINT { $$ = make_str("->*"); }
+ | S_MEMPOINT { $$ = make_str("->*"); }
| S_MOD { $$ = make_str("%="); }
| S_MUL { $$ = make_str("*="); }
| S_NEQUAL { $$ = make_str("!="); }
| S_OR { $$ = make_str("||"); }
- | S_REGISTER { $$ = make_str("register"); }
+ | S_REGISTER { $$ = make_str("register"); }
| S_RSHIFT { $$ = make_str(">>"); }
| S_STATIC { $$ = make_str("static"); }
| S_SUB { $$ = make_str("-="); }
| S_TYPEDEF { $$ = make_str("typedef"); }
- | S_VOLATILE { $$ = make_str("volatile"); }
+ | S_VOLATILE { $$ = make_str("volatile"); }
| SQL_BOOL { $$ = make_str("bool"); }
- | SQL_ENUM { $$ = make_str("enum"); }
+ | ENUM_P { $$ = make_str("enum"); }
| HOUR_P { $$ = make_str("hour"); }
| INT_P { $$ = make_str("int"); }
| SQL_LONG { $$ = make_str("long"); }
| MONTH_P { $$ = make_str("month"); }
| SECOND_P { $$ = make_str("second"); }
| SQL_SHORT { $$ = make_str("short"); }
- | SQL_SIGNED { $$ = make_str("signed"); }
- | SQL_STRUCT { $$ = make_str("struct"); }
- | SQL_UNSIGNED { $$ = make_str("unsigned"); }
+ | SQL_SIGNED { $$ = make_str("signed"); }
+ | SQL_STRUCT { $$ = make_str("struct"); }
+ | SQL_UNSIGNED { $$ = make_str("unsigned"); }
| YEAR_P { $$ = make_str("year"); }
| CHAR_P { $$ = make_str("char"); }
| FLOAT_P { $$ = make_str("float"); }
| '[' { $$ = make_str("["); }
| ']' { $$ = make_str("]"); }
| '=' { $$ = make_str("="); }
+ | ':' { $$ = make_str(":"); }
;
%%
-void yyerror( char * error)
+void base_yyerror(const char * error)
{
char buf[1024];
mmerror(PARSE_ERROR, ET_ERROR, buf);
}
+void parser_init(void)
+{
+ /* This function is empty. It only exists for compatibility with the backend parser right now. */
+}
+
+/*
+ * Must undefine base_yylex before including pgc.c, since we want it
+ * to create the function base_yylex not filtered_base_yylex.
+ */
+#undef base_yylex
+
#include "pgc.c"