LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/preproc - type.pgc (source / functions) Hit Total Coverage
Test: PostgreSQL 12beta2 Lines: 16 24 66.7 %
Date: 2019-06-19 16:07:09 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include <stdio.h>
       2             : #include <stdlib.h>
       3             : 
       4             : EXEC SQL include ../regression;
       5             : 
       6             : EXEC SQL typedef long mmInteger;
       7             : EXEC SQL typedef char mmChar;
       8             : EXEC SQL typedef short mmSmallInt;
       9             : 
      10             : exec sql type string is char[11];
      11             : typedef char string[11];
      12             : 
      13             : exec sql type c is char reference;
      14             : typedef char* c;
      15             : 
      16             : EXEC SQL BEGIN DECLARE SECTION;
      17             : struct TBempl
      18             : {
      19             :   mmInteger idnum;
      20             :   mmChar name[21];
      21             :   mmSmallInt accs;
      22             : };
      23             : EXEC SQL END DECLARE SECTION;
      24             : 
      25             : int
      26           4 : main (void)
      27             : {
      28             :   EXEC SQL BEGIN DECLARE SECTION;
      29             :   struct TBempl empl;
      30             :   string str;
      31           4 :   c ptr = NULL;
      32             :   struct varchar
      33             :   {
      34             :     int len;
      35             :     char text[10];
      36             :   } vc;
      37             :   EXEC SQL END DECLARE SECTION;
      38             : 
      39             :   EXEC SQL var vc is varchar[10];
      40           4 :   ECPGdebug (1, stderr);
      41             : 
      42           4 :   empl.idnum = 1;
      43           4 :   EXEC SQL connect to REGRESSDB1;
      44           4 :   if (sqlca.sqlcode)
      45             :     {
      46           0 :       printf ("connect error = %ld\n", sqlca.sqlcode);
      47           0 :       exit (sqlca.sqlcode);
      48             :     }
      49             : 
      50           4 :   EXEC SQL create table empl
      51             :     (idnum integer, name char(20), accs smallint, string1 char(10), string2 char(10), string3 char(10));
      52           4 :   if (sqlca.sqlcode)
      53             :     {
      54           0 :       printf ("create error = %ld\n", sqlca.sqlcode);
      55           0 :       exit (sqlca.sqlcode);
      56             :     }
      57             : 
      58           4 :   EXEC SQL insert into empl values (1, 'user name', 320, 'first str', 'second str', 'third str');
      59           4 :   if (sqlca.sqlcode)
      60             :     {
      61           0 :       printf ("insert error = %ld\n", sqlca.sqlcode);
      62           0 :       exit (sqlca.sqlcode);
      63             :     }
      64             : 
      65           4 :   EXEC SQL select idnum, name, accs, string1, string2, string3
      66             :     into :empl, :str, :ptr, :vc
      67             :     from empl
      68             :     where idnum =:empl.idnum;
      69           4 :   if (sqlca.sqlcode)
      70             :     {
      71           0 :       printf ("select error = %ld\n", sqlca.sqlcode);
      72           0 :       exit (sqlca.sqlcode);
      73             :     }
      74           4 :   printf ("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text);
      75             : 
      76           4 :   EXEC SQL disconnect;
      77             : 
      78           4 :   free(ptr);
      79           4 :   exit (0);
      80             : }

Generated by: LCOV version 1.13