Skip to content

Commit 13b78a2

Browse files
author
Michael Meskes
committed
- Fixed bug in a connect statement using varchars.
- Synced parser.
1 parent 1deb6e7 commit 13b78a2

File tree

4 files changed

+55
-29
lines changed

4 files changed

+55
-29
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,5 +1029,10 @@ Mon Dec 18 12:27:52 CET 2000
10291029
- Synced gram.y and preproc.y.
10301030
- Synced keyword.c.
10311031
- Added several small patches from Christof.
1032+
1033+
Fri Dec 22 13:33:31 CET 2000
1034+
1035+
- Fixed bug in a connect statement using varchars.
1036+
- Synced gram.y and preproc.y.
10321037
- Set ecpg version to 2.8.0.
10331038
- Set library version to 3.2.0.

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ make_name(void)
313313
%type <str> index_list func_index index_elem opt_class access_method_clause
314314
%type <str> index_opt_unique IndexStmt func_return ConstInterval
315315
%type <str> func_args_list func_args opt_with ProcedureStmt def_arg
316-
%type <str> def_elem def_list definition def_name def_type DefineStmt
316+
%type <str> def_elem def_list definition DefineStmt
317317
%type <str> opt_instead event event_object RuleActionList opt_using
318318
%type <str> RuleActionStmtOrEmpty RuleActionMulti func_as reindex_type
319319
%type <str> RuleStmt opt_column opt_name oper_argtypes sysid_clause
@@ -1335,7 +1335,7 @@ OptSeqElem: CACHE IntConst
13351335
*****************************************************************************/
13361336

13371337
CreatePLangStmt: CREATE PLangTrusted opt_procedural LANGUAGE StringConst
1338-
HANDLER def_name LANCOMPILER StringConst
1338+
HANDLER func_name LANCOMPILER StringConst
13391339
{
13401340
$$ = cat_str(9, make_str("create"), $2, $3, make_str("language"), $5, make_str("handler"), $7, make_str("langcompiler"), $9);
13411341
}
@@ -1482,41 +1482,34 @@ DropTrigStmt: DROP TRIGGER name ON relation_name
14821482
*
14831483
*****************************************************************************/
14841484

1485-
DefineStmt: CREATE def_type def_name definition
1486-
{
1487-
$$ = cat_str(3, make_str("create"), $2, $3, $4);
1488-
}
1489-
;
1490-
1491-
def_type: OPERATOR { $$ = make_str("operator"); }
1492-
| TYPE_P { $$ = make_str("type"); }
1493-
| AGGREGATE { $$ = make_str("aggregate"); }
1485+
DefineStmt: CREATE AGGREGATE func_name definition
1486+
{
1487+
$$ = cat_str(3, make_str("create aggregate"), $3, $4);
1488+
}
1489+
| CREATE OPERATOR all_Op definition
1490+
{
1491+
$$ = cat_str(3, make_str("create operator"), $3, $4);
1492+
}
1493+
| CREATE TYPE_P name definition
1494+
{
1495+
$$ = cat_str(3, make_str("create type"), $3, $4);
1496+
}
14941497
;
14951498

1496-
def_name: PROCEDURE { $$ = make_str("procedure"); }
1497-
| JOIN { $$ = make_str("join"); }
1498-
| all_Op { $$ = $1; }
1499-
| ColId { $$ = $1; }
1500-
;
1501-
15021499
definition: '(' def_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
15031500
;
15041501

15051502
def_list: def_elem { $$ = $1; }
15061503
| def_list ',' def_elem { $$ = cat_str(3, $1, make_str(","), $3); }
15071504
;
15081505

1509-
def_elem: def_name '=' def_arg {
1506+
def_elem: ColLabel '=' def_arg {
15101507
$$ = cat_str(3, $1, make_str("="), $3);
15111508
}
1512-
| def_name
1509+
| ColLabel
15131510
{
15141511
$$ = $1;
15151512
}
1516-
| DEFAULT '=' def_arg
1517-
{
1518-
$$ = cat2_str(make_str("default ="), $3);
1519-
}
15201513
;
15211514

15221515
def_arg: func_return { $$ = $1; }
@@ -1977,7 +1970,7 @@ RemoveFuncStmt: DROP FUNCTION func_name func_args
19771970
}
19781971
;
19791972

