LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/preproc - define.pgc (source / functions) Coverage Total Hit
Test: PostgreSQL 20devel Lines: 100.0 % 23 23
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: 54.5 % 22 12

             Branch data     Line data    Source code
       1                 :             : #include <stdlib.h>
       2                 :             : #include <string.h>
       3                 :             : #include <stdio.h>
       4                 :             : 
       5                 :             : exec sql include ../regression;
       6                 :             : 
       7                 :             : exec sql whenever sqlerror sqlprint;
       8                 :             : 
       9                 :             : exec sql define AMOUNT 6;
      10                 :             : exec sql define NAMELEN 8;
      11                 :             : 
      12                 :             : exec sql type intarray is int[AMOUNT];
      13                 :             : typedef int intarray[AMOUNT];
      14                 :             : 
      15                 :             : int
      16                 :           2 : main(void)
      17                 :             : {
      18                 :             : exec sql begin declare section;
      19                 :             : 
      20                 :             : exec sql ifdef NAMELEN;
      21                 :             :     typedef char string[NAMELEN];
      22                 :             :     intarray amount;
      23                 :             :     char name[AMOUNT][NAMELEN];
      24                 :             : exec sql elif AMOUNT;
      25                 :             :     should not get here;
      26                 :             : exec sql else;
      27                 :             :     should not get here either;
      28                 :             : exec sql endif;
      29                 :             : 
      30                 :             : exec sql ifndef NAMELEN;
      31                 :             :     should not get here;
      32                 :             : exec sql elif AMOUNT;
      33                 :             :   exec sql ifdef NOSUCHNAME;
      34                 :             :     should not get here;
      35                 :             :   exec sql else;
      36                 :             :     char letter[AMOUNT][1];
      37                 :             : #if 0
      38                 :             :     int not_used;
      39                 :             : #endif
      40                 :             :   exec sql endif;
      41                 :             : exec sql elif AMOUNT;
      42                 :             :     should not get here;
      43                 :             : exec sql endif;
      44                 :             : 
      45                 :             : exec sql end declare section;
      46                 :             :     int i,j;
      47                 :             : 
      48                 :           2 :     ECPGdebug(1, stderr);
      49                 :             : 
      50                 :           2 :     exec sql connect to REGRESSDB1;
      51         [ -  + ]:           2 : 
      52                 :           2 :     exec sql create table test (name char(NAMELEN), amount int, letter char(1));
      53         [ -  + ]:           2 :     exec sql commit;
      54         [ -  + ]:           2 : 
      55                 :           2 :     exec sql insert into Test (name, amount, letter) values ('false', 1, 'f');
      56         [ -  + ]:           2 :     exec sql insert into test (name, amount, letter) values ('true', 2, 't');
      57         [ -  + ]:           2 :     exec sql commit;
      58         [ -  + ]:           2 : 
      59                 :           2 :     exec sql select * into :name, :amount, :letter from test;
      60         [ -  + ]:           2 : 
      61         [ +  + ]:           6 :     for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
      62                 :             :     {
      63                 :             :         exec sql begin declare section;
      64                 :             :         string n;
      65                 :           4 :         char l = letter[i][0];
      66                 :           4 :         int a = amount[i];
      67                 :             :         exec sql end declare section;
      68                 :             : 
      69                 :           4 :         strncpy(n, name[i], NAMELEN);
      70                 :           4 :         printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
      71                 :             :     }
      72                 :             : 
      73                 :           2 :     exec sql drop table test;
      74         [ -  + ]:           2 :     exec sql commit;
      75         [ -  + ]:           2 :     exec sql disconnect;
      76         [ -  + ]:           2 : 
      77                 :           2 :     return 0;
      78                 :             : }
        

Generated by: LCOV version 2.0-1