From 466a4925f519a9b58580961acd42a1a463527071 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 4 Aug 2009 21:09:39 +0000 Subject: [PATCH] Fix an ecpg test, too. Are we there yet? --- .../ecpg/test/expected/sql-binary.c | 37 +++++--- .../ecpg/test/expected/sql-binary.stderr | 88 ++++++++++--------- src/interfaces/ecpg/test/sql/binary.pgc | 7 ++ 3 files changed, 77 insertions(+), 55 deletions(-) diff --git a/src/interfaces/ecpg/test/expected/sql-binary.c b/src/interfaces/ecpg/test/expected/sql-binary.c index 95b5ae2a64..00fd70224e 100644 --- a/src/interfaces/ecpg/test/expected/sql-binary.c +++ b/src/interfaces/ecpg/test/expected/sql-binary.c @@ -78,8 +78,17 @@ main (void) exit (sqlca.sqlcode); } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set bytea_output = escape", ECPGt_EOIT, ECPGt_EORT);} +#line 36 "binary.pgc" + + if (sqlca.sqlcode) + { + printf ("set bytea_output error = %ld\n", sqlca.sqlcode); + exit (sqlca.sqlcode); + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table empl ( idnum integer , name char ( 20 ) , accs smallint , byte bytea )", ECPGt_EOIT, ECPGt_EORT);} -#line 37 "binary.pgc" +#line 44 "binary.pgc" if (sqlca.sqlcode) { @@ -90,7 +99,7 @@ main (void) { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into empl values ( 1 , 'first user' , 320 , $1 )", ECPGt_char,&(data),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 44 "binary.pgc" +#line 51 "binary.pgc" if (sqlca.sqlcode) { @@ -99,12 +108,12 @@ main (void) } /* declare C cursor for select name , accs , byte from empl where idnum = $1 */ -#line 51 "binary.pgc" +#line 58 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 52 "binary.pgc" +#line 59 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), @@ -113,7 +122,7 @@ main (void) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 53 "binary.pgc" +#line 60 "binary.pgc" if (sqlca.sqlcode) { @@ -125,12 +134,12 @@ main (void) memset(empl.name, 0, 21L); /* declare B binary cursor for select name , accs , byte from empl where idnum = $1 */ -#line 63 "binary.pgc" +#line 70 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 64 "binary.pgc" +#line 71 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch B", ECPGt_EOIT, ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), @@ -139,7 +148,7 @@ main (void) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 65 "binary.pgc" +#line 72 "binary.pgc" if (sqlca.sqlcode) { @@ -148,7 +157,7 @@ main (void) } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close B", ECPGt_EOIT, ECPGt_EORT);} -#line 72 "binary.pgc" +#line 79 "binary.pgc" /* do not print a.accs because big/little endian will have different outputs here */ @@ -158,17 +167,17 @@ main (void) printf("\n"); /* declare A binary cursor for select byte from empl where idnum = $1 */ -#line 80 "binary.pgc" +#line 87 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 81 "binary.pgc" +#line 88 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch A", ECPGt_EOIT, ECPGt_char,&(pointer),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 82 "binary.pgc" +#line 89 "binary.pgc" if (sqlca.sqlcode) { @@ -177,7 +186,7 @@ main (void) } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close A", ECPGt_EOIT, ECPGt_EORT);} -#line 89 "binary.pgc" +#line 96 "binary.pgc" printf ("pointer="); @@ -187,7 +196,7 @@ main (void) free(pointer); { ECPGdisconnect(__LINE__, "CURRENT");} -#line 97 "binary.pgc" +#line 104 "binary.pgc" exit (0); } diff --git a/src/interfaces/ecpg/test/expected/sql-binary.stderr b/src/interfaces/ecpg/test/expected/sql-binary.stderr index 81f82afb76..c02229d9b3 100644 --- a/src/interfaces/ecpg/test/expected/sql-binary.stderr +++ b/src/interfaces/ecpg/test/expected/sql-binary.stderr @@ -2,89 +2,95 @@ [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ECPGconnect: opening database regress1 on port [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 36: query: create table empl ( idnum integer , name char ( 20 ) , accs smallint , byte bytea ); with 0 parameter(s) on connection regress1 +[NO_PID]: ecpg_execute on line 36: query: set bytea_output = escape; with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_execute on line 36: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 36: OK: CREATE TABLE +[NO_PID]: ecpg_execute on line 36: OK: SET [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 44: query: insert into empl values ( 1 , 'first user' , 320 , $1 ); with 1 parameter(s) on connection regress1 +[NO_PID]: ecpg_execute on line 43: query: create table empl ( idnum integer , name char ( 20 ) , accs smallint , byte bytea ); with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 44: using PQexecParams +[NO_PID]: ecpg_execute on line 43: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: free_params on line 44: parameter 1 = \001\155\000\212 +[NO_PID]: ecpg_execute on line 43: OK: CREATE TABLE [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 44: OK: INSERT 0 1 +[NO_PID]: ecpg_execute on line 51: query: insert into empl values ( 1 , 'first user' , 320 , $1 ); with 1 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 52: query: declare C cursor for select name , accs , byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1 +[NO_PID]: ecpg_execute on line 51: using PQexecParams [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 52: using PQexecParams +[NO_PID]: free_params on line 51: parameter 1 = \001\155\000\212 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: free_params on line 52: parameter 1 = 1 +[NO_PID]: ecpg_execute on line 51: OK: INSERT 0 1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 52: OK: DECLARE CURSOR +[NO_PID]: ecpg_execute on line 59: query: declare C cursor for select name , accs , byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 53: query: fetch C; with 0 parameter(s) on connection regress1 +[NO_PID]: ecpg_execute on line 59: using PQexecParams [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 53: using PQexec +[NO_PID]: free_params on line 59: parameter 1 = 1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 3 fields +[NO_PID]: ecpg_execute on line 59: OK: DECLARE CURSOR [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_get_data on line 53: RESULT: first user offset: -1; array: yes +[NO_PID]: ecpg_execute on line 60: query: fetch C; with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_get_data on line 53: RESULT: 320 offset: -1; array: yes +[NO_PID]: ecpg_execute on line 60: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_get_data on line 53: RESULT: \001m\000\212 offset: -1; array: yes +[NO_PID]: ecpg_execute on line 60: correctly got 1 tuples with 3 fields [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 64: query: declare B binary cursor for select name , accs , byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1 +[NO_PID]: ecpg_get_data on line 60: RESULT: first user offset: -1; array: yes [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 64: using PQexecParams +[NO_PID]: ecpg_get_data on line 60: RESULT: 320 offset: -1; array: yes [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: free_params on line 64: parameter 1 = 1 +[NO_PID]: ecpg_get_data on line 60: RESULT: \001m\000\212 offset: -1; array: yes [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 64: OK: DECLARE CURSOR +[NO_PID]: ecpg_execute on line 71: query: declare B binary cursor for select name , accs , byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 65: query: fetch B; with 0 parameter(s) on connection regress1 +[NO_PID]: ecpg_execute on line 71: using PQexecParams [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 65: using PQexec +[NO_PID]: free_params on line 71: parameter 1 = 1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 65: correctly got 1 tuples with 3 fields +[NO_PID]: ecpg_execute on line 71: OK: DECLARE CURSOR [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_get_data on line 65: RESULT: BINARY offset: -1; array: yes +[NO_PID]: ecpg_execute on line 72: query: fetch B; with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_get_data on line 65: RESULT: BINARY offset: -1; array: yes +[NO_PID]: ecpg_execute on line 72: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_get_data on line 65: RESULT: BINARY offset: -1; array: yes +[NO_PID]: ecpg_execute on line 72: correctly got 1 tuples with 3 fields [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 72: query: close B; with 0 parameter(s) on connection regress1 +[NO_PID]: ecpg_get_data on line 72: RESULT: BINARY offset: -1; array: yes [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 72: using PQexec +[NO_PID]: ecpg_get_data on line 72: RESULT: BINARY offset: -1; array: yes [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 72: OK: CLOSE CURSOR +[NO_PID]: ecpg_get_data on line 72: RESULT: BINARY offset: -1; array: yes [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 81: query: declare A binary cursor for select byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1 +[NO_PID]: ecpg_execute on line 79: query: close B; with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 81: using PQexecParams +[NO_PID]: ecpg_execute on line 79: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: free_params on line 81: parameter 1 = 1 +[NO_PID]: ecpg_execute on line 79: OK: CLOSE CURSOR [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 81: OK: DECLARE CURSOR +[NO_PID]: ecpg_execute on line 88: query: declare A binary cursor for select byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 82: query: fetch A; with 0 parameter(s) on connection regress1 +[NO_PID]: ecpg_execute on line 88: using PQexecParams [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 82: using PQexec +[NO_PID]: free_params on line 88: parameter 1 = 1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 82: correctly got 1 tuples with 1 fields +[NO_PID]: ecpg_execute on line 88: OK: DECLARE CURSOR [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_store_result on line 82: allocating memory for 1 tuples +[NO_PID]: ecpg_execute on line 89: query: fetch A; with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_get_data on line 82: RESULT: BINARY offset: -1; array: yes +[NO_PID]: ecpg_execute on line 89: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 89: query: close A; with 0 parameter(s) on connection regress1 +[NO_PID]: ecpg_execute on line 89: correctly got 1 tuples with 1 fields [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 89: using PQexec +[NO_PID]: ecpg_store_result on line 89: allocating memory for 1 tuples +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 89: RESULT: BINARY offset: -1; array: yes +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 96: query: close A; with 0 parameter(s) on connection regress1 +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 96: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 89: OK: CLOSE CURSOR +[NO_PID]: ecpg_execute on line 96: OK: CLOSE CURSOR [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_finish: connection regress1 closed [NO_PID]: sqlca: code: 0, state: 00000 diff --git a/src/interfaces/ecpg/test/sql/binary.pgc b/src/interfaces/ecpg/test/sql/binary.pgc index 3b2f4f68e8..723027d833 100644 --- a/src/interfaces/ecpg/test/sql/binary.pgc +++ b/src/interfaces/ecpg/test/sql/binary.pgc @@ -33,6 +33,13 @@ main (void) exit (sqlca.sqlcode); } + EXEC SQL set bytea_output = escape; + if (sqlca.sqlcode) + { + printf ("set bytea_output error = %ld\n", sqlca.sqlcode); + exit (sqlca.sqlcode); + } + EXEC SQL create table empl (idnum integer, name char (20), accs smallint, byte bytea); if (sqlca.sqlcode) -- 2.40.0