mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Fixed parsing of parameters. Added regression test for this.
This commit is contained in:
@ -162,34 +162,72 @@ if (sqlca.sqlcode < 0) sqlprint();}
|
||||
|
||||
printf("%d: %s\n", i, str);
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);
|
||||
/* declare D cursor for select * from My_Table where Item1 = $1 */
|
||||
#line 42 "fetch.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare D cursor for select * from My_Table where Item1 = $1 ",
|
||||
ECPGt_const,"1",(long)1,(long)1,strlen("1"),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
|
||||
#line 44 "fetch.pgc"
|
||||
|
||||
if (sqlca.sqlwarn[0] == 'W') sqlprint();
|
||||
#line 42 "fetch.pgc"
|
||||
#line 44 "fetch.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 42 "fetch.pgc"
|
||||
#line 44 "fetch.pgc"
|
||||
|
||||
|
||||
/* exec sql whenever not found break ; */
|
||||
#line 46 "fetch.pgc"
|
||||
|
||||
while (1) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in D", ECPGt_EOIT,
|
||||
ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
|
||||
#line 48 "fetch.pgc"
|
||||
|
||||
if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
|
||||
#line 48 "fetch.pgc"
|
||||
|
||||
if (sqlca.sqlwarn[0] == 'W') sqlprint();
|
||||
#line 48 "fetch.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 48 "fetch.pgc"
|
||||
|
||||
printf("%d: %s\n", i, str);
|
||||
}
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close D", ECPGt_EOIT, ECPGt_EORT);
|
||||
#line 51 "fetch.pgc"
|
||||
|
||||
if (sqlca.sqlwarn[0] == 'W') sqlprint();
|
||||
#line 51 "fetch.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 51 "fetch.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table My_Table ", ECPGt_EOIT, ECPGt_EORT);
|
||||
#line 44 "fetch.pgc"
|
||||
#line 53 "fetch.pgc"
|
||||
|
||||
if (sqlca.sqlwarn[0] == 'W') sqlprint();
|
||||
#line 44 "fetch.pgc"
|
||||
#line 53 "fetch.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 44 "fetch.pgc"
|
||||
#line 53 "fetch.pgc"
|
||||
|
||||
|
||||
{ ECPGdisconnect(__LINE__, "ALL");
|
||||
#line 46 "fetch.pgc"
|
||||
#line 55 "fetch.pgc"
|
||||
|
||||
if (sqlca.sqlwarn[0] == 'W') sqlprint();
|
||||
#line 46 "fetch.pgc"
|
||||
#line 55 "fetch.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 46 "fetch.pgc"
|
||||
#line 55 "fetch.pgc"
|
||||
|
||||
|
||||
return 0;
|
||||
|
@ -102,17 +102,46 @@
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_get_data on line 39: RESULT: text4 offset: -1; array: yes
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 42: query: close C; with 0 parameter(s) on connection regress1
|
||||
[NO_PID]: ecpg_execute on line 44: query: declare D cursor for select * from My_Table where Item1 = $1 ; with 1 parameter(s) on connection regress1
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 42: using PQexec
|
||||
[NO_PID]: ecpg_execute on line 44: using PQexecParams
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 42: OK: CLOSE CURSOR
|
||||
[NO_PID]: free_params on line 44: parameter 1 = 1
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 44: query: drop table My_Table ; with 0 parameter(s) on connection regress1
|
||||
[NO_PID]: ecpg_execute on line 44: OK: DECLARE CURSOR
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 44: using PQexec
|
||||
[NO_PID]: ecpg_execute on line 48: query: fetch 1 in D; with 0 parameter(s) on connection regress1
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 44: OK: DROP TABLE
|
||||
[NO_PID]: ecpg_execute on line 48: using PQexec
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 48: correctly got 1 tuples with 2 fields
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_get_data on line 48: RESULT: 1 offset: -1; array: yes
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_get_data on line 48: RESULT: text1 offset: -1; array: yes
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 48: query: fetch 1 in D; with 0 parameter(s) on connection regress1
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 48: using PQexec
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 48: correctly got 0 tuples with 2 fields
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: raising sqlcode 100 on line 48: no data found on line 48
|
||||
[NO_PID]: sqlca: code: 100, state: 02000
|
||||
[NO_PID]: ecpg_execute on line 51: query: close D; with 0 parameter(s) on connection regress1
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 51: using PQexec
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 51: OK: CLOSE CURSOR
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 53: query: drop table My_Table ; with 0 parameter(s) on connection regress1
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_execute on line 53: using PQexec
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: ecpg_check_PQresult on line 53: ERROR: relation 16491 is still open
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
[NO_PID]: raising sqlstate XX000 (sqlcode -400) on line 53: relation 16491 is still open on line 53
|
||||
[NO_PID]: sqlca: code: -400, state: XX000
|
||||
sql error: relation 16491 is still open on line 53
|
||||
[NO_PID]: ecpg_finish: connection regress1 closed
|
||||
[NO_PID]: sqlca: code: 0, state: 00000
|
||||
|
@ -3,3 +3,4 @@
|
||||
3: text3
|
||||
4: text4
|
||||
4: text4
|
||||
1: text1
|
||||
|
@ -39,7 +39,16 @@ int main(int argc, char* argv[]) {
|
||||
EXEC SQL FETCH :count IN C INTO :i, :str;
|
||||
printf("%d: %s\n", i, str);
|
||||
|
||||
EXEC SQL CLOSE C;
|
||||
EXEC SQL DECLARE D CURSOR FOR SELECT * FROM My_Table WHERE Item1 = $1;
|
||||
|
||||
EXEC SQL OPEN D using 1;
|
||||
|
||||
EXEC SQL WHENEVER NOT FOUND DO BREAK;
|
||||
while (1) {
|
||||
EXEC SQL FETCH 1 IN D INTO :i, :str;
|
||||
printf("%d: %s\n", i, str);
|
||||
}
|
||||
EXEC SQL CLOSE D;
|
||||
|
||||
EXEC SQL DROP TABLE My_Table;
|
||||
|
||||
|
Reference in New Issue
Block a user