- Changed regression test accordingly.
Thu, 14 Feb 2008 13:11:34 +0100
- Added SQLSTATE macro closing bug #3961.
+ - EXECUTE can return NOT FOUND so it should be checked here too.
+ - Changed regression test accordingly.
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.359 2008/01/15 10:31:47 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.360 2008/02/14 14:54:48 meskes Exp $ */
/* Copyright comment */
%{
| DropUserStmt { output_statement($1, 0, ECPGst_normal); }
| DropdbStmt { output_statement($1, 0, ECPGst_normal); }
| ExplainStmt { output_statement($1, 0, ECPGst_normal); }
- | ExecuteStmt { output_statement($1, 0, ECPGst_execute); }
+ | ExecuteStmt { output_statement($1, 1, ECPGst_execute); }
| FetchStmt { output_statement($1, 1, ECPGst_normal); }
| GrantStmt { output_statement($1, 0, ECPGst_normal); }
| GrantRoleStmt { output_statement($1, 0, ECPGst_normal); }
if (sqlca.sqlcode < 0) sqlprint();}
#line 88 "execute.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
+ { ECPGdeallocate(__LINE__, 0, NULL, "f");
#line 89 "execute.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 89 "execute.pgc"
+
+ sprintf (command, "select * from test where amount = $1");
+
+ { ECPGprepare(__LINE__, NULL, 0, "f", command);
+#line 93 "execute.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 93 "execute.pgc"
+
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "f",
+ ECPGt_const,"2",(long)1,(long)1,strlen("2"),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+ ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+ ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+ ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 94 "execute.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 94 "execute.pgc"
+
+
+ for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
+ {
+ /* exec sql begin declare section */
+
+
+
+#line 99 "execute.pgc"
+ char n [ 8 ] , l = letter [ i ] [ 0 ] ;
+
+#line 100 "execute.pgc"
+ int a = amount [ i ] ;
+/* exec sql end declare section */
+#line 101 "execute.pgc"
+
+
+ strncpy(n, name[i], 8);
+ printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
+ }
+
+ { ECPGdeallocate(__LINE__, 0, NULL, "f");
+#line 107 "execute.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 107 "execute.pgc"
+
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
+#line 108 "execute.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 108 "execute.pgc"
+
{ ECPGtrans(__LINE__, NULL, "commit");
-#line 90 "execute.pgc"
+#line 109 "execute.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 90 "execute.pgc"
+#line 109 "execute.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
-#line 91 "execute.pgc"
+#line 110 "execute.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 91 "execute.pgc"
+#line 110 "execute.pgc"
return (0);
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 88 Ok: CLOSE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute line 89: QUERY: drop table test with 0 parameter on connection main
+[NO_PID]: ECPGdeallocate line 89: NAME: f
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute line 89: using PQexec
+[NO_PID]: ECPGprepare line 93: NAME: f QUERY: select * from test where amount = $1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute line 89 Ok: DROP TABLE
+[NO_PID]: ecpg_execute line 94: QUERY: select * from test where amount = $1 with 1 parameter on connection main
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGtrans line 90 action = commit connection = main
+[NO_PID]: ecpg_execute line 94: using PQexecPrepared for select * from test where amount = $1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGdeallocate line 0: NAME: f
+[NO_PID]: free_params line 94: parameter 1 = 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute line 94: Correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data line 94: RESULT: db: 'r1' offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data line 94: RESULT: 2 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data line 94: RESULT: t offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeallocate line 107: NAME: f
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute line 108: QUERY: drop table test with 0 parameter on connection main
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute line 108: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute line 108 Ok: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans line 109 action = commit connection = main
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGdeallocate line 0: NAME: i
[NO_PID]: sqlca: code: 0, state: 00000
name[6]=db: 'r1' amount[6]=111 letter[6]=f
name[7]=db: 'r1' amount[7]=112 letter[7]=t
name[0]=db: 'r1' amount[0]=1 letter[0]=f
+name[0]=db: 'r1' amount[0]=2 letter[0]=t
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 52 "prep.pgc"
+if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
+#line 52 "prep.pgc"
+
if (sqlca.sqlcode < 0) sqlprint();}
#line 52 "prep.pgc"
}
exec sql close CUR2;
+ exec sql deallocate f;
+
+ sprintf (command, "select * from test where amount = $1");
+
+ exec sql prepare f from :command;
+ exec sql execute f using 2 into :name, :amount, :letter;
+
+ for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
+ {
+ exec sql begin declare section;
+ char n[8], l = letter[i][0];
+ int a = amount[i];
+ exec sql end declare section;
+
+ strncpy(n, name[i], 8);
+ printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
+ }
+
+ exec sql deallocate f;
exec sql drop table test;
exec sql commit;
exec sql disconnect;