LCOV - differential code coverage report
Current view: top level - src/interfaces/ecpg/test/compat_informix - describe.pgc (source / functions) Coverage Total Hit UBC CBC
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 87.5 % 128 112 16 112
Current Date: 2024-04-14 14:21:10 Functions: 100.0 % 1 1 1
Baseline: 16@8cea358b128 Branches: 52.1 % 94 49 45 49
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: 87.5 % 128 112 16 112
Function coverage date bins:
(240..) days: 100.0 % 1 1 1
Branch coverage date bins:
(240..) days: 52.1 % 94 49 45 49

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : #include <stdlib.h>
                                  2                 :                : #include <string.h>
                                  3                 :                : 
                                  4                 :                : exec sql include ../regression;
                                  5                 :                : exec sql include sqlda.h;
                                  6                 :                : 
                                  7                 :                : exec sql whenever sqlerror stop;
                                  8                 :                : 
                                  9                 :                : sqlda_t *sqlda1, *sqlda2, *sqlda3;
                                 10                 :                : 
                                 11                 :                : int
 5203 meskes@postgresql.or       12                 :CBC           1 : main (void)
                                 13                 :                : {
                                 14                 :                : exec sql begin declare section;
                                 15                 :              1 :     char    *stmt1 = "SELECT id, t FROM descr_t1";
                                 16                 :              1 :     char    *stmt2 = "SELECT id, t FROM descr_t1 WHERE id = -1";
                                 17                 :                :     int i, count1, count2;
                                 18                 :              1 :     char    field_name1[30] = "not set";
                                 19                 :              1 :     char    field_name2[30] = "not set";
                                 20                 :                : exec sql end declare section;
                                 21                 :                : 
                                 22                 :                :     char msg[128];
                                 23                 :                : 
                                 24                 :              1 :     ECPGdebug(1, stderr);
                                 25                 :                : 
                                 26                 :              1 :     strcpy(msg, "connect");
                                 27                 :              1 :     exec sql connect to REGRESSDB1;
                                 28         [ -  + ]:              1 : 
                                 29                 :              1 :     strcpy(msg, "set");
                                 30                 :              1 :     exec sql set datestyle to iso;
                                 31         [ -  + ]:              1 : 
                                 32                 :              1 :     strcpy(msg, "create");
                                 33                 :              1 :     exec sql create table descr_t1(id serial primary key, t text);
                                 34         [ -  + ]:              1 : 
                                 35                 :              1 :     strcpy(msg, "insert");
                                 36                 :              1 :     exec sql insert into descr_t1(id, t) values (default, 'a');
                                 37         [ -  + ]:              1 :     exec sql insert into descr_t1(id, t) values (default, 'b');
                                 38         [ -  + ]:              1 :     exec sql insert into descr_t1(id, t) values (default, 'c');
                                 39         [ -  + ]:              1 :     exec sql insert into descr_t1(id, t) values (default, 'd');
                                 40         [ -  + ]:              1 : 
                                 41                 :              1 :     strcpy(msg, "commit");
                                 42                 :              1 :     exec sql commit;
                                 43         [ -  + ]:              1 : 
                                 44                 :                :     /*
                                 45                 :                :      * Test DESCRIBE with a query producing tuples.
                                 46                 :                :      * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
                                 47                 :                :      * Informix-compat mode.
                                 48                 :                :      */
                                 49                 :                : 
                                 50                 :              1 :     strcpy(msg, "allocate");
                                 51                 :              1 :     exec sql allocate descriptor desc1;
                                 52         [ -  + ]:              1 :     exec sql allocate descriptor desc2;
                                 53         [ -  + ]:              1 : 
                                 54                 :              1 :     strcpy(msg, "prepare");
                                 55                 :              1 :     exec sql prepare st_id1 FROM :stmt1;
                                 56         [ -  + ]:              1 : 
                                 57                 :              1 :     sqlda1 = sqlda2 = sqlda3 = NULL;
                                 58                 :                : 
                                 59                 :              1 :     strcpy(msg, "describe");
                                 60                 :              1 :     exec sql describe st_id1 into sql descriptor desc1;
                                 61                 :              1 :     exec sql describe st_id1 using sql descriptor desc2;
                                 62                 :                : 
                                 63                 :              1 :     exec sql describe st_id1 into descriptor sqlda1;
                                 64                 :              1 :     exec sql describe st_id1 using descriptor sqlda2;
                                 65                 :              1 :     exec sql describe st_id1 into sqlda3;
                                 66                 :                : 
                                 67         [ -  + ]:              1 :     if (sqlda1 == NULL)
                                 68                 :                :     {
 5203 meskes@postgresql.or       69                 :UBC           0 :         printf("sqlda1 NULL\n");
                                 70                 :              0 :         exit(1);
                                 71                 :                :     }
                                 72                 :                : 
 5203 meskes@postgresql.or       73         [ -  + ]:CBC           1 :     if (sqlda2 == NULL)
                                 74                 :                :     {
 5203 meskes@postgresql.or       75                 :UBC           0 :         printf("sqlda2 NULL\n");
                                 76                 :              0 :         exit(1);
                                 77                 :                :     }
                                 78                 :                : 
 5203 meskes@postgresql.or       79         [ -  + ]:CBC           1 :     if (sqlda3 == NULL)
                                 80                 :                :     {
 5203 meskes@postgresql.or       81                 :UBC           0 :         printf("sqlda3 NULL\n");
                                 82                 :              0 :         exit(1);
                                 83                 :                :     }
                                 84                 :                : 
 5203 meskes@postgresql.or       85                 :CBC           1 :     strcpy(msg, "get descriptor");
                                 86                 :              1 :     exec sql get descriptor desc1 :count1 = count;
                                 87         [ -  + ]:              1 :     exec sql get descriptor desc1 :count2 = count;
                                 88         [ -  + ]:              1 : 
                                 89         [ -  + ]:              1 :     if (count1 != count2)
                                 90                 :                :     {
 5203 meskes@postgresql.or       91                 :UBC           0 :         printf("count1 (%d) != count2 (%d)\n", count1, count2);
                                 92                 :              0 :         exit(1);
                                 93                 :                :     }
                                 94                 :                : 
 5203 meskes@postgresql.or       95         [ -  + ]:CBC           1 :     if (count1 != sqlda1->sqld)
                                 96                 :                :     {
 5203 meskes@postgresql.or       97                 :UBC           0 :         printf("count1 (%d) != sqlda1->sqld (%d)\n", count1, sqlda1->sqld);
                                 98                 :              0 :         exit(1);
                                 99                 :                :     }
                                100                 :                : 
 5203 meskes@postgresql.or      101         [ -  + ]:CBC           1 :     if (count1 != sqlda2->sqld)
                                102                 :                :     {
 5203 meskes@postgresql.or      103                 :UBC           0 :         printf("count1 (%d) != sqlda2->sqld (%d)\n", count1, sqlda2->sqld);
                                104                 :              0 :         exit(1);
                                105                 :                :     }
                                106                 :                : 
 5203 meskes@postgresql.or      107         [ -  + ]:CBC           1 :     if (count1 != sqlda3->sqld)
                                108                 :                :     {
 5203 meskes@postgresql.or      109                 :UBC           0 :         printf("count1 (%d) != sqlda3->sqld (%d)\n", count1, sqlda3->sqld);
                                110                 :              0 :         exit(1);
                                111                 :                :     }
                                112                 :                : 
 5203 meskes@postgresql.or      113         [ +  + ]:CBC           3 :     for (i = 1; i <= count1; i++)
                                114                 :                :     {
                                115                 :              2 :         exec sql get descriptor desc1 value :i :field_name1 = name;
                                116         [ -  + ]:              2 :         exec sql get descriptor desc2 value :i :field_name2 = name;
                                117         [ -  + ]:              2 :         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
                                118                 :                :             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
                                119                 :                :             i, field_name1, field_name2,
                                120                 :              2 :             sqlda1->sqlvar[i-1].sqlname,
                                121                 :              2 :             sqlda2->sqlvar[i-1].sqlname,
                                122                 :              2 :             sqlda3->sqlvar[i-1].sqlname);
                                123                 :                :     }
                                124                 :                : 
                                125                 :              1 :     strcpy(msg, "deallocate");
                                126                 :              1 :     exec sql deallocate descriptor desc1;
                                127         [ -  + ]:              1 :     exec sql deallocate descriptor desc2;
                                128         [ -  + ]:              1 :     free(sqlda1);
                                129                 :              1 :     free(sqlda2);
                                130                 :              1 :     free(sqlda3);
                                131                 :                : 
                                132                 :              1 :     exec sql deallocate prepare st_id1;
                                133         [ -  + ]:              1 : 
                                134                 :                :     /* Test DESCRIBE with a query not producing tuples */
                                135                 :                : 
                                136                 :              1 :     strcpy(msg, "allocate");
                                137                 :              1 :     exec sql allocate descriptor desc1;
                                138         [ -  + ]:              1 :     exec sql allocate descriptor desc2;
                                139         [ -  + ]:              1 : 
                                140                 :              1 :     strcpy(msg, "prepare");
                                141                 :              1 :     exec sql prepare st_id2 FROM :stmt2;
                                142         [ -  + ]:              1 : 
                                143                 :              1 :     sqlda1 = sqlda2 = sqlda3 = NULL;
                                144                 :                : 
                                145                 :              1 :     strcpy(msg, "describe");
                                146                 :              1 :     exec sql describe st_id2 into sql descriptor desc1;
                                147                 :              1 :     exec sql describe st_id2 using sql descriptor desc2;
                                148                 :                : 
                                149                 :              1 :     exec sql describe st_id2 into descriptor sqlda1;
                                150                 :              1 :     exec sql describe st_id2 using descriptor sqlda2;
                                151                 :              1 :     exec sql describe st_id2 into sqlda3;
                                152                 :                : 
 2977 peter_e@gmx.net           153   [ +  -  +  -  :              1 :     if (sqlda1 == NULL || sqlda2 == NULL || sqlda3 == NULL)
                                              -  + ]
 5203 meskes@postgresql.or      154                 :UBC           0 :         exit(1);
                                155                 :                : 
 5203 meskes@postgresql.or      156                 :CBC           1 :     strcpy(msg, "get descriptor");
                                157                 :              1 :     exec sql get descriptor desc1 :count1 = count;
                                158         [ -  + ]:              1 :     exec sql get descriptor desc1 :count2 = count;
                                159         [ -  + ]:              1 : 
                                160         [ +  - ]:              1 :     if (!(  count1 == count2 &&
                                161         [ +  - ]:              1 :         count1 == sqlda1->sqld &&
                                162         [ +  - ]:              1 :         count1 == sqlda2->sqld &&
                                163         [ -  + ]:              1 :         count1 == sqlda3->sqld))
 5203 meskes@postgresql.or      164                 :UBC           0 :         exit(1);
                                165                 :                : 
 5203 meskes@postgresql.or      166         [ +  + ]:CBC           3 :     for (i = 1; i <= count1; i++)
                                167                 :                :     {
                                168                 :              2 :         exec sql get descriptor desc1 value :i :field_name1 = name;
                                169         [ -  + ]:              2 :         exec sql get descriptor desc2 value :i :field_name2 = name;
                                170         [ -  + ]:              2 :         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
                                171                 :                :             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
                                172                 :                :             i, field_name1, field_name2,
                                173                 :              2 :             sqlda1->sqlvar[i-1].sqlname,
                                174                 :              2 :             sqlda2->sqlvar[i-1].sqlname,
                                175                 :              2 :             sqlda3->sqlvar[i-1].sqlname);
                                176                 :                :     }
                                177                 :                : 
                                178                 :              1 :     strcpy(msg, "deallocate");
                                179                 :              1 :     exec sql deallocate descriptor desc1;
                                180         [ -  + ]:              1 :     exec sql deallocate descriptor desc2;
                                181         [ -  + ]:              1 :     free(sqlda1);
                                182                 :              1 :     free(sqlda2);
                                183                 :              1 :     free(sqlda3);
                                184                 :                : 
                                185                 :              1 :     exec sql deallocate prepare st_id2;
                                186         [ -  + ]:              1 : 
                                187                 :                :     /* End test */
                                188                 :                : 
                                189                 :              1 :     strcpy(msg, "drop");
                                190                 :              1 :     exec sql drop table descr_t1;
                                191         [ -  + ]:              1 : 
                                192                 :              1 :     strcpy(msg, "commit");
                                193                 :              1 :     exec sql commit;
                                194         [ -  + ]:              1 : 
 4891 peter_e@gmx.net           195                 :              1 :     strcpy(msg, "disconnect");
 5203 meskes@postgresql.or      196                 :              1 :     exec sql disconnect;
                                197         [ -  + ]:              1 : 
 2432 peter_e@gmx.net           198                 :              1 :     return 0;
                                199                 :                : }
        

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