Skip to content

Commit d56b9fd

Browse files
author
Michael Meskes
committed
Synced parser.
Removed Oracle transaction syntax to fix shift/reduce error.
1 parent ae9df0b commit d56b9fd

File tree

4 files changed

+77
-47
lines changed

4 files changed

+77
-47
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,6 +1859,11 @@ Mon Sep 6 13:17:46 CEST 2004
18591859

18601860
- Fixed bug in Informix mode that caused a segfault.
18611861
- Set pgtypes library version to 1.2.
1862+
1863+
Mon Sep 27 11:05:49 CEST 2004
1864+
1865+
- Synced parser.
1866+
- Removed Oracle transaction syntax to fix shift/reduce error.
18621867
- Set ecpg version to 3.2.0.
18631868
- Set compat library version to 1.2.
18641869
- Set ecpg library version to 4.2.

src/interfaces/ecpg/preproc/ecpg_keywords.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* lexical token lookup for reserved words in postgres embedded SQL
55
*
66
* IDENTIFICATION
7-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.29 2003/11/29 19:52:08 pgsql Exp $
7+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.30 2004/09/27 09:59:17 meskes Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -57,7 +57,6 @@ static ScanKeyword ScanKeywords[] = {
5757
{"open", SQL_OPEN},
5858
{"output", SQL_OUTPUT},
5959
{"reference", SQL_REFERENCE},
60-
{"release", SQL_RELEASE},
6160
{"returned_length", SQL_RETURNED_LENGTH},
6261
{"returned_octet_length", SQL_RETURNED_OCTET_LENGTH},
6362
{"scale", SQL_SCALE},

src/interfaces/ecpg/preproc/keywords.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.66 2004/08/30 02:54:41 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.67 2004/09/27 09:59:17 meskes Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -249,6 +249,7 @@ static ScanKeyword ScanKeywords[] = {
249249
{"references", REFERENCES},
250250
{"reindex", REINDEX},
251251
{"relative", RELATIVE_P},
252+
{"release", RELEASE},
252253
{"rename", RENAME},
253254
{"repeatable", REPEATABLE},
254255
{"replace", REPLACE},
@@ -262,6 +263,7 @@ static ScanKeyword ScanKeywords[] = {
262263
{"row", ROW},
263264
{"rows", ROWS},
264265
{"rule", RULE},
266+
{"savepoint", SAVEPOINT},
265267
{"schema", SCHEMA},
266268
{"scroll", SCROLL},
267269
{"second", SECOND_P},

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 68 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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 $ */
22

33
/* Copyright comment */
44
%{
@@ -326,7 +326,7 @@ add_additional_variables(char *name, bool insert)
326326
SQL_FREE SQL_GO SQL_GOTO SQL_IDENTIFIED
327327
SQL_INDICATOR SQL_KEY_MEMBER SQL_LENGTH
328328
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
330330
SQL_RETURNED_LENGTH SQL_RETURNED_OCTET_LENGTH SQL_SCALE
331331
SQL_SECTION SQL_SHORT SQL_SIGNED SQL_SQL SQL_SQLERROR
332332
SQL_SQLPRINT SQL_SQLWARNING SQL_START SQL_STOP
@@ -395,10 +395,11 @@ add_additional_variables(char *name, bool insert)
395395

396396
QUOTE
397397

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
400401

401-
SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE SERIALIZABLE
402+
SAVEPOINT SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE SERIALIZABLE
402403
SESSION SESSION_USER SET SETOF SHARE SHOW SIMILAR SIMPLE SMALLINT SOME
403404
STABLE START STATEMENT STATISTICS STDIN STDOUT STORAGE STRICT_P
404405
SUBSTRING SYSID
@@ -472,7 +473,7 @@ add_additional_variables(char *name, bool insert)
472473
%type <str> Typename SimpleTypename Numeric opt_float opt_numeric
473474
%type <str> opt_decimal Character character opt_varying opt_charset
474475
%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
476477
%type <str> SelectStmt into_clause OptTemp ConstraintAttributeSpec
477478
%type <str> opt_table opt_all sort_clause sortby_list ConstraintAttr
478479
%type <str> sortby qualified_name_list name_list ColId_or_Sconst
@@ -529,7 +530,7 @@ add_additional_variables(char *name, bool insert)
529530
%type <str> handler_name any_name_list any_name opt_as insert_column_list
530531
%type <str> columnref function_name insert_target_el AllConstVar
531532
%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
533534
%type <str> CreateFunctionStmt createfunc_opt_list func_table
534535
%type <str> DropUserStmt copy_from copy_opt_list copy_opt_item
535536
%type <str> opt_oids TableLikeClause key_action opt_definition
@@ -538,13 +539,13 @@ add_additional_variables(char *name, bool insert)
538539
%type <str> iso_level type_list CharacterWithLength ConstCharacter
539540
%type <str> CharacterWithoutLength BitWithLength BitWithoutLength
540541
%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
542543
%type <str> ECPGWhenever ECPGConnect connection_target ECPGOpen
543544
%type <str> indicator ECPGExecute ECPGPrepare ecpg_using ecpg_into
544545
%type <str> storage_declaration storage_clause opt_initializer c_anything
545546
%type <str> variable_list variable c_thing c_term ECPGKeywords_vanames
546547
%type <str> opt_pointer ECPGDisconnect dis_name storage_modifier
547-
%type <str> ECPGRelease execstring server_name ECPGVarDeclaration
548+
%type <str> execstring server_name ECPGVarDeclaration
548549
%type <str> connection_object opt_server opt_port c_stuff c_stuff_item
549550
%type <str> user_name opt_user char_variable ora_user ident opt_reference
550551
%type <str> var_type_declarations quoted_ident_stringvar ECPGKeywords_rest
@@ -561,7 +562,7 @@ add_additional_variables(char *name, bool insert)
561562
%type <str> col_name_keyword func_name_keyword precision opt_scale
562563
%type <str> ECPGTypeName using_list ECPGColLabelCommon UsingConst
563564
%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
565566
%type <str> ECPGunreserved ECPGunreserved_interval cvariable
566567
%type <str> AlterOwnerStmt OptTableSpaceOwner CreateTableSpaceStmt
567568
%type <str> DropTableSpaceStmt indirection indirection_el ECPGSetDescriptorHeader
@@ -816,7 +817,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
816817
whenever_action(2);
817818
free($1);
818819
}
819-
| ECPGRelease { /* output already done */ }
820+
/* | ECPGRelease { / * output already done * / } */
820821
| ECPGSetAutocommit
821822
{
822823
fprintf(yyout, "{ ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
@@ -1177,15 +1178,18 @@ CheckPointStmt: CHECKPOINT { $$= make_str("checkpoint"); }
11771178

11781179
/*****************************************************************************
11791180
*
1180-
* ALTER TABLE variations
1181+
* ALTER [ TABLE | INDEX ] variations
11811182
*
11821183
*****************************************************************************/
11831184

11841185
AlterTableStmt:
11851186
ALTER TABLE relation_expr alter_table_cmds
11861187
{ $$ = 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); }
11871190
;
11881191

1192+
/* Subcommands that are for ALTER TABLE only */
11891193
alter_table_cmds:
11901194
alter_table_cmd { $$ = $1; }
11911195
| alter_table_cmds ',' alter_table_cmd { $$ = cat_str(3, $1, make_str(","), $3); }
@@ -1228,16 +1232,24 @@ alter_table_cmd:
12281232
/* ALTER TABLE <name> CREATE TOAST TABLE */
12291233
| CREATE TOAST TABLE
12301234
{ $$ = 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); }
12341235
/* ALTER TABLE <name> CLUSTER ON <indexname> */
12351236
| CLUSTER ON name
12361237
{ $$ = cat_str(2, make_str("cluster on"), $3); }
12371238
/* ALTER TABLE <name> SET WITHOUT CLUSTER */
12381239
| SET WITHOUT CLUSTER
12391240
{ $$ = 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> */
12411253
| SET TABLESPACE name
12421254
{ $$ = cat_str(2, make_str("set tablespace"), $3); }
12431255
;
@@ -1417,10 +1429,10 @@ ColConstraintElem: NOT NULL_P
14171429
{ $$ = make_str("not null"); }
14181430
| NULL_P
14191431
{ $$ = 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); }
14241436
| CHECK '(' a_expr ')'
14251437
{ $$ = cat_str(3, make_str("check ("), $3, make_str(")")); }
14261438
| DEFAULT b_expr
@@ -1470,10 +1482,10 @@ TableConstraint: CONSTRAINT name ConstraintElem
14701482

14711483
ConstraintElem: CHECK '(' a_expr ')'
14721484
{ $$ = 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); }
14771489
| FOREIGN KEY '(' columnList ')' REFERENCES qualified_name opt_column_list
14781490
key_match key_actions ConstraintAttributeSpec
14791491
{ $$ = 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); }
15461558
| /*EMPTY*/ { $$ = EMPTY; }
15471559
;
15481560

1561+
OptConsTableSpace: USING INDEX TABLESPACE name { $$ = cat2_str(make_str("using index tablespace"), $4); }
1562+
| /*EMPTY*/ { $$ = EMPTY; }
1563+
;
1564+
15491565
/*
15501566
* Note: CREATE TABLE ... AS SELECT ... is just another spelling for
15511567
* SELECT ... INTO.
@@ -2192,7 +2208,7 @@ index_params: index_elem { $$ = $1; }
21922208
| index_params ',' index_elem { $$ = cat_str(3, $1, make_str(","), $3); }
21932209
;
21942210

2195-
index_elem: attr_name opt_class
2211+
index_elem: ColId opt_class
21962212
{ $$ = cat2_str($1, $2); }
21972213
| func_name '(' expr_list ')' opt_class
21982214
{ $$ = cat_str(5, $1, make_str("("), $3, ")", $5); }
@@ -2416,6 +2432,8 @@ RenameStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' RENAME TO name
24162432
{ $$ = cat_str(4, make_str("alter schema"), $3, make_str("rename to"), $6); }
24172433
| ALTER TABLE relation_expr RENAME TO name
24182434
{ $$ = 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); }
24192437
| ALTER TABLE relation_expr RENAME opt_column name TO name
24202438
{ $$ = cat_str(7, make_str("alter table"), $3, make_str("rename"), $5, $6, make_str("to"), $8); }
24212439
| ALTER TRIGGER name ON relation_expr RENAME TO name
@@ -2545,40 +2563,43 @@ UnlistenStmt: UNLISTEN qualified_name
25452563
* (also older versions END / ABORT)
25462564
*
25472565
*****************************************************************************/
2548-
TransactionStmt: ABORT_P opt_transaction { $$ = make_str("rollback"); }
2566+
TransactionStmt: ABORT_P opt_transaction { $$ = make_str("rollback"); }
25492567
| BEGIN_P opt_transaction transaction_mode_list_or_empty { $$ = cat2_str(make_str("begin transaction"), $3); }
25502568
| 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+
25542578
;
25552579

25562580
opt_transaction: WORK { $$ = EMPTY; }
25572581
| TRANSACTION { $$ = EMPTY; }
25582582
| /*EMPTY*/ { $$ = EMPTY; }
25592583
;
25602584

2561-
transaction_mode_list:
2585+
transaction_mode_item:
25622586
ISOLATION LEVEL iso_level
25632587
{ $$ = 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); }
25702596
;
25712597

