Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3615a6a

Browse files
author
Michael Meskes
committed
Fixed handling of variables in connect rule.
1 parent38c8346 commit3615a6a

File tree

5 files changed

+48
-20
lines changed

5 files changed

+48
-20
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,5 +965,9 @@ Thu Oct 12 20:13:00 CEST 2000
965965

966966
- Changed parser to accept a variable instead of a constant wherever
967967
possible.
968+
969+
Mon Oct 16 21:33:17 CEST 2000
970+
971+
- Fixed handling of variables in connect rule.
968972
- Set ecpg version to 2.8.0.
969973
- Set library version to 3.2.0.

‎src/interfaces/ecpg/preproc/descriptor.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ drop_descriptor(char *name, char *connection)
113113
}
114114

115115
structdescriptor
116-
*
117-
lookup_descriptor(char*name,char*connection)
116+
*lookup_descriptor(char*name,char*connection)
118117
{
119118
structdescriptor*i;
120119

‎src/interfaces/ecpg/preproc/preproc.y

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,15 @@ stmt: AlterSchemaStmt { output_statement($1, 0, NULL, connection); }
465465
if (connection)
466466
mmerror(ET_ERROR,"no at option for connect statement.\n");
467467

468-
fprintf(yyout,"{ ECPGconnect(__LINE__, %s, %d);", $1, autocommit);
468+
fputs("{ ECPGconnect(__LINE__,", yyout);
469+
470+
if ($1[1] =='?')
471+
fprintf(yyout,"%s, %s, %d);", argsinsert->variable->name, $1 +sizeof("\"?\","), autocommit);
472+
else
473+
fprintf(yyout,"%s, %d);", $1, autocommit);
474+
475+
reset_variables();
476+
469477
whenever_action(2);
470478
free($1);
471479
}
@@ -3965,10 +3973,10 @@ connection_target: database_name opt_server opt_port
39653973
}
39663974
|StringConst
39673975
{
3968-
$$ = mm_strdup($1);
3969-
$$[0] ='\"';
3970-
$$[strlen($$) -1] ='\"';
3971-
free($1);
3976+
if($1[0] =='\"')
3977+
$$ =$1;
3978+
else
3979+
$$ = make3_str(make_str("\""),$1, make_str("\""));
39723980
}
39733981

39743982
db_prefix:identcvariable
@@ -4032,12 +4040,18 @@ ora_user: user_name
40324040
$$ = cat_str(3,$1, make_str(","),$3);
40334041
}
40344042

4035-
user_name:UserId {if ($1[0] =='\"')
4043+
user_name:UserId {
4044+
if ($1[0] =='\"')
4045+
$$ =$1;
4046+
else
4047+
$$ = make3_str(make_str("\""),$1, make_str("\""));
4048+
}
4049+
|StringConst {
4050+
if ($1[0] =='\"')
40364051
$$ =$1;
40374052
else
40384053
$$ = make3_str(make_str("\""),$1, make_str("\""));
40394054
}
4040-
|StringConst {$$ = make3_str(make_str("\""),$1, make_str("\"")); }
40414055

40424056
char_variable:cvariable
40434057
{/* check if we have a char variable*/

‎src/interfaces/ecpg/preproc/type.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, l
204204
void
205205
ECPGdump_a_type(FILE*o,constchar*name,structECPGtype*typ,constchar*ind_name,structECPGtype*ind_typ,constchar*prefix,constchar*ind_prefix)
206206
{
207-
if (ind_typ==NULL)
207+
/*if (ind_typ == NULL)
208208
{
209209
ind_typ = &ecpg_no_indicator;
210210
ind_name = "no_indicator";
211-
}
211+
}*/
212212

213213
switch (typ->typ)
214214
{
@@ -228,17 +228,20 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in
228228

229229
ECPGdump_a_simple(o,name,typ->u.element->typ,
230230
typ->u.element->size,typ->size,NULL,prefix);
231-
if (ind_typ->typ==ECPGt_NO_INDICATOR)
232-
ECPGdump_a_simple(o,ind_name,ind_typ->typ,ind_typ->size,-1,NULL,ind_prefix);
233-
else
231+
if (ind_typ!=NULL)
234232
{
235-
if (ind_typ->typ!=ECPGt_array)
233+
if (ind_typ->typ==ECPGt_NO_INDICATOR)
234+
ECPGdump_a_simple(o,ind_name,ind_typ->typ,ind_typ->size,-1,NULL,ind_prefix);
235+
else
236236
{
237-
fprintf(stderr,"Indicator for an array has to be array too.\n");
238-
exit(INDICATOR_NOT_ARRAY);
237+
if (ind_typ->typ!=ECPGt_array)
238+
{
239+
fprintf(stderr,"Indicator for an array has to be array too.\n");
240+
exit(INDICATOR_NOT_ARRAY);
241+
}
242+
ECPGdump_a_simple(o,ind_name,ind_typ->u.element->typ,
243+
ind_typ->u.element->size,ind_typ->size,NULL,prefix);
239244
}
240-
ECPGdump_a_simple(o,ind_name,ind_typ->u.element->typ,
241-
ind_typ->u.element->size,ind_typ->size,NULL,prefix);
242245
}
243246
}
244247
break;

‎src/interfaces/ecpg/test/dyntest.pgc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
44
*
5-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.6 2000/03/17 23:26:36 tgl Exp $
5+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Attic/dyntest.pgc,v 1.7 2000/10/16 19:53:04 meskes Exp $
66
*/
77

88
#include <stdio.h>
@@ -32,7 +32,11 @@ int main(int argc,char **argv)
3232
char DB[1024];
3333
exec sql end declare section;
3434
int done=0;
35+
FILE *dbgs;
3536

37+
if ((dbgs = fopen("log", "w")) != NULL)
38+
ECPGdebug(1, dbgs);
39+
3640
snprintf(QUERY,sizeof QUERY,"select * from %s",argc>1 && argv[1][0]?argv[1]:"pg_tables");
3741

3842
exec sql whenever sqlerror do error();
@@ -179,5 +183,9 @@ int main(int argc,char **argv)
179183
exec sql close MYCURS;
180184

181185
exec sql deallocate descriptor MYDESC;
186+
187+
if (dbgs != NULL)
188+
fclose(dbgs);
189+
182190
return 0;
183191
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp