summaryrefslogtreecommitdiffstats
path: root/src/interfaces/ecpg/test/sql/parser.pgc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:15:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:15:05 +0000
commit46651ce6fe013220ed397add242004d764fc0153 (patch)
tree6e5299f990f88e60174a1d3ae6e48eedd2688b2b /src/interfaces/ecpg/test/sql/parser.pgc
parentInitial commit. (diff)
downloadpostgresql-14-upstream.tar.xz
postgresql-14-upstream.zip
Adding upstream version 14.5.upstream/14.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/interfaces/ecpg/test/sql/parser.pgc')
-rw-r--r--src/interfaces/ecpg/test/sql/parser.pgc39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/test/sql/parser.pgc b/src/interfaces/ecpg/test/sql/parser.pgc
new file mode 100644
index 0000000..6e15f13
--- /dev/null
+++ b/src/interfaces/ecpg/test/sql/parser.pgc
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* test parser addition that merges two tokens into one */
+EXEC SQL INCLUDE ../regression;
+
+int main() {
+ EXEC SQL BEGIN DECLARE SECTION;
+ int item[3], ind[3], i;
+ EXEC SQL END DECLARE SECTION;
+
+ ECPGdebug(1, stderr);
+ EXEC SQL CONNECT TO REGRESSDB1;
+
+ EXEC SQL SET AUTOCOMMIT TO ON;
+ EXEC SQL WHENEVER SQLWARNING SQLPRINT;
+ EXEC SQL WHENEVER SQLERROR SQLPRINT;
+
+ EXEC SQL CREATE TABLE T ( Item1 int, Item2 int );
+
+ EXEC SQL INSERT INTO t
+ SELECT 1,nullif(y-1,0)
+ FROM generate_series(1,3) WITH ORDINALITY AS series(x,y);
+
+ EXEC SQL SELECT Item2 INTO :item:ind FROM T ORDER BY Item2 NULLS LAST;
+
+ for (i=0; i<3; i++)
+ printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
+
+ EXEC SQL ALTER TABLE T ALTER Item1 TYPE bigint;
+ EXEC SQL ALTER TABLE T ALTER COLUMN Item2 SET DATA TYPE smallint;
+
+ EXEC SQL DROP TABLE T;
+
+ EXEC SQL DISCONNECT ALL;
+
+ return 0;
+}