Commit 3615a6a8 authored by Michael Meskes's avatar Michael Meskes

Fixed handling of variables in connect rule.

parent 38c83465
...@@ -965,5 +965,9 @@ Thu Oct 12 20:13:00 CEST 2000 ...@@ -965,5 +965,9 @@ Thu Oct 12 20:13:00 CEST 2000
- Changed parser to accept a variable instead of a constant wherever - Changed parser to accept a variable instead of a constant wherever
possible. possible.
Mon Oct 16 21:33:17 CEST 2000
- Fixed handling of variables in connect rule.
- Set ecpg version to 2.8.0. - Set ecpg version to 2.8.0.
- Set library version to 3.2.0. - Set library version to 3.2.0.
...@@ -113,8 +113,7 @@ drop_descriptor(char *name, char *connection) ...@@ -113,8 +113,7 @@ drop_descriptor(char *name, char *connection)
} }
struct descriptor struct descriptor
* *lookup_descriptor(char *name, char *connection)
lookup_descriptor(char *name, char *connection)
{ {
struct descriptor *i; struct descriptor *i;
......
...@@ -465,7 +465,15 @@ stmt: AlterSchemaStmt { output_statement($1, 0, NULL, connection); } ...@@ -465,7 +465,15 @@ stmt: AlterSchemaStmt { output_statement($1, 0, NULL, connection); }
if (connection) if (connection)
mmerror(ET_ERROR, "no at option for connect statement.\n"); mmerror(ET_ERROR, "no at option for connect statement.\n");
fprintf(yyout, "{ ECPGconnect(__LINE__, %s, %d);", $1, autocommit); fputs("{ ECPGconnect(__LINE__,", yyout);
if ($1[1] == '?')
fprintf(yyout, "%s, %s, %d);", argsinsert->variable->name, $1 + sizeof("\"?\","), autocommit);
else
fprintf(yyout, "%s, %d); ", $1, autocommit);
reset_variables();
whenever_action(2); whenever_action(2);
free($1); free($1);
} }
...@@ -3965,10 +3973,10 @@ connection_target: database_name opt_server opt_port ...@@ -3965,10 +3973,10 @@ connection_target: database_name opt_server opt_port
} }
| StringConst | StringConst
{ {
$$ = mm_strdup($1); if ($1[0] == '\"')
$$[0] = '\"'; $$ = $1;
$$[strlen($$) - 1] = '\"'; else
free($1); $$ = make3_str(make_str("\""), $1, make_str("\""));
} }
db_prefix: ident cvariable db_prefix: ident cvariable
...@@ -4032,12 +4040,18 @@ ora_user: user_name ...@@ -4032,12 +4040,18 @@ ora_user: user_name
$$ = cat_str(3, $1, make_str(","), $3); $$ = cat_str(3, $1, make_str(","), $3);
} }
user_name: UserId { if ($1[0] == '\"') user_name: UserId {
if ($1[0] == '\"')
$$ = $1;
else
$$ = make3_str(make_str("\""), $1, make_str("\""));
}
| StringConst {
if ($1[0] == '\"')
$$ = $1; $$ = $1;
else else
$$ = make3_str(make_str("\""), $1, make_str("\"")); $$ = make3_str(make_str("\""), $1, make_str("\""));
} }
| StringConst { $$ = make3_str(make_str("\""), $1, make_str("\"")); }
char_variable: cvariable char_variable: cvariable
{ /* check if we have a char variable */ { /* check if we have a char variable */
......
...@@ -204,11 +204,11 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, l ...@@ -204,11 +204,11 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, l
void void
ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *ind_name, struct ECPGtype * ind_typ, const char *prefix, const char *ind_prefix) ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *ind_name, struct ECPGtype * ind_typ, const char *prefix, const char *ind_prefix)
{ {
if (ind_typ == NULL) /* if (ind_typ == NULL)
{ {
ind_typ = &ecpg_no_indicator; ind_typ = &ecpg_no_indicator;
ind_name = "no_indicator"; ind_name = "no_indicator";
} }*/
switch (typ->typ) switch (typ->typ)
{ {
...@@ -228,6 +228,8 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in ...@@ -228,6 +228,8 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in
ECPGdump_a_simple(o, name, typ->u.element->typ, ECPGdump_a_simple(o, name, typ->u.element->typ,
typ->u.element->size, typ->size, NULL, prefix); typ->u.element->size, typ->size, NULL, prefix);
if (ind_typ != NULL)
{
if (ind_typ->typ == ECPGt_NO_INDICATOR) if (ind_typ->typ == ECPGt_NO_INDICATOR)
ECPGdump_a_simple(o, ind_name, ind_typ->typ, ind_typ->size, -1, NULL, ind_prefix); ECPGdump_a_simple(o, ind_name, ind_typ->typ, ind_typ->size, -1, NULL, ind_prefix);
else else
...@@ -241,6 +243,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in ...@@ -241,6 +243,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in
ind_typ->u.element->size, ind_typ->size, NULL, prefix); ind_typ->u.element->size, ind_typ->size, NULL, prefix);
} }
} }
}
break; break;
case ECPGt_struct: case ECPGt_struct:
ECPGdump_a_struct(o, name, ind_name, 1, typ, ind_typ, NULL, prefix, ind_prefix); ECPGdump_a_struct(o, name, ind_name, 1, typ, ind_typ, NULL, prefix, ind_prefix);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* *
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de> * Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
* *
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.6 2000/03/17 23:26:36 tgl Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.7 2000/10/16 19:53:04 meskes Exp $
*/ */
#include <stdio.h> #include <stdio.h>
...@@ -32,6 +32,10 @@ int main(int argc,char **argv) ...@@ -32,6 +32,10 @@ int main(int argc,char **argv)
char DB[1024]; char DB[1024];
exec sql end declare section; exec sql end declare section;
int done=0; int done=0;
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
snprintf(QUERY,sizeof QUERY,"select * from %s",argc>1 && argv[1][0]?argv[1]:"pg_tables"); snprintf(QUERY,sizeof QUERY,"select * from %s",argc>1 && argv[1][0]?argv[1]:"pg_tables");
...@@ -179,5 +183,9 @@ int main(int argc,char **argv) ...@@ -179,5 +183,9 @@ int main(int argc,char **argv)
exec sql close MYCURS; exec sql close MYCURS;
exec sql deallocate descriptor MYDESC; exec sql deallocate descriptor MYDESC;
if (dbgs != NULL)
fclose(dbgs);
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment