summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/test/sql/parser.pgc
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2007-03-17 19:25:24 +0000
committerMichael Meskes <meskes@postgresql.org>2007-03-17 19:25:24 +0000
commitd3e131e06269d569917ac2a005bc6b92b581612f (patch)
tree56afc7a953c2ad68ba36b5022990dc9d0de17105 /src/interfaces/ecpg/test/sql/parser.pgc
parente6e78187ef4011aa3d44280fccc8fbc9baed1dfa (diff)
- Changed some whitespacing in connect statement.
- Made some chars const as proposed by Stefan Huehner <stefan@huehner.org>. - Synced parser and keyword lists. - Copied two token parsing from backend parser to ecpg parser. - Also added a test case for this.
Diffstat (limited to 'src/interfaces/ecpg/test/sql/parser.pgc')
-rw-r--r--src/interfaces/ecpg/test/sql/parser.pgc36
1 files changed, 36 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 00000000000..97ccedda289
--- /dev/null
+++ b/src/interfaces/ecpg/test/sql/parser.pgc
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* test parser addition that merges two tokens into one */
+EXEC SQL INCLUDE ../regression;
+
+int main(int argc, char* argv[]) {
+ 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 VALUES ( 1, null );
+ EXEC SQL INSERT INTO T VALUES ( 1, 1 );
+ EXEC SQL INSERT INTO T VALUES ( 1, 2 );
+
+ 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 DROP TABLE T;
+
+ EXEC SQL DISCONNECT ALL;
+
+ return 0;
+}