25722598
transaction_mode_list_or_empty:
25732599
transaction_mode_list { $$ = $1; }
25742600
| /* EMPTY */ { $$ = EMPTY; }
25752601
;
25762602

2577-
transaction_access_mode:
2578-
READ ONLY { $$ = make_str("read only"); }
2579-
| READ WRITE { $$ = make_str("read write"); }
2580-
;
2581-
25822603
/*****************************************************************************
25832604
*
25842605
* QUERY:
@@ -4156,7 +4177,7 @@ name_list: name
41564177
name: ColId { $$ = $1; };
41574178
database_name: ColId { $$ = $1; };
41584179
access_method: ColId { $$ = $1; };
4159-
attr_name: ColId { $$ = $1; };
4180+
attr_name: ColLabel { $$ = $1; };
41604181
index_name: ColId { $$ = $1; };
41614182

41624183
file_name: StringConst { $$ = $1; };
@@ -5453,7 +5474,8 @@ descriptor_item: SQL_CARDINALITY { $$ = ECPGd_cardinality; }
54535474
* after a transaction statement to disconnect from the database.
54545475
*/
54555476

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
54575479
{
54585480
if (strcmp($1, "begin") == 0)
54595481
mmerror(PARSE_ERROR, ET_ERROR, "RELEASE does not make sense when beginning a transaction");
@@ -5467,6 +5489,7 @@ ECPGRelease: TransactionStmt SQL_RELEASE
54675489
free($1);
54685490
}
54695491
;
5492+
*/
54705493

