1
- /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.296 2004/09/06 11:23:07 meskes Exp $ */
1
+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.297 2004/09/27 09:59:17 meskes Exp $ */
2
2
3
3
/* Copyright comment */
4
4
%{
@@ -326,7 +326,7 @@ add_additional_variables(char *name, bool insert)
326
326
SQL_FREE SQL_GO SQL_GOTO SQL_IDENTIFIED
327
327
SQL_INDICATOR SQL_KEY_MEMBER SQL_LENGTH
328
328
SQL_LONG SQL_NAME SQL_NULLABLE SQL_OCTET_LENGTH
329
- SQL_OPEN SQL_OUTPUT SQL_RELEASE SQL_REFERENCE
329
+ SQL_OPEN SQL_OUTPUT SQL_REFERENCE
330
330
SQL_RETURNED_LENGTH SQL_RETURNED_OCTET_LENGTH SQL_SCALE
331
331
SQL_SECTION SQL_SHORT SQL_SIGNED SQL_SQL SQL_SQLERROR
332
332
SQL_SQLPRINT SQL_SQLWARNING SQL_START SQL_STOP
@@ -395,10 +395,11 @@ add_additional_variables(char *name, bool insert)
395
395
396
396
QUOTE
397
397
398
- READ REAL RECHECK REFERENCES REINDEX RELATIVE_P RENAME REPEATABLE REPLACE
399
- RESET RESTART RESTRICT RETURNS REVOKE RIGHT ROLLBACK ROW ROWS RULE
398
+ READ REAL RECHECK REFERENCES REINDEX RELATIVE_P RELEASE RENAME
399
+ REPEATABLE REPLACE RESET RESTART RESTRICT RETURNS REVOKE RIGHT
400
+ ROLLBACK ROW ROWS RULE
400
401
401
- SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE SERIALIZABLE
402
+ SAVEPOINT SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE SERIALIZABLE
402
403
SESSION SESSION_USER SET SETOF SHARE SHOW SIMILAR SIMPLE SMALLINT SOME
403
404
STABLE START STATEMENT STATISTICS STDIN STDOUT STORAGE STRICT_P
404
405
SUBSTRING SYSID
@@ -472,7 +473,7 @@ add_additional_variables(char *name, bool insert)
472
473
%type <str> Typename SimpleTypename Numeric opt_float opt_numeric
473
474
%type <str> opt_decimal Character character opt_varying opt_charset
474
475
%type <str> opt_timezone opt_interval table_ref fetch_direction
475
- %type <str> ConstDatetime AlterDomainStmt AlterSeqStmt
476
+ %type <str> ConstDatetime AlterDomainStmt AlterSeqStmt alter_rel_cmds
476
477
%type <str> SelectStmt into_clause OptTemp ConstraintAttributeSpec
477
478
%type <str> opt_table opt_all sort_clause sortby_list ConstraintAttr
478
479
%type <str> sortby qualified_name_list name_list ColId_or_Sconst
@@ -529,7 +530,7 @@ add_additional_variables(char *name, bool insert)
529
530
%type <str> handler_name any_name_list any_name opt_as insert_column_list
530
531
%type <str> columnref function_name insert_target_el AllConstVar
531
532
%type <str> insert_target_list insert_column_item DropRuleStmt
532
- %type <str> createfunc_opt_item set_rest var_list_or_default
533
+ %type <str> createfunc_opt_item set_rest var_list_or_default alter_rel_cmd
533
534
%type <str> CreateFunctionStmt createfunc_opt_list func_table
534
535
%type <str> DropUserStmt copy_from copy_opt_list copy_opt_item
535
536
%type <str> opt_oids TableLikeClause key_action opt_definition
@@ -538,13 +539,13 @@ add_additional_variables(char *name, bool insert)
538
539
%type <str> iso_level type_list CharacterWithLength ConstCharacter
539
540
%type <str> CharacterWithoutLength BitWithLength BitWithoutLength
540
541
%type <str> ConstBit GenericType TableFuncElementList opt_analyze
541
- %type <str> opt_sort_clause transaction_access_mode subquery_Op
542
+ %type <str> opt_sort_clause subquery_Op transaction_mode_item
542
543
%type <str> ECPGWhenever ECPGConnect connection_target ECPGOpen
543
544
%type <str> indicator ECPGExecute ECPGPrepare ecpg_using ecpg_into
544
545
%type <str> storage_declaration storage_clause opt_initializer c_anything
545
546
%type <str> variable_list variable c_thing c_term ECPGKeywords_vanames
546
547
%type <str> opt_pointer ECPGDisconnect dis_name storage_modifier
547
- %type <str> ECPGRelease execstring server_name ECPGVarDeclaration
548
+ %type <str> execstring server_name ECPGVarDeclaration
548
549
%type <str> connection_object opt_server opt_port c_stuff c_stuff_item
549
550
%type <str> user_name opt_user char_variable ora_user ident opt_reference
550
551
%type <str> var_type_declarations quoted_ident_stringvar ECPGKeywords_rest
@@ -561,7 +562,7 @@ add_additional_variables(char *name, bool insert)
561
562
%type <str> col_name_keyword func_name_keyword precision opt_scale
562
563
%type <str> ECPGTypeName using_list ECPGColLabelCommon UsingConst
563
564
%type <str> inf_val_list inf_col_list using_descriptor into_descriptor
564
- %type <str> prepared_name struct_union_type_with_symbol
565
+ %type <str> prepared_name struct_union_type_with_symbol OptConsTableSpace
565
566
%type <str> ECPGunreserved ECPGunreserved_interval cvariable
566
567
%type <str> AlterOwnerStmt OptTableSpaceOwner CreateTableSpaceStmt
567
568
%type <str> DropTableSpaceStmt indirection indirection_el ECPGSetDescriptorHeader
@@ -816,7 +817,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
816
817
whenever_action (2 );
817
818
free ($1 );
818
819
}
819
- | ECPGRelease { /* output already done */ }
820
+ /* | ECPGRelease { / * output already done * / } */
820
821
| ECPGSetAutocommit
821
822
{
822
823
fprintf (yyout, " { ECPGsetcommit(__LINE__, \" %s\" , %s);" , $1 , connection ? connection : " NULL" );
@@ -1177,15 +1178,18 @@ CheckPointStmt: CHECKPOINT { $$= make_str("checkpoint"); }
1177
1178
1178
1179
/* ****************************************************************************
1179
1180
*
1180
- * ALTER TABLE variations
1181
+ * ALTER [ TABLE | INDEX ] variations
1181
1182
*
1182
1183
*****************************************************************************/
1183
1184
1184
1185
AlterTableStmt :
1185
1186
ALTER TABLE relation_expr alter_table_cmds
1186
1187
{ $$ = cat_str(3 , make_str(" alter table" ), $3 , $4 ); }
1188
+ | ALTER INDEX relation_expr alter_rel_cmds
1189
+ { $$ = cat_str(3 , make_str(" alter table" ), $3 , $4 ); }
1187
1190
;
1188
1191
1192
+ /* Subcommands that are for ALTER TABLE only */
1189
1193
alter_table_cmds :
1190
1194
alter_table_cmd { $$ = $1 ; }
1191
1195
| alter_table_cmds ' ,' alter_table_cmd { $$ = cat_str(3 , $1 , make_str(" ," ), $3 ); }
@@ -1228,16 +1232,24 @@ alter_table_cmd:
1228
1232
/* ALTER TABLE <name> CREATE TOAST TABLE */
1229
1233
| CREATE TOAST TABLE
1230
1234
{ $$ = make_str(" create toast table" ); }
1231
- /* ALTER TABLE <name> OWNER TO UserId */
1232
- | OWNER TO UserId
1233
- { $$ = cat_str(2 , make_str(" owner to" ), $3 ); }
1234
1235
/* ALTER TABLE <name> CLUSTER ON <indexname> */
1235
1236
| CLUSTER ON name
1236
1237
{ $$ = cat_str(2 , make_str(" cluster on" ), $3 ); }
1237
1238
/* ALTER TABLE <name> SET WITHOUT CLUSTER */
1238
1239
| SET WITHOUT CLUSTER
1239
1240
{ $$ = make_str(" set without cluster" ); }
1240
- /* ALTER TABLE <name> SET TABLESPACE <tablespacename> */
1241
+ ;
1242
+
1243
+ alter_rel_cmds : alter_rel_cmd { $$ = $1 ; }
1244
+ | alter_rel_cmds ' ,' alter_rel_cmd { $$ = cat_str(3 , $1 , make_str(" ," ), $3 ); }
1245
+ ;
1246
+
1247
+ /* Subcommands that are for ALTER TABLE or ALTER INDEX */
1248
+ alter_rel_cmd :
1249
+ /* ALTER [TABLE|INDEX] <name> OWNER TO UserId */
1250
+ OWNER TO UserId
1251
+ { $$ = cat_str(2 , make_str(" owner to" ), $3 ); }
1252
+ /* ALTER [TABLE|INDEX] <name> SET TABLESPACE <tablespacename> */
1241
1253
| SET TABLESPACE name
1242
1254
{ $$ = cat_str(2 , make_str(" set tablespace" ), $3 ); }
1243
1255
;
@@ -1417,10 +1429,10 @@ ColConstraintElem: NOT NULL_P
1417
1429
{ $$ = make_str(" not null" ); }
1418
1430
| NULL_P
1419
1431
{ $$ = make_str(" null" ); }
1420
- | UNIQUE
1421
- { $$ = make_str(" unique" ); }
1422
- | PRIMARY KEY
1423
- { $$ = make_str(" primary key" ); }
1432
+ | UNIQUE OptConsTableSpace
1433
+ { $$ = cat2_str( make_str(" unique" ), $2 ); }
1434
+ | PRIMARY KEY OptConsTableSpace
1435
+ { $$ = cat2_str( make_str(" primary key" ), $3 ); }
1424
1436
| CHECK ' (' a_expr ' )'
1425
1437
{ $$ = cat_str(3 , make_str(" check (" ), $3 , make_str(" )" )); }
1426
1438
| DEFAULT b_expr
@@ -1470,10 +1482,10 @@ TableConstraint: CONSTRAINT name ConstraintElem
1470
1482
1471
1483
ConstraintElem : CHECK ' (' a_expr ' )'
1472
1484
{ $$ = cat_str(3 , make_str(" check(" ), $3 , make_str(" )" )); }
1473
- | UNIQUE ' (' columnList ' )'
1474
- { $$ = cat_str(3 , make_str(" unique(" ), $3 , make_str(" )" )); }
1475
- | PRIMARY KEY ' (' columnList ' )'
1476
- { $$ = cat_str(3 , make_str(" primary key(" ), $4 , make_str(" )" )); }
1485
+ | UNIQUE ' (' columnList ' )' OptConsTableSpace
1486
+ { $$ = cat_str(4 , make_str(" unique(" ), $3 , make_str(" )" ), $5 ); }
1487
+ | PRIMARY KEY ' (' columnList ' )' OptConsTableSpace
1488
+ { $$ = cat_str(4 , make_str(" primary key(" ), $4 , make_str(" )" ), $6 ); }
1477
1489
| FOREIGN KEY ' (' columnList ' )' REFERENCES qualified_name opt_column_list
1478
1490
key_match key_actions ConstraintAttributeSpec
1479
1491
{ $$ = cat_str(8 , make_str(" foreign key(" ), $4 , make_str(" ) references" ), $7 , $8 , $9 , $10 , $11 ); }
@@ -1546,6 +1558,10 @@ OptTableSpace: TABLESPACE name { $$ = cat2_str(make_str("tablespace"), $2); }
1546
1558
| /* EMPTY*/ { $$ = EMPTY; }
1547
1559
;
1548
1560
1561
+ OptConsTableSpace : USING INDEX TABLESPACE name { $$ = cat2_str(make_str(" using index tablespace" ), $4 ); }
1562
+ | /* EMPTY*/ { $$ = EMPTY; }
1563
+ ;
1564
+
1549
1565
/*
1550
1566
* Note: CREATE TABLE ... AS SELECT ... is just another spelling for
1551
1567
* SELECT ... INTO.
@@ -2192,7 +2208,7 @@ index_params: index_elem { $$ = $1; }
2192
2208
| index_params ' ,' index_elem { $$ = cat_str(3 , $1 , make_str(" ," ), $3 ); }
2193
2209
;
2194
2210
2195
- index_elem : attr_name opt_class
2211
+ index_elem : ColId opt_class
2196
2212
{ $$ = cat2_str($1 , $2 ); }
2197
2213
| func_name ' (' expr_list ' )' opt_class
2198
2214
{ $$ = cat_str(5 , $1 , make_str(" (" ), $3 , " )" , $5 ); }
@@ -2416,6 +2432,8 @@ RenameStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' RENAME TO name
2416
2432
{ $$ = cat_str(4 , make_str(" alter schema" ), $3 , make_str(" rename to" ), $6 ); }
2417
2433
| ALTER TABLE relation_expr RENAME TO name
2418
2434
{ $$ = cat_str(4 , make_str(" alter table" ), $3 , make_str(" rename to" ), $6 ); }
2435
+ | ALTER INDEX relation_expr RENAME TO name
2436
+ { $$ = cat_str(4 , make_str(" alter index" ), $3 , make_str(" rename to" ), $6 ); }
2419
2437
| ALTER TABLE relation_expr RENAME opt_column name TO name
2420
2438
{ $$ = cat_str(7 , make_str(" alter table" ), $3 , make_str(" rename" ), $5 , $6 , make_str(" to" ), $8 ); }
2421
2439
| ALTER TRIGGER name ON relation_expr RENAME TO name
@@ -2545,40 +2563,43 @@ UnlistenStmt: UNLISTEN qualified_name
2545
2563
* (also older versions END / ABORT)
2546
2564
*
2547
2565
*****************************************************************************/
2548
- TransactionStmt : ABORT_P opt_transaction { $$ = make_str(" rollback" ); }
2566
+ TransactionStmt : ABORT_P opt_transaction { $$ = make_str(" rollback" ); }
2549
2567
| BEGIN_P opt_transaction transaction_mode_list_or_empty { $$ = cat2_str(make_str(" begin transaction" ), $3 ); }
2550
2568
| START TRANSACTION transaction_mode_list_or_empty { $$ = cat2_str(make_str(" start transaction" ), $3 ); }
2551
- | COMMIT opt_transaction { $$ = make_str(" commit" ); }
2552
- | END_P opt_transaction { $$ = make_str(" commit" ); }
2553
- | ROLLBACK opt_transaction { $$ = make_str(" rollback" ); }
2569
+ | COMMIT opt_transaction { $$ = make_str(" commit" ); }
2570
+ | END_P opt_transaction { $$ = make_str(" commit" ); }
2571
+ | ROLLBACK opt_transaction { $$ = make_str(" rollback" ); }
2572
+ | SAVEPOINT ColId { $$ = cat2_str(make_str(" savepoint" ), $2 ); }
2573
+ | RELEASE SAVEPOINT ColId { $$ = cat2_str(make_str(" release savepoint" ), $3 ); }
2574
+ | RELEASE ColId { $$ = cat2_str(make_str(" release" ), $2 ); }
2575
+ | ROLLBACK opt_transaction TO SAVEPOINT ColId { $$ = cat_str(4 , make_str(" rollback" ), $2 , make_str(" to savepoint" ), $5 ); }
2576
+ | ROLLBACK opt_transaction TO ColId { $$ = cat_str(4 , make_str(" rollback" ), $2 , make_str(" to" ), $4 ); }
2577
+
2554
2578
;
2555
2579
2556
2580
opt_transaction : WORK { $$ = EMPTY; }
2557
2581
| TRANSACTION { $$ = EMPTY; }
2558
2582
| /* EMPTY*/ { $$ = EMPTY; }
2559
2583
;
2560
2584
2561
- transaction_mode_list :
2585
+ transaction_mode_item :
2562
2586
ISOLATION LEVEL iso_level
2563
2587
{ $$ = cat2_str(make_str(" isolation level" ), $3 ); }
2564
- | transaction_access_mode
2565
- { $$ = $1 ; }
2566
- | ISOLATION LEVEL iso_level transaction_access_mode
2567
- { $$ = cat_str(3 , make_str(" isolation level" ), $3 , $4 ); }
2568
- | transaction_access_mode ISOLATION LEVEL iso_level
2569
- { $$ = cat_str(3 , $1 , make_str(" isolation level" ), $4 ); }
2588
+ | READ ONLY { $$ = make_str(" read only" ); }
2589
+ | READ WRITE { $$ = make_str(" read write" ); }
2590
+ ;
2591
+
2592
+ transaction_mode_list :
2593
+ transaction_mode_item { $$ = $1 ; }
2594
+ | transaction_mode_list ' ,' transaction_mode_item { $$ = cat_str(3 , $1 , make_str(" ," ), $3 ); }
2595
+ | transaction_mode_list transaction_mode_item { $$ = cat_str(3 , $1 , make_str(" " ), $2 ); }
2570
2596
;
2571
2597
2572
2598
transaction_mode_list_or_empty :
2573
2599
transaction_mode_list { $$ = $1 ; }
2574
2600
| /* EMPTY */ { $$ = EMPTY; }
2575
2601
;
2576
2602
2577
- transaction_access_mode :
2578
- READ ONLY { $$ = make_str(" read only" ); }
2579
- | READ WRITE { $$ = make_str(" read write" ); }
2580
- ;
2581
-
2582
2603
/* ****************************************************************************
2583
2604
*
2584
2605
* QUERY:
@@ -4156,7 +4177,7 @@ name_list: name
4156
4177
name : ColId { $$ = $1 ; };
4157
4178
database_name : ColId { $$ = $1 ; };
4158
4179
access_method : ColId { $$ = $1 ; };
4159
- attr_name : ColId { $$ = $1 ; };
4180
+ attr_name : ColLabel { $$ = $1 ; };
4160
4181
index_name : ColId { $$ = $1 ; };
4161
4182
4162
4183
file_name : StringConst { $$ = $1 ; };
@@ -5453,7 +5474,8 @@ descriptor_item: SQL_CARDINALITY { $$ = ECPGd_cardinality; }
5453
5474
* after a transaction statement to disconnect from the database.
5454
5475
*/
5455
5476
5456
- ECPGRelease : TransactionStmt SQL_RELEASE
5477
+ /* We cannot do that anymore since it causes shift/reduce conflicts. 2004-09-27 Michael Meskes
5478
+ ECPGRelease: TransactionStmt RELEASE
5457
5479
{
5458
5480
if (strcmp($1, "begin") == 0)
5459
5481
mmerror(PARSE_ERROR, ET_ERROR, "RELEASE does not make sense when beginning a transaction");
@@ -5467,6 +5489,7 @@ ECPGRelease: TransactionStmt SQL_RELEASE
5467
5489
free($1);
5468
5490
}
5469
5491
;
5492
+ */
5470
5493
5471
5494
/*
5472
5495
* set/reset the automatic transaction mode, this needs a differnet handling
@@ -5728,7 +5751,6 @@ ECPGKeywords_vanames: SQL_BREAK { $$ = make_str("break"); }
5728
5751
| SQL_NAME { $$ = make_str(" name" ); }
5729
5752
| SQL_NULLABLE { $$ = make_str(" nullable" ); }
5730
5753
| SQL_OCTET_LENGTH { $$ = make_str(" octet_length" ); }
5731
- | SQL_RELEASE { $$ = make_str(" release" ); }
5732
5754
| SQL_RETURNED_LENGTH { $$ = make_str(" returned_length" ); }
5733
5755
| SQL_RETURNED_OCTET_LENGTH { $$ = make_str(" returned_octet_length" ); }
5734
5756
| SQL_SCALE { $$ = make_str(" scale" ); }
@@ -5978,6 +6000,7 @@ ECPGunreserved: ABORT_P { $$ = make_str("abort"); }
5978
6000
| RECHECK { $$ = make_str(" recheck" ); }
5979
6001
| REINDEX { $$ = make_str(" reindex" ); }
5980
6002
| RELATIVE_P { $$ = make_str(" relative" ); }
6003
+ | RELEASE { $$ = make_str(" release" ); }
5981
6004
| RENAME { $$ = make_str(" rename" ); }
5982
6005
| REPEATABLE { $$ = make_str(" repeatable" ); }
5983
6006
| REPLACE { $$ = make_str(" replace" ); }
@@ -5989,6 +6012,7 @@ ECPGunreserved: ABORT_P { $$ = make_str("abort"); }
5989
6012
| ROLLBACK { $$ = make_str(" rollback" ); }
5990
6013
| ROWS { $$ = make_str(" rows" ); }
5991
6014
| RULE { $$ = make_str(" rule" ); }
6015
+ | SAVEPOINT { $$ = make_str(" savepoint" ); }
5992
6016
| SCHEMA { $$ = make_str(" schema" ); }
5993
6017
| SCROLL { $$ = make_str(" scroll" ); }
5994
6018
/* | SECOND_P { $$ = make_str("second"); }*/
0 commit comments