#!/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
#
$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';
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"
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();
#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();
#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;
[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
+changes
+2 3 4 3
test
a b
2 1
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);
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;