1- /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.334 2006/08/29 12:24:51 meskes Exp $*/
1+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.335 2006/09/03 12:24:07 meskes Exp $*/
22
33/* Copyright comment*/
44%{
@@ -360,7 +360,7 @@ add_additional_variables(char *name, bool insert)
360360CACHE CALLED CASCADE CASCADED CASE CAST CHAIN CHAR_P
361361CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
362362CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT
363- COMMITTED CONNECTION CONSTRAINT CONSTRAINTS CONVERSION_P CONVERT COPY CREATE CREATEDB
363+ COMMITTEDCONCURRENTLY CONNECTION CONSTRAINT CONSTRAINTS CONVERSION_P CONVERT COPY CREATE CREATEDB
364364CREATEROLE CREATEUSER CROSS CSV CURRENT_DATE CURRENT_ROLE CURRENT_TIME
365365CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
366366
@@ -575,7 +575,7 @@ add_additional_variables(char *name, bool insert)
575575%type <str> reserved_keyword unreserved_keyword ecpg_interval opt_ecpg_using
576576%type <str> col_name_keyword func_name_keyword precision opt_scale
577577%type <str> ECPGTypeName using_list ECPGColLabelCommon UsingConst
578- %type <str> inf_val_list inf_col_list using_descriptor into_descriptor
578+ %type <str> using_descriptor into_descriptor
579579%type <str> prepared_name struct_union_type_with_symbol OptConsTableSpace
580580%type <str> ECPGunreserved ECPGunreserved_interval cvariable opt_bit_field
581581%type <str> AlterOwnerStmt OptTableSpaceOwner CreateTableSpaceStmt
@@ -587,6 +587,8 @@ add_additional_variables(char *name, bool insert)
587587%type <str> locked_rels_list opt_granted_by RevokeRoleStmt alterdb_opt_item using_clause
588588%type <str> GrantRoleStmt opt_asymmetric aggr_args aggr_args_list old_aggr_definition
589589%type <str> old_aggr_elem for_locking_items TableLikeOptionList TableLikeOption
590+ %type <str> update_target_lists_list set_opt update_target_lists_el update_col_list
591+ %type <str> update_value_list update_col_list_el
590592
591593%type <struct_union> s_struct_union_symbol
592594
@@ -1369,14 +1371,6 @@ ClosePortalStmt: CLOSE name
13691371{$$ = cat2_str(make_str(" close" ),$2 );}
13701372;
13711373
1372- /* ****************************************************************************
1373- *
1374- *QUERY :
1375- *COPY [BINARY] <relname> FROM/TO
1376- *[USING DELIMITERS <delimiter>]
1377- *
1378- *****************************************************************************/
1379-
13801374CopyStmt :COPY opt_binary qualified_name opt_oids copy_from
13811375copy_file_name copy_delimiter opt_with copy_opt_list
13821376{
@@ -1389,6 +1383,13 @@ CopyStmt: COPY opt_binary qualified_name opt_oids copy_from
13891383
13901384$$ = cat_str(9 , make_str(" copy" ),$2 ,$3 ,$4 ,$5 ,$6 ,$7 ,$8 ,$9 );
13911385}
1386+ | COPY select_with_parens TO copy_file_name opt_with copy_opt_list
1387+ {
1388+ if (strcmp($4 ," stdin" ) ==0 )
1389+ mmerror (PARSE_ERROR, ET_ERROR," copy to stdin not possible.\n " );
1390+
1391+ $$ = cat_str(6 , make_str(" copy" ),$2 , make_str(" to" ),$4 ,$5 ,$6 );
1392+ }
13921393;
13931394
13941395copy_from :TO {$$ = make_str(" to" ); }
@@ -2331,15 +2332,22 @@ opt_granted_by: GRANTED BY RoleId { $$ = cat2_str(make_str("granted by"), $3);
23312332/* ****************************************************************************
23322333 *
23332334 *QUERY:
2334- *create index <indexname> on <relname>
2335- * [ using <access> ] "(" ( <col> | using <opclass> ] )+ ")"
2336- * [ tablespace <tablespacename> ] [ where <predicate> ]
2335+ * QUERY: CREATE INDEX
2336+ *
2337+ * Note: we can't factor CONCURRENTLY into a separate production without
2338+ * making it a reserved word.
2339+ *
2340+ * Note: we cannot put TABLESPACE clause after WHERE clause unless we are
2341+ * willing to make TABLESPACE a fully reserved word.
23372342 *
23382343 *****************************************************************************/
23392344
23402345IndexStmt :CREATE index_opt_unique INDEX index_name ON qualified_name
23412346access_method_clause ' (' index_params ' )' opt_definition OptTableSpace where_clause
23422347{$$ = cat_str(13 , make_str(" create" ),$2 , make_str(" index" ),$4 , make_str(" on" ),$6 ,$7 , make_str(" (" ),$9 , make_str(" )" ),$11 ,$12 ,$13 ); }
2348+ | CREATE index_opt_unique INDEX CONCURRENTLY index_name ON qualified_name
2349+ access_method_clause ' (' index_params ' )' opt_definition OptTableSpace where_clause
2350+ {$$ = 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 ); }
23432351;
23442352
23452353index_opt_unique :UNIQUE {$$ = make_str(" unique" ); }
@@ -3166,13 +3174,17 @@ opt_nowait: NOWAIT { $$ = make_str("nowait"); }
31663174 *****************************************************************************/
31673175
31683176UpdateStmt :UPDATE relation_expr_opt_alias
3169- SET update_target_list
3177+ SET set_opt
31703178from_clause
31713179where_clause
31723180returning_clause
31733181{$$ = cat_str(7 , make_str(" update" ),$2 , make_str(" set" ),$4 ,$5 ,$6 ,$7 ); }
31743182;
31753183
3184+ set_opt :
3185+ update_target_list {$$ =$1 ; }
3186+ | update_target_lists_list {$$ =$1 ; }
3187+ ;
31763188
31773189/* ****************************************************************************
31783190 *
@@ -3433,6 +3445,35 @@ values_item:a_expr{ $$ = $1; }
34333445| DEFAULT {$$ = make_str(" DEFAULT" ); }
34343446;
34353447
3448+ update_target_lists_list :
3449+ update_target_lists_el {$$ =$1 ; }
3450+ | update_target_lists_list ' ,' update_target_lists_el {$$ = cat_str(3 ,$1 , make_str(" ," ),$3 ); }
3451+ ;
3452+
3453+ update_target_lists_el :
3454+ ' (' update_col_list ' )' ' =' ' (' update_value_list ' )'
3455+ {
3456+ $$ = cat_str(5 , make_str(" (" ),$2 , make_str(" )=(" ),$6 , make_str(" )" ));
3457+ }
3458+ ;
3459+
3460+ update_col_list :
3461+ update_col_list_el {$$ =$1 ; }
3462+ | update_col_list ' ,' update_col_list_el {$$ = cat_str(3 ,$1 , make_str(" ," ),$3 ); }
3463+ ;
3464+
3465+ update_col_list_el :
3466+ ColId opt_indirection
3467+ {
3468+ $$ = cat2_str($1 ,$2 );
3469+ }
3470+ ;
3471+
3472+ update_value_list :
3473+ values_item {$$ =$1 ; }
3474+ | update_value_list ' ,' values_item {$$ = cat_str(3 ,$1 , make_str(" ," ),$3 ); }
3475+ ;
3476+
34363477/* ****************************************************************************
34373478 *
34383479 *clauses common to all Optimizable Stmts:
@@ -4337,6 +4378,7 @@ target_el:a_expr AS ColLabel
43374378/* Target list as found in UPDATE table SET ...*/
43384379update_target_list :update_target_list ' ,' update_target_el
43394380{$$ = cat_str(3 ,$1 , make_str(" ," ),$3 );}
4381+ /* INFORMIX workaround, no longer needed
43404382| '(' inf_col_list ')' '=' '(' inf_val_list ')'
43414383{
43424384struct inf_compat_col *ptrc;
@@ -4360,12 +4402,12 @@ update_target_list: update_target_list ',' update_target_el
43604402vals = cat_str( 3, vals, ptrv->val, make_str(")") );
43614403}
43624404$$ = cat_str( 3, cols, make_str("="), vals );
4363- }
4405+ }*/
43644406| update_target_el
43654407{$$ =$1 ;}
43664408;
43674409
4368- inf_col_list :ColId opt_indirection
4410+ /* inf_col_list: ColId opt_indirection
43694411{
43704412struct inf_compat_col *ptr = mm_alloc(sizeof(struct inf_compat_col));
43714413
@@ -4402,6 +4444,7 @@ inf_val_list: a_expr
44024444 informix_val = ptr;
44034445}
44044446;
4447+ */
44054448
44064449update_target_el :ColId opt_indirection ' =' a_expr
44074450{$$ = cat_str(4 ,$1 ,$2 , make_str(" =" ),$4 ); }
@@ -6216,6 +6259,7 @@ ECPGunreserved_con: ABORT_P{ $$ = make_str("abort"); }
62166259| COMMENT {$$ = make_str(" comment" ); }
62176260| COMMIT {$$ = make_str(" commit" ); }
62186261| COMMITTED {$$ = make_str(" committed" ); }
6262+ | CONCURRENTLY {$$ = make_str(" concurrently" ); }
62196263/* | CONNECTION{ $$ = make_str("connection"); }*/
62206264| CONSTRAINTS {$$ = make_str(" constraints" ); }
62216265| CONVERSION_P {$$ = make_str(" conversion" ); }