From 311bcfc6b3acdd6fd152798c7f287ddf74fa2a98 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 16 Apr 2024 21:46:48 +0200 Subject: Adding upstream version 15.4. Signed-off-by: Daniel Baumann --- src/interfaces/ecpg/test/sql/quote.pgc | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/interfaces/ecpg/test/sql/quote.pgc (limited to 'src/interfaces/ecpg/test/sql/quote.pgc') 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 +#include +#include + +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; +} -- cgit v1.2.3