LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/preproc - type.pgc (source / functions) Coverage Total Hit
Test: PostgreSQL 20devel Lines: 68.0 % 25 17
Test Date: 2026-07-25 22:15:46 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 50.0 % 8 4

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

Generated by: LCOV version 2.0-1