LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/sql - dynalloc2.pgc (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 37 37 100.0 %
Date: 2019-11-13 21:06:57 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 *ip1=0;
      10           4 :    char **cp2=0;
      11           4 :    int *ipointer1=0;
      12           4 :    int *ipointer2=0;
      13             :    int colnum;
      14             :    exec sql end declare section;
      15             :    int i;
      16             : 
      17           4 :    ECPGdebug(1, stderr);
      18             : 
      19             :    exec sql whenever sqlerror do sqlprint();
      20           4 :    exec sql connect to REGRESSDB1;
      21           4 : 
      22           4 :    exec sql set datestyle to postgres;
      23           4 : 
      24           4 :    exec sql create table test (a int, b text);
      25           4 :    exec sql insert into test values (1, 'one');
      26           4 :    exec sql insert into test values (2, 'two');
      27           4 :    exec sql insert into test values (NULL, 'three');
      28           4 :    exec sql insert into test values (4, 'four');
      29           4 :    exec sql insert into test values (5, NULL);
      30           4 :    exec sql insert into test values (NULL, NULL);
      31           4 : 
      32           4 :    exec sql allocate descriptor mydesc;
      33           4 :    exec sql select * into sql descriptor mydesc from test;
      34           4 :    exec sql get descriptor mydesc :colnum=COUNT;
      35           4 :    exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
      36           4 :    exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
      37           4 : 
      38           4 :    printf("Result (%d columns):\n", colnum);
      39          28 :    for (i=0;i < sqlca.sqlerrd[2];++i)
      40             :    {
      41          24 :       if (ipointer1[i]) printf("NULL, ");
      42          16 :       else printf("%d, ",ip1[i]);
      43             : 
      44          24 :       if (ipointer2[i]) printf("NULL, ");
      45          16 :       else printf("'%s', ",cp2[i]);
      46          24 :       printf("\n");
      47             :    }
      48           4 :    ECPGfree_auto_mem();
      49           4 :    printf("\n");
      50             : 
      51           4 :    exec sql deallocate descriptor mydesc;
      52           4 :    exec sql rollback;
      53           4 :    exec sql disconnect;
      54           4 :    return 0;
      55             : }

Generated by: LCOV version 1.13