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:
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/parse.pl,v 1.8 2010/05/30 18:10:41 tgl Exp $
|
||||
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/parse.pl,v 1.9 2010/06/04 10:09:58 meskes Exp $
|
||||
# parser generater for ecpg
|
||||
# call with backend parser as stdin
|
||||
#
|
||||
@ -83,6 +83,7 @@ $replace_line{'VariableShowStmtSHOWvar_name'} = 'SHOW var_name ecpg_into';
|
||||
$replace_line{'VariableShowStmtSHOWTIMEZONE'} = 'SHOW TIME ZONE ecpg_into';
|
||||
$replace_line{'VariableShowStmtSHOWTRANSACTIONISOLATIONLEVEL'} = 'SHOW TRANSACTION ISOLATION LEVEL ecpg_into';
|
||||
$replace_line{'VariableShowStmtSHOWSESSIONAUTHORIZATION'} = 'SHOW SESSION AUTHORIZATION ecpg_into';
|
||||
$replace_line{'returning_clauseRETURNINGtarget_list'} = 'RETURNING target_list ecpg_into';
|
||||
$replace_line{'ExecuteStmtEXECUTEnameexecute_param_clause'} = 'EXECUTE prepared_name execute_param_clause execute_rest';
|
||||
$replace_line{'ExecuteStmtCREATEOptTempTABLEcreate_as_targetASEXECUTEnameexecute_param_clause'} = 'CREATE OptTemp TABLE create_as_target AS EXECUTE prepared_name execute_param_clause';
|
||||
$replace_line{'PrepareStmtPREPAREnameprep_type_clauseASPreparableStmt'} = 'PREPARE prepared_name prep_type_clause AS PreparableStmt';
|
||||
|
@ -27,7 +27,7 @@ int main() {
|
||||
|
||||
|
||||
#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;
|
||||
|
@ -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
|
||||
|
@ -1,3 +1,5 @@
|
||||
changes
|
||||
2 3 4 3
|
||||
test
|
||||
a b
|
||||
2 1
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user