From 635a0b9a8640bb7f2944a3f77ddc370f8dd7b010 Mon Sep 17 00:00:00 2001 From: Michael Meskes Date: Tue, 14 Aug 2007 10:01:54 +0000 Subject: - Finished major rewrite to use new protocol version - Really prepare statements - Added more regression tests - Added auto-prepare mode - Use '$n' for positional variables, '?' is still possible via ecpg option - Cleaned up the sources a little bit --- src/interfaces/ecpg/test/expected/sql-execute.c | 90 ++++++++++++------------- 1 file changed, 44 insertions(+), 46 deletions(-) (limited to 'src/interfaces/ecpg/test/expected/sql-execute.c') diff --git a/src/interfaces/ecpg/test/expected/sql-execute.c b/src/interfaces/ecpg/test/expected/sql-execute.c index 4e0c78e33c2..cc66dd50c67 100644 --- a/src/interfaces/ecpg/test/expected/sql-execute.c +++ b/src/interfaces/ecpg/test/expected/sql-execute.c @@ -65,7 +65,7 @@ main(void) if (sqlca.sqlcode < 0) sqlprint();} #line 24 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ) ", ECPGt_EOIT, ECPGt_EORT); + { ECPGdo(__LINE__, 0, 1, NULL, 0, 0, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ) ", ECPGt_EOIT, ECPGt_EORT); #line 25 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} @@ -79,9 +79,7 @@ if (sqlca.sqlcode < 0) sqlprint();} sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')"); - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(command),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { ECPGdo(__LINE__, 0, 1, NULL, 0, 2, command, ECPGt_EOIT, ECPGt_EORT); #line 29 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} @@ -89,9 +87,7 @@ if (sqlca.sqlcode < 0) sqlprint();} sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')"); - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(command),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { ECPGdo(__LINE__, 0, 1, NULL, 0, 2, command, ECPGt_EOIT, ECPGt_EORT); #line 32 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} @@ -99,9 +95,7 @@ if (sqlca.sqlcode < 0) sqlprint();} sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test"); - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(command),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { ECPGdo(__LINE__, 0, 1, NULL, 0, 2, command, ECPGt_EOIT, ECPGt_EORT); #line 35 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} @@ -110,16 +104,14 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]); - sprintf(command, "insert into test (name, amount, letter) select name, amount+?, letter from test"); - { ECPGprepare(__LINE__, "I" , command); + sprintf(command, "insert into test (name, amount, letter) select name, amount+$1, letter from test"); + { ECPGprepare(__LINE__, NULL, 0, "i", command); #line 40 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 40 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(ECPGprepared_statement("I")),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "i", ECPGt_int,&(increment),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 41 "execute.pgc" @@ -139,25 +131,25 @@ if (sqlca.sqlcode < 0) sqlprint();} sprintf (command, "select * from test"); - { ECPGprepare(__LINE__, "F" , command); + { ECPGprepare(__LINE__, NULL, 0, "f", command); #line 49 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 49 "execute.pgc" - /* declare CUR cursor for ? */ + /* declare CUR cursor for $1 */ #line 50 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "declare CUR cursor for ?", - ECPGt_char_variable,(ECPGprepared_statement("F")),(long)1,(long)1,(1)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, 0, "declare CUR cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement("f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 52 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 52 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "fetch 8 in CUR", ECPGt_EOIT, + { ECPGdo(__LINE__, 0, 1, NULL, 0, 0, "fetch 8 in CUR", 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), @@ -189,46 +181,52 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } - { ECPGdo(__LINE__, 0, 1, NULL, "close CUR", ECPGt_EOIT, ECPGt_EORT); + { ECPGdo(__LINE__, 0, 1, NULL, 0, 0, "close CUR", ECPGt_EOIT, ECPGt_EORT); #line 66 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 66 "execute.pgc" + { ECPGdeallocate(__LINE__, 0, "f"); +#line 67 "execute.pgc" - sprintf (command, "select * from test where amount = ?"); +if (sqlca.sqlcode < 0) sqlprint();} +#line 67 "execute.pgc" - { ECPGprepare(__LINE__, "F" , command); -#line 70 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} -#line 70 "execute.pgc" + sprintf (command, "select * from test where amount = $1"); + + { ECPGprepare(__LINE__, NULL, 0, "f", command); +#line 71 "execute.pgc" - /* declare CUR2 cursor for ? */ +if (sqlca.sqlcode < 0) sqlprint();} #line 71 "execute.pgc" + /* declare CUR2 cursor for $1 */ +#line 72 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "declare CUR2 cursor for ?", - ECPGt_char_variable,(ECPGprepared_statement("F")),(long)1,(long)1,(1)*sizeof(char), + + { ECPGdo(__LINE__, 0, 1, NULL, 0, 0, "declare CUR2 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement("f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_const,"1",(long)1,(long)1,strlen("1"), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); -#line 73 "execute.pgc" +#line 74 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 73 "execute.pgc" +#line 74 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "fetch in CUR2", ECPGt_EOIT, + { ECPGdo(__LINE__, 0, 1, NULL, 0, 0, "fetch in CUR2", 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 74 "execute.pgc" +#line 75 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} -#line 74 "execute.pgc" +#line 75 "execute.pgc" for (i=0, j=sqlca.sqlerrd[2]; i