diff options
Diffstat (limited to 'src/interfaces/ecpg/test')
-rw-r--r-- | src/interfaces/ecpg/test/compat_informix/.gitignore | 2 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/compat_informix/Makefile | 3 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/compat_informix/intoasc.pgc | 21 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/compat_informix/meson.build | 1 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/ecpg_schedule | 1 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/expected/compat_informix-intoasc.c | 40 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/expected/compat_informix-intoasc.stderr | 0 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/expected/compat_informix-intoasc.stdout | 2 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/expected/sql-define.c | 65 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/expected/sql-define.stderr | 24 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/expected/sql-define.stdout | 3 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/meson.build | 3 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/sql/Makefile | 3 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/sql/define.pgc | 25 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/sql/define_prelim.pgc | 6 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/sql/meson.build | 1 |
16 files changed, 196 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/test/compat_informix/.gitignore b/src/interfaces/ecpg/test/compat_informix/.gitignore index f97706b..6967ae7 100644 --- a/src/interfaces/ecpg/test/compat_informix/.gitignore +++ b/src/interfaces/ecpg/test/compat_informix/.gitignore @@ -4,6 +4,8 @@ /dec_test.c /describe /describe.c +/intoasc +/intoasc.c /rfmtdate /rfmtdate.c /rfmtlong diff --git a/src/interfaces/ecpg/test/compat_informix/Makefile b/src/interfaces/ecpg/test/compat_informix/Makefile index d50fdc2..638b4e0 100644 --- a/src/interfaces/ecpg/test/compat_informix/Makefile +++ b/src/interfaces/ecpg/test/compat_informix/Makefile @@ -16,7 +16,8 @@ TESTS = test_informix test_informix.c \ rnull rnull.c \ sqlda sqlda.c \ describe describe.c \ - charfuncs charfuncs.c + charfuncs charfuncs.c \ + intoasc intoasc.c all: $(TESTS) diff --git a/src/interfaces/ecpg/test/compat_informix/intoasc.pgc b/src/interfaces/ecpg/test/compat_informix/intoasc.pgc new file mode 100644 index 0000000..d13c83b --- /dev/null +++ b/src/interfaces/ecpg/test/compat_informix/intoasc.pgc @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "pgtypes_interval.h" + +EXEC SQL BEGIN DECLARE SECTION; + char dirty_str[100] = "aaaaaaaaa_bbbbbbbb_ccccccccc_ddddddddd_"; + interval *interval_ptr; +EXEC SQL END DECLARE SECTION; + +int main() +{ + interval_ptr = (interval *) malloc(sizeof(interval)); + interval_ptr->time = 100000000; + interval_ptr->month = 240; + + printf("dirty_str contents before intoasc: %s\n", dirty_str); + intoasc(interval_ptr, dirty_str); + printf("dirty_str contents after intoasc: %s\n", dirty_str); + return 0; +} diff --git a/src/interfaces/ecpg/test/compat_informix/meson.build b/src/interfaces/ecpg/test/compat_informix/meson.build index e2f8802..7e47909 100644 --- a/src/interfaces/ecpg/test/compat_informix/meson.build +++ b/src/interfaces/ecpg/test/compat_informix/meson.build @@ -4,6 +4,7 @@ pgc_files = [ 'charfuncs', 'dec_test', 'describe', + 'intoasc', 'rfmtdate', 'rfmtlong', 'rnull', diff --git a/src/interfaces/ecpg/test/ecpg_schedule b/src/interfaces/ecpg/test/ecpg_schedule index 39814a3..f9c0a0e 100644 --- a/src/interfaces/ecpg/test/ecpg_schedule +++ b/src/interfaces/ecpg/test/ecpg_schedule @@ -7,6 +7,7 @@ test: compat_informix/sqlda test: compat_informix/describe test: compat_informix/test_informix test: compat_informix/test_informix2 +test: compat_informix/intoasc test: compat_oracle/char_array test: connect/test2 test: connect/test3 diff --git a/src/interfaces/ecpg/test/expected/compat_informix-intoasc.c b/src/interfaces/ecpg/test/expected/compat_informix-intoasc.c new file mode 100644 index 0000000..3098880 --- /dev/null +++ b/src/interfaces/ecpg/test/expected/compat_informix-intoasc.c @@ -0,0 +1,40 @@ +/* Processed by ecpg (regression mode) */ +/* These include files are added by the preprocessor */ +#include <ecpglib.h> +#include <ecpgerrno.h> +#include <sqlca.h> +/* Needed for informix compatibility */ +#include <ecpg_informix.h> +/* End of automatic include section */ +#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) + +#line 1 "intoasc.pgc" +#include <stdio.h> +#include <stdlib.h> + +#include "pgtypes_interval.h" + +/* exec sql begin declare section */ + + + +#line 7 "intoasc.pgc" + char dirty_str [ 100 ] = "aaaaaaaaa_bbbbbbbb_ccccccccc_ddddddddd_" ; + +#line 8 "intoasc.pgc" + interval * interval_ptr ; +/* exec sql end declare section */ +#line 9 "intoasc.pgc" + + +int main() +{ + interval_ptr = (interval *) malloc(sizeof(interval)); + interval_ptr->time = 100000000; + interval_ptr->month = 240; + + printf("dirty_str contents before intoasc: %s\n", dirty_str); + intoasc(interval_ptr, dirty_str); + printf("dirty_str contents after intoasc: %s\n", dirty_str); + return 0; +} diff --git a/src/interfaces/ecpg/test/expected/compat_informix-intoasc.stderr b/src/interfaces/ecpg/test/expected/compat_informix-intoasc.stderr new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/interfaces/ecpg/test/expected/compat_informix-intoasc.stderr diff --git a/src/interfaces/ecpg/test/expected/compat_informix-intoasc.stdout b/src/interfaces/ecpg/test/expected/compat_informix-intoasc.stdout new file mode 100644 index 0000000..0769465 --- /dev/null +++ b/src/interfaces/ecpg/test/expected/compat_informix-intoasc.stdout @@ -0,0 +1,2 @@ +dirty_str contents before intoasc: aaaaaaaaa_bbbbbbbb_ccccccccc_ddddddddd_ +dirty_str contents after intoasc: @ 20 years 1 min 40 secs diff --git a/src/interfaces/ecpg/test/expected/sql-define.c b/src/interfaces/ecpg/test/expected/sql-define.c index 29583ec..e97caec 100644 --- a/src/interfaces/ecpg/test/expected/sql-define.c +++ b/src/interfaces/ecpg/test/expected/sql-define.c @@ -6,6 +6,21 @@ /* End of automatic include section */ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) +#line 1 "define_prelim.pgc" +/* + * Test that the effects of these commands don't carry over to the next + * file named on the ecpg command line. + */ + + +/* Processed by ecpg (regression mode) */ +/* These include files are added by the preprocessor */ +#include <ecpglib.h> +#include <ecpgerrno.h> +#include <sqlca.h> +/* End of automatic include section */ +#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) + #line 1 "define.pgc" #line 1 "sqlca.h" @@ -195,11 +210,57 @@ if (sqlca.sqlcode < 0) sqlprint ( );} + /* test handling of a macro defined on the command line */ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 123", ECPGt_EOIT, + ECPGt_int,&(i),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 57 "define.pgc" + +if (sqlca.sqlcode < 0) sqlprint ( );} +#line 57 "define.pgc" + + printf("original CMDLINESYM: %d\n", i); + + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 42", ECPGt_EOIT, + ECPGt_int,&(i),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 62 "define.pgc" + +if (sqlca.sqlcode < 0) sqlprint ( );} +#line 62 "define.pgc" + + printf("redefined CMDLINESYM: %d\n", i); + + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 43", ECPGt_EOIT, + ECPGt_int,&(i),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 67 "define.pgc" + +if (sqlca.sqlcode < 0) sqlprint ( );} +#line 67 "define.pgc" + + printf("redefined CMDLINESYM: %d\n", i); + + + + + + + + /* this macro should not have carried over from define_prelim.pgc */ + + + + { ECPGdisconnect(__LINE__, "CURRENT"); -#line 56 "define.pgc" +#line 81 "define.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} -#line 56 "define.pgc" +#line 81 "define.pgc" return 0; } diff --git a/src/interfaces/ecpg/test/expected/sql-define.stderr b/src/interfaces/ecpg/test/expected/sql-define.stderr index 20601b6..c4da992 100644 --- a/src/interfaces/ecpg/test/expected/sql-define.stderr +++ b/src/interfaces/ecpg/test/expected/sql-define.stderr @@ -48,5 +48,29 @@ [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_process_output on line 53: OK: SET [NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 57: query: select 123; with 0 parameter(s) on connection ecpg1_regression +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 57: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 57: correctly got 1 tuples with 1 fields +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 57: RESULT: 123 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 62: query: select 42; with 0 parameter(s) on connection ecpg1_regression +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 62: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 62: correctly got 1 tuples with 1 fields +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 62: RESULT: 42 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 67: query: select 43; with 0 parameter(s) on connection ecpg1_regression +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_execute on line 67: using PQexec +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_process_output on line 67: correctly got 1 tuples with 1 fields +[NO_PID]: sqlca: code: 0, state: 00000 +[NO_PID]: ecpg_get_data on line 67: RESULT: 43 offset: -1; array: no +[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_finish: connection ecpg1_regression closed [NO_PID]: sqlca: code: 0, state: 00000 diff --git a/src/interfaces/ecpg/test/expected/sql-define.stdout b/src/interfaces/ecpg/test/expected/sql-define.stdout index 864cd85..eaddc7f 100644 --- a/src/interfaces/ecpg/test/expected/sql-define.stdout +++ b/src/interfaces/ecpg/test/expected/sql-define.stdout @@ -1 +1,4 @@ i: 1, s: 29-abcdef +original CMDLINESYM: 123 +redefined CMDLINESYM: 42 +redefined CMDLINESYM: 43 diff --git a/src/interfaces/ecpg/test/meson.build b/src/interfaces/ecpg/test/meson.build index 04c6819..8fc352b 100644 --- a/src/interfaces/ecpg/test/meson.build +++ b/src/interfaces/ecpg/test/meson.build @@ -45,9 +45,10 @@ ecpg_preproc_test_command_start = [ '--regression', '-I@CURRENT_SOURCE_DIR@', '-I@SOURCE_ROOT@' + '/src/interfaces/ecpg/include/', + '-o', '@OUTPUT@', ] ecpg_preproc_test_command_end = [ - '-o', '@OUTPUT@', '@INPUT@' + '@INPUT@' ] ecpg_test_dependencies = [] diff --git a/src/interfaces/ecpg/test/sql/Makefile b/src/interfaces/ecpg/test/sql/Makefile index d8213b2..6032762 100644 --- a/src/interfaces/ecpg/test/sql/Makefile +++ b/src/interfaces/ecpg/test/sql/Makefile @@ -33,5 +33,8 @@ TESTS = array array.c \ all: $(TESTS) +define.c: define.pgc define_prelim.pgc $(ECPG_TEST_DEPENDENCIES) + $(ECPG) -DCMDLINESYM=123 -o $@ $(srcdir)/define_prelim.pgc $< + oldexec.c: oldexec.pgc $(ECPG_TEST_DEPENDENCIES) $(ECPG) -r questionmarks -o $@ $< diff --git a/src/interfaces/ecpg/test/sql/define.pgc b/src/interfaces/ecpg/test/sql/define.pgc index ed58a4b..83f328d 100644 --- a/src/interfaces/ecpg/test/sql/define.pgc +++ b/src/interfaces/ecpg/test/sql/define.pgc @@ -53,6 +53,31 @@ int main(void) exec sql SET TIMEZONE TO TZVAR; exec sql endif; + /* test handling of a macro defined on the command line */ + exec sql select CMDLINESYM INTO :i; + printf("original CMDLINESYM: %d\n", i); + + exec sql define CMDLINESYM 42; + + exec sql select CMDLINESYM INTO :i; + printf("redefined CMDLINESYM: %d\n", i); + + exec sql define CMDLINESYM 43; + + exec sql select CMDLINESYM INTO :i; + printf("redefined CMDLINESYM: %d\n", i); + + exec sql undef CMDLINESYM; + + exec sql ifdef CMDLINESYM; + exec sql insert into test values (NUMBER, 'no string'); + exec sql endif; + + /* this macro should not have carried over from define_prelim.pgc */ + exec sql ifdef NONCMDLINESYM; + exec sql insert into test values (NUMBER, 'no string'); + exec sql endif; + exec sql disconnect; return 0; } diff --git a/src/interfaces/ecpg/test/sql/define_prelim.pgc b/src/interfaces/ecpg/test/sql/define_prelim.pgc new file mode 100644 index 0000000..7a984f7 --- /dev/null +++ b/src/interfaces/ecpg/test/sql/define_prelim.pgc @@ -0,0 +1,6 @@ +/* + * Test that the effects of these commands don't carry over to the next + * file named on the ecpg command line. + */ +exec sql define CMDLINESYM 999; +exec sql define NONCMDLINESYM 1234; diff --git a/src/interfaces/ecpg/test/sql/meson.build b/src/interfaces/ecpg/test/sql/meson.build index f4c9418..e2a5ca2 100644 --- a/src/interfaces/ecpg/test/sql/meson.build +++ b/src/interfaces/ecpg/test/sql/meson.build @@ -30,6 +30,7 @@ pgc_files = [ ] pgc_extra_flags = { + 'define': ['-DCMDLINESYM=123', files('define_prelim.pgc')], 'oldexec': ['-r', 'questionmarks'], } |