54715494
/*
54725495
* set/reset the automatic transaction mode, this needs a differnet handling
@@ -5728,7 +5751,6 @@ ECPGKeywords_vanames: SQL_BREAK { $$ = make_str("break"); }
57285751
| SQL_NAME { $$ = make_str("name"); }
57295752
| SQL_NULLABLE { $$ = make_str("nullable"); }
57305753
| SQL_OCTET_LENGTH { $$ = make_str("octet_length"); }
5731-
| SQL_RELEASE { $$ = make_str("release"); }
57325754
| SQL_RETURNED_LENGTH { $$ = make_str("returned_length"); }
57335755
| SQL_RETURNED_OCTET_LENGTH { $$ = make_str("returned_octet_length"); }
57345756
| SQL_SCALE { $$ = make_str("scale"); }
@@ -5978,6 +6000,7 @@ ECPGunreserved: ABORT_P { $$ = make_str("abort"); }
59786000
| RECHECK { $$ = make_str("recheck"); }
59796001
| REINDEX { $$ = make_str("reindex"); }
59806002
| RELATIVE_P { $$ = make_str("relative"); }
6003+
| RELEASE { $$ = make_str("release"); }
59816004
| RENAME { $$ = make_str("rename"); }
59826005
| REPEATABLE { $$ = make_str("repeatable"); }
59836006
| REPLACE { $$ = make_str("replace"); }
@@ -5989,6 +6012,7 @@ ECPGunreserved: ABORT_P { $$ = make_str("abort"); }
59896012
| ROLLBACK { $$ = make_str("rollback"); }
59906013
| ROWS { $$ = make_str("rows"); }
59916014
| RULE { $$ = make_str("rule"); }
6015+
| SAVEPOINT { $$ = make_str("savepoint"); }
59926016
| SCHEMA { $$ = make_str("schema"); }
59936017
| SCROLL { $$ = make_str("scroll"); }
59946018
/* | SECOND_P { $$ = make_str("second"); }*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy