LCOV - differential code coverage report
Current view: top level - src/interfaces/ecpg/test/preproc - pointer_to_struct.pgc (source / functions) Coverage Total Hit UBC CBC
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 100.0 % 39 39 39
Current Date: 2024-04-14 14:21:10 Functions: 100.0 % 1 1 1
Baseline: 16@8cea358b128 Branches: 56.5 % 62 35 27 35
Baseline Date: 2024-04-14 14:21:09 Line coverage date bins:
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed (240..) days: 100.0 % 39 39 39
Function coverage date bins:
(240..) days: 100.0 % 1 1 1
Branch coverage date bins:
(240..) days: 56.5 % 62 35 27 35

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : #include <stdio.h>
                                  2                 :                : #include <stdlib.h>
                                  3                 :                : 
                                  4                 :                : exec sql include ../regression;
                                  5                 :                : 
                                  6                 :                : EXEC SQL WHENEVER sqlerror sqlprint;
                                  7                 :                : EXEC SQL WHENEVER sqlwarning sqlprint;
                                  8                 :                : EXEC SQL WHENEVER not found sqlprint;
                                  9                 :                : 
                                 10                 :                : EXEC SQL TYPE customer IS
                                 11                 :                :     struct
                                 12                 :                :     {
                                 13                 :                :         varchar name[50];
                                 14                 :                :         int     phone;
                                 15                 :                :     };
                                 16                 :                : 
                                 17                 :                : EXEC SQL TYPE cust_ind IS
                                 18                 :                :     struct ind
                                 19                 :                :     {
                                 20                 :                :         short   name_ind;
                                 21                 :                :         short   phone_ind;
                                 22                 :                :     };
                                 23                 :                : 
 3658 meskes@postgresql.or       24                 :CBC           1 : int main()
                                 25                 :                : {
                                 26                 :                :     EXEC SQL begin declare section;
                                 27                 :              1 :       customer  *custs1 = (customer *) malloc(sizeof(customer) * 10);
                                 28                 :              1 :       cust_ind  *inds = (cust_ind *) malloc(sizeof(cust_ind) * 10);
                                 29                 :                :       typedef struct
                                 30                 :                :       {
                                 31                 :                :         varchar name[50];
                                 32                 :                :         int     phone;
                                 33                 :                :       } customer2;
                                 34                 :              1 :       customer2  *custs2 = (customer2 *) malloc(sizeof(customer2) * 10);
                                 35                 :                : 
                                 36                 :                :       struct customer3
                                 37                 :                :       {
                                 38                 :                :         char name[50];
                                 39                 :                :         int     phone;
                                 40                 :              1 :       } *custs3 = (struct customer3 *) malloc(sizeof(struct customer3) * 10);
                                 41                 :                : 
                                 42                 :                :       struct customer4
                                 43                 :                :       {
                                 44                 :                :         varchar name[50];
                                 45                 :                :         int     phone;
                                 46                 :              1 :       } *custs4 = (struct customer4 *) malloc(sizeof(struct customer4));
                                 47                 :                : 
                                 48                 :                :       int r;
                                 49                 :                :       varchar onlyname[2][50];
                                 50                 :                :     EXEC SQL end declare section;
                                 51                 :                : 
                                 52                 :              1 :     ECPGdebug(1, stderr);
                                 53                 :                : 
                                 54                 :              1 :     EXEC SQL connect to REGRESSDB1;
                                 55   [ -  +  -  + ]:              1 : 
                                 56                 :              1 :     EXEC SQL create table customers (c varchar(50), p int);
                                 57   [ -  +  -  + ]:              1 :     EXEC SQL insert into customers values ('John Doe', '12345');
                                 58   [ -  +  -  +  :              1 :     EXEC SQL insert into customers values ('Jane Doe', '67890');
                                              -  + ]
                                 59   [ -  +  -  +  :              1 : 
                                              -  + ]
                                 60                 :              1 :     EXEC SQL select * INTO :custs1:inds from customers limit 2;
                                 61   [ -  +  -  +  :              1 :     printf("custs1:\n");
                                              -  + ]
                                 62         [ +  + ]:              3 :     for (r = 0; r < 2; r++)
                                 63                 :                :     {
                                 64                 :              2 :         printf( "name  - %s\n", custs1[r].name.arr );
                                 65                 :              2 :         printf( "phone - %d\n", custs1[r].phone );
                                 66                 :                :     }
                                 67                 :                : 
                                 68                 :              1 :     EXEC SQL select * INTO :custs2:inds from customers limit 2;
                                 69   [ -  +  -  +  :              1 :     printf("\ncusts2:\n");
                                              -  + ]
                                 70         [ +  + ]:              3 :     for (r = 0; r < 2; r++)
                                 71                 :                :     {
                                 72                 :              2 :         printf( "name  - %s\n", custs2[r].name.arr );
                                 73                 :              2 :         printf( "phone - %d\n", custs2[r].phone );
                                 74                 :                :     }
                                 75                 :                : 
                                 76                 :              1 :     EXEC SQL select * INTO :custs3:inds from customers limit 2;
                                 77   [ -  +  -  +  :              1 :     printf("\ncusts3:\n");
                                              -  + ]
                                 78         [ +  + ]:              3 :     for (r = 0; r < 2; r++)
                                 79                 :                :     {
                                 80                 :              2 :         printf( "name  - %s\n", custs3[r].name );
                                 81                 :              2 :         printf( "phone - %d\n", custs3[r].phone );
                                 82                 :                :     }
                                 83                 :                : 
                                 84                 :              1 :     EXEC SQL select * INTO :custs4:inds from customers limit 1;
                                 85   [ -  +  -  +  :              1 :     printf("\ncusts4:\n");
                                              -  + ]
                                 86                 :              1 :     printf( "name  - %s\n", custs4->name.arr );
                                 87                 :              1 :     printf( "phone - %d\n", custs4->phone );
                                 88                 :                : 
                                 89                 :              1 :     EXEC SQL select c INTO :onlyname from customers limit 2;
                                 90   [ -  +  -  +  :              1 :     printf("\nname:\n");
                                              -  + ]
                                 91         [ +  + ]:              3 :     for (r = 0; r < 2; r++)
                                 92                 :                :     {
                                 93                 :              2 :         printf( "name  - %s\n", onlyname[r].arr );
                                 94                 :                :     }
                                 95                 :                : 
                                 96                 :              1 :     EXEC SQL disconnect all;
                                 97   [ -  +  -  + ]:              1 : 
                                 98                 :                :     /* All the memory will anyway be freed at the end */
 2432 peter_e@gmx.net            99                 :              1 :     return 0;
                                100                 :                : }
        

Generated by: LCOV version 2.1-beta2-3-g6141622