summaryrefslogtreecommitdiffstats
path: root/src/interfaces/ecpg/test/sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/ecpg/test/sql')
-rw-r--r--src/interfaces/ecpg/test/sql/Makefile3
-rw-r--r--src/interfaces/ecpg/test/sql/define.pgc25
-rw-r--r--src/interfaces/ecpg/test/sql/define_prelim.pgc6
-rw-r--r--src/interfaces/ecpg/test/sql/meson.build1
4 files changed, 35 insertions, 0 deletions
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'],
}