LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/sql - quote.pgc (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 35 35 100.0 %
Date: 2019-11-15 23:07:02 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include <stdio.h>
       2             : #include <stdlib.h>
       3             : #include <string.h>
       4             : 
       5             : EXEC SQL INCLUDE ../regression;
       6             : 
       7           4 : int main() {
       8             :   EXEC SQL BEGIN DECLARE SECTION;
       9             :     char var[25];
      10             :     int i, loopcount;
      11             :   EXEC SQL END DECLARE SECTION;
      12             : 
      13           4 :   ECPGdebug(1, stderr);
      14           4 :   EXEC SQL CONNECT TO REGRESSDB1;
      15             : 
      16           4 :   EXEC SQL SET AUTOCOMMIT TO ON;
      17             :   EXEC SQL WHENEVER SQLWARNING SQLPRINT;
      18             :   EXEC SQL WHENEVER SQLERROR STOP;
      19             : 
      20           4 :   EXEC SQL CREATE TABLE "My_Table" ( Item1 int, Item2 text );
      21           4 : 
      22           4 :   EXEC SQL SET standard_conforming_strings TO off;
      23           4 : 
      24           4 :   EXEC SQL SHOW standard_conforming_strings INTO :var;
      25           4 :   printf("Standard conforming strings: %s\n", var);
      26             : 
      27             :   /* this is a\\b actually */
      28           4 :   EXEC SQL INSERT INTO "My_Table" VALUES ( 1, 'a\\\\b' );
      29           4 :   /* this is a\\b */
      30           4 :   EXEC SQL INSERT INTO "My_Table" VALUES ( 1, E'a\\\\b' );
      31           4 : 
      32           4 :   EXEC SQL SET standard_conforming_strings TO on;
      33           4 : 
      34           4 :   EXEC SQL SHOW standard_conforming_strings INTO :var;
      35           4 :   printf("Standard conforming strings: %s\n", var);
      36             : 
      37             :   /* this is a\\\\b actually */
      38           4 :   EXEC SQL INSERT INTO "My_Table" VALUES ( 2, 'a\\\\b' );
      39           4 :   /* this is a\\b */
      40           4 :   EXEC SQL INSERT INTO "My_Table" VALUES ( 2, E'a\\\\b' );
      41           4 : 
      42           4 :   EXEC SQL BEGIN;
      43           4 :   EXEC SQL DECLARE C CURSOR FOR SELECT * FROM "My_Table";
      44             : 
      45           4 :   EXEC SQL OPEN C;
      46           4 : 
      47             :   EXEC SQL WHENEVER NOT FOUND DO BREAK;
      48             : 
      49          20 :   for (loopcount = 0; loopcount < 100; loopcount++)
      50             :   {
      51          20 :     EXEC SQL FETCH C INTO :i, :var;
      52          20 :     printf("value: %d %s\n", i, var);
      53             :   }
      54             : 
      55           4 :   EXEC SQL ROLLBACK;
      56           4 :   EXEC SQL DROP TABLE "My_Table";
      57           4 : 
      58           4 :   EXEC SQL DISCONNECT ALL;
      59           4 : 
      60           4 :   return 0;
      61             : }

Generated by: LCOV version 1.13