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

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

Generated by: LCOV version 1.13