#include <stdio.h>
#include <stdlib.h>
#include <string.h>

EXEC SQL INCLUDE ../regression;

int main(int argc, char* argv[]) {
  EXEC SQL BEGIN DECLARE SECTION;
    char var[25];
  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 "My_Table" ( Item1 int, Item2 text );

  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;

  /* 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 SELECT * FROM "My_Table";

  EXEC SQL DROP TABLE "My_Table";

  EXEC SQL DISCONNECT ALL;

  return 0;
}
