diff options
Diffstat (limited to '')
-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 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/test/sql/Makefile b/src/interfaces/ecpg/test/sql/Makefile index 876ca8d..5d35e15 100644 --- a/src/interfaces/ecpg/test/sql/Makefile +++ b/src/interfaces/ecpg/test/sql/Makefile @@ -32,5 +32,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; |