summaryrefslogtreecommitdiffstats
path: root/src/interfaces/ecpg/test/sql/quote.pgc
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/ecpg/test/sql/quote.pgc')
-rw-r--r--src/interfaces/ecpg/test/sql/quote.pgc61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/test/sql/quote.pgc b/src/interfaces/ecpg/test/sql/quote.pgc
new file mode 100644
index 0000000..9b62b7d
--- /dev/null
+++ b/src/interfaces/ecpg/test/sql/quote.pgc
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+EXEC SQL INCLUDE ../regression;
+
+int main() {
+ EXEC SQL BEGIN DECLARE SECTION;
+ char var[25];
+ int i, loopcount;
+ 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 STOP;
+
+ EXEC SQL CREATE TABLE "My_Table" ( Item1 int, Item2 text );
+
+ EXEC SQL SET standard_conforming_strings TO off;
+
+ EXEC SQL SHOW standard_conforming_strings INTO :var;
+ printf("Standard conforming strings: %s\n", var);
+
+ /* this is a\\b actually */
+ EXEC SQL INSERT INTO "My_Table" VALUES ( 1, 'a\\\\b' );
+ /* this is a\\b */
+ EXEC SQL INSERT INTO "My_Table" VALUES ( 1, E'a\\\\b' );
+
+ EXEC SQL SET standard_conforming_strings TO on;
+
+ EXEC SQL SHOW standard_conforming_strings INTO :var;
+ printf("Standard conforming strings: %s\n", var);
+
+ /* this is a\\\\b actually */
+ EXEC SQL INSERT INTO "My_Table" VALUES ( 2, 'a\\\\b' );
+ /* this is a\\b */
+ EXEC SQL INSERT INTO "My_Table" VALUES ( 2, E'a\\\\b' );
+
+ EXEC SQL BEGIN;
+ EXEC SQL DECLARE C CURSOR FOR SELECT * FROM "My_Table";
+
+ EXEC SQL OPEN C;
+
+ EXEC SQL WHENEVER NOT FOUND DO BREAK;
+
+ for (loopcount = 0; loopcount < 100; loopcount++)
+ {
+ EXEC SQL FETCH C INTO :i, :var;
+ printf("value: %d %s\n", i, var);
+ }
+
+ EXEC SQL ROLLBACK;
+ EXEC SQL DROP TABLE "My_Table";
+
+ EXEC SQL DISCONNECT ALL;
+
+ return 0;
+}