LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/sql - dynalloc.pgc (source / functions) Hit Total Coverage
Test: PostgreSQL 18devel Lines: 62 62 100.0 %
Date: 2024-11-21 08:14:44 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include <stdio.h>
       2             : exec sql include sqlca;
       3             : #include <stdlib.h>
       4             : exec sql include ../regression;
       5             : 
       6           4 : int main(void)
       7             : {
       8             :    exec sql begin declare section;
       9           4 :    int     *d1=0;
      10           4 :    double  *d2=0;
      11           4 :    char **d3=0;
      12           4 :    char **d4=0;
      13           4 :    char **d5=0;
      14           4 :    char **d6=0;
      15           4 :    char **d7=0;
      16             : /*   char **d8=0; */
      17           4 :    char **d9=0;
      18           4 :    int *i1=0;
      19           4 :    int *i2=0;
      20           4 :    int *i3=0;
      21           4 :    int *i4=0;
      22           4 :    int *i5=0;
      23           4 :    int *i6=0;
      24           4 :    int *i7=0;
      25             : /*   int *i8=0; */
      26           4 :    int *i9=0;
      27             :    exec sql end declare section;
      28             :    int i;
      29             : 
      30           4 :    ECPGdebug(1, stderr);
      31             : 
      32             :    exec sql whenever sqlerror do sqlprint();
      33           4 :    exec sql connect to REGRESSDB1;
      34           4 : 
      35           4 :    exec sql set datestyle to mdy;
      36           4 : 
      37           4 :    exec sql create table test (a serial, b numeric(12,3), c varchar, d varchar(3), e char(4), f timestamptz, g boolean, h box, i inet);
      38           4 :    exec sql insert into test (b, c, d, e, f, g, h, i) values (23.456, 'varchar', 'v', 'c', '2003-03-03 12:33:07 PDT', true, '(1,2,3,4)', '2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128');
      39           4 :    exec sql insert into test (b, c, d, e, f, g, h, i) values (2.446456, NULL, 'v', 'c', '2003-03-03 12:33:07 PDT', false, NULL, NULL);
      40           4 : 
      41           4 :    exec sql allocate descriptor mydesc;
      42           4 :    exec sql select a,b,c,d,e,f,g,h,i into sql descriptor mydesc from test order by a;
      43           4 :    exec sql get descriptor mydesc value 1 :d1=DATA, :i1=INDICATOR;
      44           4 :    exec sql get descriptor mydesc value 2 :d2=DATA, :i2=INDICATOR;
      45           4 :    exec sql get descriptor mydesc value 3 :d3=DATA, :i3=INDICATOR;
      46           4 :    exec sql get descriptor mydesc value 4 :d4=DATA, :i4=INDICATOR;
      47           4 :    exec sql get descriptor mydesc value 5 :d5=DATA, :i5=INDICATOR;
      48           4 :    exec sql get descriptor mydesc value 6 :d6=DATA, :i6=INDICATOR;
      49           4 :    exec sql get descriptor mydesc value 7 :d7=DATA, :i7=INDICATOR;
      50           4 :    /* skip box for now */
      51             :    /* exec sql get descriptor mydesc value 8 :d8=DATA, :i8=INDICATOR; */
      52           4 :    exec sql get descriptor mydesc value 9 :d9=DATA, :i9=INDICATOR;
      53           4 : 
      54           4 :    printf("Result:\n");
      55          12 :    for (i=0;i<sqlca.sqlerrd[2];++i)
      56             :    {
      57           8 :       if (i1[i]) printf("NULL, ");
      58           8 :       else printf("%d, ",d1[i]);
      59             : 
      60           8 :       if (i2[i]) printf("NULL, ");
      61           8 :       else printf("%f, ",d2[i]);
      62             : 
      63           8 :       if (i3[i]) printf("NULL, ");
      64           4 :       else printf("'%s', ",d3[i]);
      65             : 
      66           8 :       if (i4[i]) printf("NULL, ");
      67           8 :       else printf("'%s', ",d4[i]);
      68             : 
      69           8 :       if (i5[i]) printf("NULL, ");
      70           8 :       else printf("'%s', ",d5[i]);
      71             : 
      72           8 :       if (i6[i]) printf("NULL, ");
      73           8 :       else printf("'%s', ",d6[i]);
      74             : 
      75           8 :       if (i7[i]) printf("NULL, ");
      76           8 :       else printf("'%s', ",d7[i]);
      77             : 
      78           8 :       if (i9[i]) printf("NULL, ");
      79           4 :       else printf("'%s', ",d9[i]);
      80             : 
      81           8 :       printf("\n");
      82             :    }
      83           4 :    ECPGfree_auto_mem();
      84           4 :    printf("\n");
      85             : 
      86           4 :    exec sql deallocate descriptor mydesc;
      87           4 :    exec sql disconnect;
      88           4 :    return 0;
      89             : }

Generated by: LCOV version 1.14