1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +03:00

Added variable handling for RETURNING clause to ecpg.

While the values were correctly returned they were not moved into C variables
as they should be.

Closes: #5489
This commit is contained in:
Michael Meskes
2010-06-04 10:09:58 +00:00
parent dcd52a64bd
commit 98e4005efb
5 changed files with 32 additions and 15 deletions

View File

@ -24,10 +24,10 @@
int main() {
/* exec sql begin declare section */
#line 9 "insupd.pgc"
int i1 [ 3 ] , i2 [ 3 ] ;
int i1 [ 3 ] , i2 [ 3 ] , i3 [ 3 ] , i4 ;
/* exec sql end declare section */
#line 10 "insupd.pgc"
@ -72,7 +72,9 @@ if (sqlca.sqlwarn[0] == 'W') sqlprint();
if (sqlca.sqlcode < 0) sqlprint();}
#line 21 "insupd.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 3 , 3 )", ECPGt_EOIT, ECPGt_EORT);
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 3 , 3 ) returning a", ECPGt_EOIT,
ECPGt_int,&(i4),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 22 "insupd.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
@ -82,7 +84,9 @@ if (sqlca.sqlcode < 0) sqlprint();}
#line 22 "insupd.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set a = a + 1", ECPGt_EOIT, ECPGt_EORT);
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set a = a + 1 returning a", ECPGt_EOIT,
ECPGt_int,(i3),(long)1,(long)3,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 24 "insupd.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
@ -124,16 +128,17 @@ if (sqlca.sqlcode < 0) sqlprint();}
#line 28 "insupd.pgc"
printf("changes\n%d %d %d %d\n", i3[0], i3[1], i3[2], i4);
printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]);
{ ECPGdisconnect(__LINE__, "ALL");
#line 32 "insupd.pgc"
#line 33 "insupd.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 32 "insupd.pgc"
#line 33 "insupd.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 32 "insupd.pgc"
#line 33 "insupd.pgc"
return 0;

View File

@ -20,17 +20,25 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 21: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 22: query: insert into insupd_test ( a , b ) values ( 3 , 3 ); with 0 parameter(s) on connection regress1
[NO_PID]: ecpg_execute on line 22: query: insert into insupd_test ( a , b ) values ( 3 , 3 ) returning a; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 22: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 22: OK: INSERT 0 1
[NO_PID]: ecpg_execute on line 22: correctly got 1 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 24: query: update insupd_test set a = a + 1; with 0 parameter(s) on connection regress1
[NO_PID]: ecpg_get_data on line 22: RESULT: 3 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 24: query: update insupd_test set a = a + 1 returning a; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 24: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 24: OK: UPDATE 3
[NO_PID]: ecpg_execute on line 24: correctly got 3 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 24: RESULT: 2 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 24: RESULT: 3 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 24: RESULT: 4 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 25: query: update insupd_test set ( a , b ) = ( 5 , 5 ) where a = 4; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000

View File

@ -1,3 +1,5 @@
changes
2 3 4 3
test
a b
2 1

View File

@ -6,7 +6,7 @@ EXEC SQL INCLUDE ../regression;
int main() {
EXEC SQL BEGIN DECLARE SECTION;
int i1[3], i2[3];
int i1[3], i2[3], i3[3], i4;
EXEC SQL END DECLARE SECTION;
ECPGdebug(1, stderr);
@ -19,14 +19,15 @@ int main() {
EXEC SQL INSERT INTO insupd_test (a,b) values (1, 1);
EXEC SQL INSERT INTO insupd_test (a,b) values (2, 2);
EXEC SQL INSERT INTO insupd_test (a,b) values (3, 3);
EXEC SQL INSERT INTO insupd_test (a,b) values (3, 3) returning a into :i4;
EXEC SQL UPDATE insupd_test set a=a+1;
EXEC SQL UPDATE insupd_test set a=a+1 returning a into :i3;
EXEC SQL UPDATE insupd_test set (a,b)=(5,5) where a = 4;
EXEC SQL UPDATE insupd_test set a=4 where a=3;;
EXEC SQL SELECT a,b into :i1,:i2 from insupd_test order by a;
printf("changes\n%d %d %d %d\n", i3[0], i3[1], i3[2], i4);
printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]);
EXEC SQL DISCONNECT ALL;