LCOV - differential code coverage report
Current view: top level - src/interfaces/ecpg/test/sql - bytea.pgc (source / functions) Coverage Total Hit UBC CBC
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 100.0 % 65 65 65
Current Date: 2024-04-14 14:21:10 Functions: 100.0 % 2 2 2
Baseline: 16@8cea358b128 Branches: 60.7 % 84 51 33 51
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 % 65 65 65
Function coverage date bins:
(240..) days: 100.0 % 2 2 2
Branch coverage date bins:
(240..) days: 60.7 % 84 51 33 51

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : #include <stdlib.h>
                                  2                 :                : #include <string.h>
                                  3                 :                : #include <stdio.h>
                                  4                 :                : #include <time.h>
                                  5                 :                : 
                                  6                 :                : exec sql include ../regression;
                                  7                 :                : exec sql whenever sqlerror sqlprint;
                                  8                 :                : 
                                  9                 :                : static void
 1882 meskes@postgresql.or       10                 :CBC           9 : dump_binary(char *buf, int len, int ind)
                                 11                 :                : {
                                 12                 :                :     int i;
                                 13                 :                : 
                                 14                 :              9 :     printf("len=%d, ind=%d, data=0x", len, ind);
                                 15         [ +  + ]:           4578 :     for (i = 0; i < len; ++i)
                                 16                 :           4569 :         printf("%02x", 0xff & buf[i]);
                                 17                 :              9 :     printf("\n");
                                 18                 :              9 : }
                                 19                 :                : 
                                 20                 :                : #define DATA_SIZE 0x200
                                 21                 :                : #define LACK_SIZE 13
                                 22                 :                : #
                                 23                 :                : int
                                 24                 :              1 : main(void)
                                 25                 :                : {
                                 26                 :                : exec sql begin declare section;
                                 27                 :                :     bytea send_buf[2][512];
                                 28                 :                :     bytea recv_buf[2][DATA_SIZE];
                                 29                 :                :     bytea recv_vlen_buf[][DATA_SIZE];
                                 30                 :                :     bytea recv_short_buf[DATA_SIZE - LACK_SIZE];
                                 31                 :                :     int ind[2];
                                 32                 :                : exec sql end declare section;
                                 33                 :                :     int i, j, c;
                                 34                 :                : 
                                 35                 :                : #define init() { \
                                 36                 :                :     for (i = 0; i < 2; ++i) \
                                 37                 :                :     { \
                                 38                 :                :         memset(recv_buf[i].arr, 0x0, sizeof(recv_buf[i].arr)); \
                                 39                 :                :         recv_buf[i].len = 0; \
                                 40                 :                :         ind[i] = 0; \
                                 41                 :                :     } \
                                 42                 :                :     recv_vlen_buf = NULL, \
                                 43                 :                :     memset(recv_short_buf.arr, 0x0, sizeof(recv_short_buf.arr)); \
                                 44                 :                : } \
                                 45                 :                : while (0)
                                 46                 :                : 
                                 47                 :              1 :     ECPGdebug(1, stderr);
                                 48                 :                : 
                                 49         [ +  + ]:              3 :     for (i = 0; i < 2; ++i)
                                 50                 :                :     {
                                 51   [ +  +  +  + ]:           1026 :         for (j = 0, c = 0xff; (c == -1 ? c = 0xff : 1), j < DATA_SIZE; ++j, --c)
                                 52                 :           1024 :             send_buf[i].arr[j] = c;
                                 53                 :                : 
                                 54                 :              2 :         send_buf[i].len = DATA_SIZE;
                                 55                 :                :     }
                                 56                 :                : 
                                 57                 :              1 :     exec sql connect to REGRESSDB1;
                                 58         [ -  + ]:              1 : 
                                 59                 :              1 :     exec sql create table if not exists test (data1 bytea, data2 bytea);
                                 60         [ -  + ]:              1 : 
                                 61                 :              1 :     exec sql prepare ins_stmt from "insert into test values(?,?)";
                                 62         [ -  + ]:              1 :     exec sql prepare sel_stmt from "select data1,data2 from test";
                                 63         [ -  + ]:              1 :     exec sql allocate descriptor idesc;
                                 64         [ -  + ]:              1 :     exec sql allocate descriptor odesc;
                                 65         [ -  + ]:              1 : 
                                 66                 :                :     /* Test for static sql statement with normal host variable, indicator */
                                 67         [ +  + ]:              3 :     init();
                                 68                 :              1 :     exec sql truncate test;
                                 69         [ -  + ]:              1 :     exec sql insert into test values(:send_buf[0], :send_buf[1]);
                                 70         [ -  + ]:              1 :     exec sql select data1,data2 into :recv_buf[0]:ind[0], :recv_short_buf:ind[1] from test;
                                 71         [ -  + ]:              1 :     dump_binary(recv_buf[0].arr, recv_buf[0].len, ind[0]);
                                 72                 :              1 :     dump_binary(recv_short_buf.arr, recv_short_buf.len, ind[1]);
                                 73                 :                : 
                                 74                 :                :     /* Test for cursor */
 1384                            75         [ +  + ]:              3 :     init();
                                 76                 :              1 :     exec sql truncate test;
                                 77         [ -  + ]:              1 :     exec sql insert into test values(:send_buf[0], :send_buf[1]);
                                 78         [ -  + ]:              1 :     exec sql declare cursor1 cursor for select data1 from test where data1 = :send_buf[0];
                                 79         [ -  + ]:              1 :     exec sql open cursor1;
                                 80         [ -  + ]:              1 :     exec sql fetch from cursor1 INTO :recv_buf[0];
                                 81         [ -  + ]:              1 :     exec sql close cursor1;
                                 82         [ -  + ]:              1 :     exec sql free cursor1 ;
                                 83         [ +  - ]:              1 :     dump_binary(recv_buf[0].arr, recv_buf[0].len, 0);
                                 84                 :                : 
                                 85                 :                :     /* Test for variable length array */
 1882                            86         [ +  + ]:              3 :     init();
                                 87                 :              1 :     exec sql truncate test;
                                 88         [ -  + ]:              1 :     exec sql insert into test values(:send_buf[0], :send_buf[1]);
                                 89         [ -  + ]:              1 :     exec sql insert into test values(:send_buf[0], :send_buf[1]);
                                 90         [ -  + ]:              1 :     exec sql select data1 into :recv_vlen_buf from test;
                                 91         [ -  + ]:              1 :     dump_binary(recv_vlen_buf[0].arr, recv_vlen_buf[0].len, 0);
                                 92                 :              1 :     dump_binary(recv_vlen_buf[1].arr, recv_vlen_buf[1].len, 0);
 1874                            93                 :              1 :     free(recv_vlen_buf);
                                 94                 :                : 
                                 95                 :                :     /* Test for dynamic sql statement with normal host variable, indicator */
 1882                            96         [ +  + ]:              3 :     init();
                                 97                 :              1 :     exec sql truncate test;
                                 98         [ -  + ]:              1 :     exec sql execute ins_stmt using :send_buf[0], :send_buf[1];
                                 99         [ -  + ]:              1 :     exec sql execute sel_stmt into  :recv_buf[0]:ind[0], :recv_short_buf:ind[1];
                                100         [ -  + ]:              1 :     dump_binary(recv_buf[0].arr, recv_buf[0].len, ind[0]);
                                101                 :              1 :     dump_binary(recv_short_buf.arr, recv_short_buf.len, ind[1]);
                                102                 :                : 
                                103                 :                :     /* Test for dynamic sql statement with sql descriptor */
                                104         [ +  + ]:              3 :     init();
                                105                 :              1 :     exec sql truncate test;
                                106         [ -  + ]:              1 :     exec sql set descriptor idesc value 1 data = :send_buf[0];
                                107         [ -  + ]:              1 :     exec sql set descriptor idesc value 2 data = :send_buf[1];
                                108         [ -  + ]:              1 :     exec sql execute ins_stmt using sql descriptor idesc;
                                109         [ -  + ]:              1 :     exec sql execute sel_stmt into  sql descriptor odesc;
                                110         [ -  + ]:              1 :     exec sql get descriptor odesc value 1 :recv_buf[0] = data, :ind[0] = indicator;
                                111         [ -  + ]:              1 :     exec sql get descriptor odesc value 2 :recv_short_buf = data, :ind[1] = indicator;
                                112         [ -  + ]:              1 :     dump_binary(recv_buf[0].arr, recv_buf[0].len, ind[0]);
                                113                 :              1 :     dump_binary(recv_short_buf.arr, recv_short_buf.len, ind[1]);
                                114                 :                : 
                                115                 :              1 :     exec sql drop table test;
                                116         [ -  + ]:              1 :     exec sql commit;
                                117         [ -  + ]:              1 :     exec sql disconnect;
                                118         [ -  + ]:              1 : 
                                119                 :              1 :     return 0;
                                120                 :                : }
        

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