summaryrefslogtreecommitdiffstats
path: root/src/interfaces/ecpg/test/preproc/init.pgc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:46:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:46:48 +0000
commit311bcfc6b3acdd6fd152798c7f287ddf74fa2a98 (patch)
tree0ec307299b1dada3701e42f4ca6eda57d708261e /src/interfaces/ecpg/test/preproc/init.pgc
parentInitial commit. (diff)
downloadpostgresql-15-311bcfc6b3acdd6fd152798c7f287ddf74fa2a98.tar.xz
postgresql-15-311bcfc6b3acdd6fd152798c7f287ddf74fa2a98.zip
Adding upstream version 15.4.upstream/15.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/interfaces/ecpg/test/preproc/init.pgc')
-rw-r--r--src/interfaces/ecpg/test/preproc/init.pgc100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/test/preproc/init.pgc b/src/interfaces/ecpg/test/preproc/init.pgc
new file mode 100644
index 0000000..b1f7199
--- /dev/null
+++ b/src/interfaces/ecpg/test/preproc/init.pgc
@@ -0,0 +1,100 @@
+exec sql include sqlca;
+
+enum e { ENUM0, ENUM1 };
+struct sa { int member; };
+
+static int fa(void)
+{
+ printf("in fa\n");
+ return 2;
+}
+
+static int
+fb(int x)
+{
+ printf("in fb (%d)\n", x);
+ return x;
+}
+
+static int
+fc(const char *x)
+{
+ printf("in fc (%s)\n", x);
+ return *x;
+}
+
+static int fd(const char *x,int i)
+{
+ printf("in fd (%s, %d)\n", x, i);
+ return (*x)*i;
+}
+
+static int fe(enum e x)
+{
+ printf("in fe (%d)\n", (int) x);
+ return (int)x;
+}
+
+static void sqlnotice(const char *notice, short trans)
+{
+ if (!notice)
+ notice = "-empty-";
+ printf("in sqlnotice (%s, %d)\n", notice, trans);
+}
+
+exec sql define NONO 0;
+
+#define YES 1
+
+#ifdef _cplusplus
+namespace N
+{
+ static const int i=2;
+};
+#endif
+
+int main(void)
+{
+ struct sa x = { 14 },*y = &x;
+ exec sql begin declare section;
+ int a=(int)2;
+ int b=2+2;
+ int b2=(14*7);
+ int d=x.member;
+ int g=fb(2);
+ int i=3^1;
+ int j=1?1:2;
+
+ int e=y->member;
+ int c=10>>2;
+ bool h=2||1;
+ long iay /* = 1L */ ;
+ exec sql end declare section;
+
+ int f=fa();
+
+#ifdef _cplusplus
+ exec sql begin declare section;
+ int k=N::i; /* compile error */
+ exec sql end declare section;
+#endif
+
+ ECPGdebug(1, stderr);
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d\n", a, b, b2, c, d, e, f, g, h, i, j);
+ iay = 0;
+ printf("%ld\n", iay);
+ exec sql whenever sqlerror do fa();
+ exec sql select now();
+ exec sql whenever sqlerror do fb(20);
+ exec sql select now();
+ exec sql whenever sqlerror do fc("50");
+ exec sql select now();
+ exec sql whenever sqlerror do fd("50",1);
+ exec sql select now();
+ exec sql whenever sqlerror do fe(ENUM0);
+ exec sql select now();
+ exec sql whenever sqlerror do sqlnotice(NULL, NONO);
+ exec sql select now();
+ return 0;
+}