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

Commit423abf4

Browse files
author
Michael Meskes
committed
- EXECUTE can return NOT FOUND so it should be checked here too.
- Changed regression test accordingly.
1 parenta3a648e commit423abf4

File tree

7 files changed

+110
-12
lines changed

7 files changed

+110
-12
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,4 +2310,6 @@ Wed, 06 Feb 2008 09:04:48 +0100
23102310
Thu, 14 Feb 2008 13:11:34 +0100
23112311

23122312
- Added SQLSTATE macro closing bug #3961.
2313+
- EXECUTE can return NOT FOUND so it should be checked here too.
2314+
- Changed regression test accordingly.
23132315

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.359 2008/01/15 10:31:47 meskes Exp $*/
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.360 2008/02/14 14:54:48 meskes Exp $*/
22

33
/* Copyright comment*/
44
%{
@@ -807,7 +807,7 @@ stmt: AlterDatabaseStmt{ output_statement($1, 0, ECPGst_normal); }
807807
|DropUserStmt{ output_statement($1,0, ECPGst_normal); }
808808
|DropdbStmt{ output_statement($1,0, ECPGst_normal); }
809809
|ExplainStmt{ output_statement($1,0, ECPGst_normal); }
810-
|ExecuteStmt{ output_statement($1,0, ECPGst_execute); }
810+
|ExecuteStmt{ output_statement($1,1, ECPGst_execute); }
811811
|FetchStmt{ output_statement($1,1, ECPGst_normal); }
812812
|GrantStmt{ output_statement($1,0, ECPGst_normal); }
813813
|GrantRoleStmt{ output_statement($1,0, ECPGst_normal); }

‎src/interfaces/ecpg/test/expected/sql-execute.c

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,23 +254,78 @@ if (sqlca.sqlcode < 0) sqlprint();}
254254
if (sqlca.sqlcode<0)sqlprint();}
255255
#line 88 "execute.pgc"
256256

257-
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"drop table test ",ECPGt_EOIT,ECPGt_EORT);
257+
{ECPGdeallocate(__LINE__,0,NULL,"f");
258258
#line 89 "execute.pgc"
259259

260260
if (sqlca.sqlcode<0)sqlprint();}
261261
#line 89 "execute.pgc"
262262

263+
264+
sprintf (command,"select * from test where amount = $1");
265+
266+
{ECPGprepare(__LINE__,NULL,0,"f",command);
267+
#line 93 "execute.pgc"
268+
269+
if (sqlca.sqlcode<0)sqlprint();}
270+
#line 93 "execute.pgc"
271+
272+
{ECPGdo(__LINE__,0,1,NULL,0,1,"f",
273+
ECPGt_const,"2",(long)1,(long)1,strlen("2"),
274+
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,
275+
ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
276+
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
277+
ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
278+
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
279+
ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
280+
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
281+
#line 94 "execute.pgc"
282+
283+
if (sqlca.sqlcode<0)sqlprint();}
284+
#line 94 "execute.pgc"
285+
286+
287+
for (i=0,j=sqlca.sqlerrd[2];i<j;i++)
288+
{
289+
/* exec sql begin declare section */
290+
291+
292+
293+
#line 99 "execute.pgc"
294+
charn [8 ] ,l=letter [i ] [0 ] ;
295+
296+
#line 100 "execute.pgc"
297+
inta=amount [i ] ;
298+
/* exec sql end declare section */
299+
#line 101 "execute.pgc"
300+
301+
302+
strncpy(n,name[i],8);
303+
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n",i,n,i,a,i,l);
304+
}
305+
306+
{ECPGdeallocate(__LINE__,0,NULL,"f");
307+
#line 107 "execute.pgc"
308+
309+
if (sqlca.sqlcode<0)sqlprint();}
310+
#line 107 "execute.pgc"
311+
312+
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"drop table test ",ECPGt_EOIT,ECPGt_EORT);
313+
#line 108 "execute.pgc"
314+
315+
if (sqlca.sqlcode<0)sqlprint();}
316+
#line 108 "execute.pgc"
317+
263318
{ECPGtrans(__LINE__,NULL,"commit");
264-
#line90 "execute.pgc"
319+
#line109 "execute.pgc"
265320

266321
if (sqlca.sqlcode<0)sqlprint();}
267-
#line90 "execute.pgc"
322+
#line109 "execute.pgc"
268323

269324
{ECPGdisconnect(__LINE__,"CURRENT");
270-
#line91 "execute.pgc"
325+
#line110 "execute.pgc"
271326

272327
if (sqlca.sqlcode<0)sqlprint();}
273-
#line91 "execute.pgc"
328+
#line110 "execute.pgc"
274329

275330

276331
return (0);