1980-
RemoveAggrStmt: DROP AGGREGATE name aggr_argtype
1973+
RemoveAggrStmt: DROP AGGREGATE func_name aggr_argtype
19811974
{
19821975
$$ = cat_str(3, make_str("drop aggregate"), $3, $4);
19831976
}
@@ -3964,8 +3957,20 @@ connection_target: database_name opt_server opt_port
39643957
{
39653958
if ($1[0] == '\"')
39663959
$$ = $1;
3967-
else if (strcmp($1, "?") == 0)
3968-
$$ = mm_strdup(argsinsert->variable->name);
3960+
else if (strcmp($1, "?") == 0) /* variable */
3961+
{
3962+
enum ECPGttype typ = argsinsert->variable->type->typ;
3963+
3964+
/* if array see what's inside */
3965+
if (typ == ECPGt_array)
3966+
typ = argsinsert->variable->type->u.element->typ;
3967+
3968+
/* handle varchars */
3969+
if (typ == ECPGt_varchar)
3970+
$$ = make2_str(mm_strdup(argsinsert->variable->name), make_str(".arr"));
3971+
else
3972+
$$ = mm_strdup(argsinsert->variable->name);
3973+
}
39693974
else
39703975
$$ = make3_str(make_str("\""), $1, make_str("\""));
39713976
}
@@ -4040,6 +4045,20 @@ user_name: UserId {
40404045
| StringConst {
40414046
if ($1[0] == '\"')
40424047
$$ = $1;
4048+
else if (strcmp($1, "?") == 0) /* variable */
4049+
{
4050+
enum ECPGttype typ = argsinsert->variable->type->typ;
4051+
4052+
/* if array see what's inside */
4053+
if (typ == ECPGt_array)
4054+
typ = argsinsert->variable->type->u.element->typ;
4055+
4056+
/* handle varchars */
4057+
if (typ == ECPGt_varchar)
4058+
$$ = make2_str(mm_strdup(argsinsert->variable->name), make_str(".arr"));
4059+
else
4060+
$$ = mm_strdup(argsinsert->variable->name);
4061+
}
40434062
else
40444063
$$ = make3_str(make_str("\""), $1, make_str("\""));
40454064
}
@@ -5033,6 +5052,7 @@ TokenId: ABSOLUTE { $$ = make_str("absolute"); }
50335052
| PRIOR { $$ = make_str("prior"); }
50345053
| PRIVILEGES { $$ = make_str("privileges"); }
50355054
| PROCEDURAL { $$ = make_str("procedural"); }
5055+
| PROCEDURE { $$ = make_str("procedure"); }
50365056
| READ { $$ = make_str("read"); }
50375057
| REINDEX { $$ = make_str("reindex"); }
50385058
| RELATIVE { $$ = make_str("relative"); }
@@ -5180,7 +5200,6 @@ ECPGColLabel: ECPGColId { $$ = $1; }
51805200
| POSITION { $$ = make_str("position"); }
51815201
| PRECISION { $$ = make_str("precision"); }
51825202
| PRIMARY { $$ = make_str("primary"); }
5183-
| PROCEDURE { $$ = make_str("procedure"); }
51845203
| PUBLIC { $$ = make_str("public"); }
51855204
| REFERENCES { $$ = make_str("references"); }
51865205
| RESET { $$ = make_str("reset"); }

src/interfaces/ecpg/test/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ test_init: test_init.c
2323
$(ECPG) $?
2424

2525
clean:
26-
rm -f test1 test2 test3 test4 perftest *.c log dyntest dyntest2 test_notice test_code100
26+
rm -f test1 test2 test3 test4 perftest *.c log dyntest dyntest2 test_notice test_code100 test_init

src/interfaces/ecpg/test/test4.pgc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ EXEC SQL BEGIN DECLARE SECTION;
1515
char *t = "uvwxyz1234";
1616
double f;
1717
bool b = true;
18+
varchar database[3];
1819
EXEC SQL END DECLARE SECTION;
1920
FILE *dbgs;
2021

@@ -23,7 +24,8 @@ EXEC SQL END DECLARE SECTION;
2324
if ((dbgs = fopen("log", "w")) != NULL)
2425
ECPGdebug(1, dbgs);
2526

26-
EXEC SQL CONNECT TO mm;
27+
strcpy(database.arr, "mm");
28+
EXEC SQL CONNECT TO :database;
2729

2830
EXEC SQL SET AUTOCOMMIT = ON;
2931

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