Skip to content

Commit 246bd83

Browse files
author
Michael Meskes
committed
Synced parser.
Added another regression test and fixed tcp test.
1 parent fc51c91 commit 246bd83

File tree

10 files changed

+305
-24
lines changed

10 files changed

+305
-24
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,5 +2131,10 @@ Tu 29. Aug 14:21:31 CEST 2006
21312131

21322132
- Fixed parser and library to allow empty database names.
21332133
- Streamlined connection name parsing.
2134+
2135+
Su 3. Sep 14:21:29 CEST 2006
2136+
2137+
- Synced parser.
2138+
- Added another regression test and fixed tcp test.
21342139
- Set ecpg library version to 5.2.
21352140
- Set ecpg version to 4.2.1.

src/interfaces/ecpg/preproc/keywords.c

Lines changed: 2 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.75 2006/08/18 15:59:35 meskes Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.76 2006/09/03 12:24:07 meskes Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -81,6 +81,7 @@ static ScanKeyword ScanKeywords[] = {
8181
{"comment", COMMENT},
8282
{"commit", COMMIT},
8383
{"committed", COMMITTED},
84+
{"concurrently", CONCURRENTLY},
8485
{"connection", CONNECTION},
8586
{"constraint", CONSTRAINT},
8687
{"constraints", CONSTRAINTS},

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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)
360360
CACHE CALLED CASCADE CASCADED CASE CAST CHAIN CHAR_P
361361
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
362362
CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT
363-
COMMITTED CONNECTION CONSTRAINT CONSTRAINTS CONVERSION_P CONVERT COPY CREATE CREATEDB
363+
COMMITTED CONCURRENTLY CONNECTION CONSTRAINT CONSTRAINTS CONVERSION_P CONVERT COPY CREATE CREATEDB
364364
CREATEROLE CREATEUSER CROSS CSV CURRENT_DATE CURRENT_ROLE CURRENT_TIME
365365
CURRENT_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-
13801374
CopyStmt: COPY opt_binary qualified_name opt_oids copy_from
13811375
copy_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

13941395
copy_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

23402345
IndexStmt: CREATE index_opt_unique INDEX index_name ON qualified_name
23412346
access_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

23452353
index_opt_unique: UNIQUE { $$ = make_str("unique"); }
@@ -3166,13 +3174,17 @@ opt_nowait: NOWAIT { $$ = make_str("nowait"); }
31663174
*****************************************************************************/
31673175

31683176
UpdateStmt: UPDATE relation_expr_opt_alias
3169-
SET update_target_list
3177+
SET set_opt
31703178
from_clause
31713179
where_clause
31723180
returning_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 ... */
43384379
update_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
{
43424384
struct inf_compat_col *ptrc;
@@ -4360,12 +4402,12 @@ update_target_list: update_target_list ',' update_target_el
43604402
vals = 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
{
43704412
struct 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

44064449
update_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"); }

src/interfaces/ecpg/test/expected/connect-test1.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ main(void)
5656
#line 27 "test1.pgc"
5757

5858

59-
{ ECPGconnect(__LINE__, 0, "@localhost" , NULL,NULL , "main", 0); }
59+
{ ECPGconnect(__LINE__, 0, "@localhost" , "connectdb" , NULL , "main", 0); }
6060
#line 29 "test1.pgc"
6161

6262
{ ECPGdisconnect(__LINE__, "main");}
@@ -70,7 +70,7 @@ main(void)
7070
#line 33 "test1.pgc"
7171

7272

73-
{ ECPGconnect(__LINE__, 0, "@localhost:55432" , NULL,NULL , "main", 0); }
73+
{ ECPGconnect(__LINE__, 0, "@localhost:55432" , "connectdb" , NULL , "main", 0); }
7474
#line 35 "test1.pgc"
7575

7676
{ ECPGdisconnect(__LINE__, "main");}
@@ -84,7 +84,7 @@ main(void)
8484
#line 39 "test1.pgc"
8585

8686

87-
{ ECPGconnect(__LINE__, 0, ":55432" , NULL,NULL , "main", 0); }
87+
{ ECPGconnect(__LINE__, 0, ":55432" , "connectdb" , NULL , "main", 0); }
8888
#line 41 "test1.pgc"
8989

9090
{ ECPGdisconnect(__LINE__, "main");}

src/interfaces/ecpg/test/expected/connect-test1.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ THE PORT NUMBER MIGHT HAVE BEEN CHANGED BY THE REGRESSION SCRIPT
1515
[NO_PID]: sqlca: code: 0, state: 00000
1616
[NO_PID]: ecpg_finish: Connection main closed.
1717
[NO_PID]: sqlca: code: 0, state: 00000
18-
[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT>
18+
[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT> for user connectdb
1919
[NO_PID]: sqlca: code: 0, state: 00000
2020
[NO_PID]: ecpg_finish: Connection main closed.
2121
[NO_PID]: sqlca: code: 0, state: 00000
2222
[NO_PID]: ECPGconnect: opening database connectdb on localhost port 55432
2323
[NO_PID]: sqlca: code: 0, state: 00000
2424
[NO_PID]: ecpg_finish: Connection main closed.
2525
[NO_PID]: sqlca: code: 0, state: 00000
26-
[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port 55432
26+
[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port 55432 for user connectdb
2727
[NO_PID]: sqlca: code: 0, state: 00000
2828
[NO_PID]: ecpg_finish: Connection main closed.
2929
[NO_PID]: sqlca: code: 0, state: 00000
3030
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port 55432
3131
[NO_PID]: sqlca: code: 0, state: 00000
3232
[NO_PID]: ecpg_finish: Connection main closed.
3333
[NO_PID]: sqlca: code: 0, state: 00000
34-
[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port 55432
34+
[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port 55432 for user connectdb
3535
[NO_PID]: sqlca: code: 0, state: 00000
3636
[NO_PID]: ecpg_finish: Connection main closed.
3737
[NO_PID]: sqlca: code: 0, state: 00000

0 commit comments

Comments
 (0)