‎src/interfaces/ecpg/test/expected/sql-execute.stderr

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,33 @@
138138
[NO_PID]: sqlca: code: 0, state: 00000
139139
[NO_PID]: ecpg_execute line 88 Ok: CLOSE CURSOR
140140
[NO_PID]: sqlca: code: 0, state: 00000
141-
[NO_PID]:ecpg_execute line 89:QUERY: drop table test with 0 parameter on connection main
141+
[NO_PID]:ECPGdeallocate line 89:NAME: f
142142
[NO_PID]: sqlca: code: 0, state: 00000
143-
[NO_PID]:ecpg_execute line89: using PQexec
143+
[NO_PID]:ECPGprepare line93: NAME: f QUERY: select * from test where amount = $1
144144
[NO_PID]: sqlca: code: 0, state: 00000
145-
[NO_PID]: ecpg_execute line89 Ok: DROP TABLE
145+
[NO_PID]: ecpg_execute line94: QUERY: select * from test where amount = $1 with 1 parameter on connection main
146146
[NO_PID]: sqlca: code: 0, state: 00000
147-
[NO_PID]:ECPGtrans line90 action = commit connection = main
147+
[NO_PID]:ecpg_execute line94: using PQexecPrepared for select * from test where amount = $1
148148
[NO_PID]: sqlca: code: 0, state: 00000
149-
[NO_PID]: ECPGdeallocate line 0: NAME: f
149+
[NO_PID]: free_params line 94: parameter 1 = 2
150+
[NO_PID]: sqlca: code: 0, state: 00000
151+
[NO_PID]: ecpg_execute line 94: Correctly got 1 tuples with 3 fields
152+
[NO_PID]: sqlca: code: 0, state: 00000
153+
[NO_PID]: ecpg_get_data line 94: RESULT: db: 'r1' offset: -1 array: Yes
154+
[NO_PID]: sqlca: code: 0, state: 00000
155+
[NO_PID]: ecpg_get_data line 94: RESULT: 2 offset: -1 array: Yes
156+
[NO_PID]: sqlca: code: 0, state: 00000
157+
[NO_PID]: ecpg_get_data line 94: RESULT: t offset: -1 array: Yes
158+
[NO_PID]: sqlca: code: 0, state: 00000
159+
[NO_PID]: ECPGdeallocate line 107: NAME: f
160+
[NO_PID]: sqlca: code: 0, state: 00000
161+
[NO_PID]: ecpg_execute line 108: QUERY: drop table test with 0 parameter on connection main
162+
[NO_PID]: sqlca: code: 0, state: 00000
163+
[NO_PID]: ecpg_execute line 108: using PQexec
164+
[NO_PID]: sqlca: code: 0, state: 00000
165+
[NO_PID]: ecpg_execute line 108 Ok: DROP TABLE
166+
[NO_PID]: sqlca: code: 0, state: 00000
167+
[NO_PID]: ECPGtrans line 109 action = commit connection = main
150168
[NO_PID]: sqlca: code: 0, state: 00000
151169
[NO_PID]: ECPGdeallocate line 0: NAME: i
152170
[NO_PID]: sqlca: code: 0, state: 00000

‎src/interfaces/ecpg/test/expected/sql-execute.stdout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ name[5]=db: 'r1'amount[5]=102letter[5]=t
99
name[6]=db: 'r1'amount[6]=111letter[6]=f
1010
name[7]=db: 'r1'amount[7]=112letter[7]=t
1111
name[0]=db: 'r1'amount[0]=1letter[0]=f
12+
name[0]=db: 'r1'amount[0]=2letter[0]=t

‎src/interfaces/ecpg/test/expected/thread-prep.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ if (sqlca.sqlcode < 0) sqlprint();}
173173
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
174174
#line 52 "prep.pgc"
175175

176+
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
177+
#line 52 "prep.pgc"
178+
176179
if (sqlca.sqlcode<0)sqlprint();}
177180
#line 52 "prep.pgc"
178181

‎src/interfaces/ecpg/test/sql/execute.pgc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,25 @@ exec sql end declare section;
8686
}
8787

8888
exec sql close CUR2;
89+
exec sql deallocate f;
90+
91+
sprintf (command, "select * from test where amount = $1");
92+
93+
exec sql prepare f from :command;
94+
exec sql execute f using 2 into :name, :amount, :letter;
95+
96+
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
97+
{
98+
exec sql begin declare section;
99+
char n[8], l = letter[i][0];
100+
int a = amount[i];
101+
exec sql end declare section;
102+
103+
strncpy(n, name[i], 8);
104+
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
105+
}
106+
107+
exec sql deallocate f;
89108
exec sql drop table test;
90109
exec sql commit;
91110
exec sql disconnect;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp