LCOV - differential code coverage report
Current view: top level - src/interfaces/ecpg/test/sql - array.pgc (source / functions) Coverage Total Hit CBC
Current: Differential Code Coverage HEAD vs 15 Lines: 100.0 % 63 63 63
Current Date: 2023-04-08 17:13:01 Functions: 100.0 % 1 1 1
Baseline: 15 Line coverage date bins:
Baseline Date: 2023-04-08 15:09:40 (240..) days: 100.0 % 63 63 63
Legend: Lines: hit not hit Function coverage date bins:
(240..) days: 100.0 % 1 1 1

 Age         Owner                  TLA  Line data    Source code
                                  1                 : #include <locale.h>
                                  2                 : #include <string.h>
                                  3                 : #include <stdlib.h>
                                  4                 : 
                                  5                 : #include <pgtypes_date.h>
                                  6                 : #include <pgtypes_interval.h>
                                  7                 : #include <pgtypes_numeric.h>
                                  8                 : #include <pgtypes_timestamp.h>
                                  9                 : 
                                 10                 : exec sql whenever sqlerror sqlprint;
                                 11                 : 
                                 12                 : exec sql include sqlca;
                                 13                 : exec sql include ../regression;
                                 14                 : 
                                 15                 : int
 6094 meskes                     16 CBC           1 : main (void)
                                 17                 : {
                                 18                 : EXEC SQL BEGIN DECLARE SECTION;
 2980                            19               1 :     int i = 1, j;
 6094                            20               1 :     int *did = &i;
 2980                            21               1 :     short a[10] = {9,8,7,6,5,4,3,2,1,0};
                                 22                 :     timestamp ts[10];
                                 23                 :     date d[10];
                                 24                 :     interval in[10];
                                 25                 :     numeric n[10];
 6094                            26               1 :     char text[25] = "klmnopqrst";
 6078                            27               1 :     char *t = (char *)malloc(11);
                                 28                 :     double f;
                                 29                 : EXEC SQL END DECLARE SECTION;
                                 30                 : 
 6094                            31               1 :     strcpy(t, "0123456789");
 6091                            32               1 :     setlocale(LC_ALL, "C");
                                 33                 : 
 6094                            34               1 :     ECPGdebug(1, stderr);
                                 35                 : 
 2980                            36              11 :     for (j = 0; j < 10; j++) {
                                 37                 :         char str[28];
                                 38                 :         numeric *value;
                                 39                 :         interval *inter;
                                 40                 : 
                                 41              10 :         sprintf(str, "2000-1-1 0%d:00:00", j);
                                 42              10 :         ts[j] = PGTYPEStimestamp_from_asc(str, NULL);
                                 43              10 :         sprintf(str, "2000-1-1%d\n", j);
                                 44              10 :         d[j] = PGTYPESdate_from_asc(str, NULL);
                                 45              10 :         sprintf(str, "%d hours", j+10);
                                 46              10 :         inter = PGTYPESinterval_from_asc(str, NULL);
                                 47              10 :         in[j] = *inter;
                                 48              10 :         value = PGTYPESnumeric_new();
                                 49              10 :         PGTYPESnumeric_from_int(j, value);
                                 50              10 :         n[j] = *value;
                                 51                 :     }
                                 52                 : 
 6094                            53               1 :         EXEC SQL CONNECT TO REGRESSDB1;
                                 54               1 : 
                                 55               1 :     EXEC SQL SET AUTOCOMMIT = ON;
                                 56               1 : 
 4520 peter_e                    57               1 :     EXEC SQL BEGIN WORK;
 6094 meskes                     58               1 : 
 2980                            59               1 :     EXEC SQL CREATE TABLE test (f float, i int, a int[10], text char(10), ts timestamp[10], n numeric[10], d date[10], inter interval[10]);
 6094                            60               1 : 
 2980                            61               1 :     EXEC SQL INSERT INTO test(f,i,a,text,ts,n,d,inter) VALUES(404.90,3,'{0,1,2,3,4,5,6,7,8,9}','abcdefghij',:ts,:n,:d,:in);
 6094                            62               1 : 
 2980                            63               1 :     EXEC SQL INSERT INTO test(f,i,a,text,ts,n,d,inter) VALUES(140787.0,2,:a,:text,:ts,:n,:d,:in);
 5717                            64               1 : 
 2980                            65               1 :     EXEC SQL INSERT INTO test(f,i,a,text,ts,n,d,inter) VALUES(14.07,:did,:a,:t,:ts,:n,:d,:in);
 6094                            66               1 : 
                                 67               1 :     EXEC SQL COMMIT;
                                 68               1 : 
 2980                            69              11 :     for (j = 0; j < 10; j++) {
                                 70              10 :         ts[j] = PGTYPEStimestamp_from_asc("1900-01-01 00:00:00", NULL);
                                 71              10 :         d[j] = PGTYPESdate_from_asc("1900-01-01", NULL);
                                 72              10 :         in[j] = *PGTYPESinterval_new();
                                 73              10 :         n[j] = *PGTYPESnumeric_new();
                                 74                 :     }
 4520 peter_e                    75               1 :     EXEC SQL BEGIN WORK;
 6094 meskes                     76               1 : 
 6060                            77               1 :     EXEC SQL SELECT f,text
                                 78                 :          INTO :f,:text
                                 79                 :          FROM test
                                 80                 :          WHERE i = 1;
 6094                            81               1 : 
 6060                            82               1 :     printf("Found f=%f text=%10.10s\n", f, text);
                                 83                 : 
 6094                            84               1 :     f=140787;
 2980                            85               1 :     EXEC SQL SELECT a,text,ts,n,d,inter
                                 86                 :      INTO :a,:t,:ts,:n,:d,:in
                                 87                 :      FROM test
                                 88                 :      WHERE f = :f;
 6094                            89               1 : 
                                 90              11 :     for (i = 0; i < 10; i++)
 2980                            91              10 :         printf("Found a[%d] = %d ts[%d] = %s n[%d] = %s d[%d] = %s in[%d] = %s\n", i, a[i], i, PGTYPEStimestamp_to_asc(ts[i]), i, PGTYPESnumeric_to_asc(&(n[i]), -1), i, PGTYPESdate_to_asc(d[i]), i, PGTYPESinterval_to_asc(&(in[i])));
                                 92                 : 
 6094                            93               1 :     printf("Found text=%10.10s\n", t);
                                 94                 : 
                                 95               1 :     EXEC SQL SELECT a
                                 96                 :      INTO :text
                                 97                 :      FROM test
                                 98                 :      WHERE f = :f;
                                 99               1 : 
                                100               1 :     printf("Found text=%s\n", text);
                                101                 : 
                                102               1 :     EXEC SQL DROP TABLE test;
                                103               1 : 
                                104               1 :     EXEC SQL COMMIT;
                                105               1 : 
                                106               1 :     EXEC SQL DISCONNECT;
                                107               1 : 
 4618                           108               1 :     free(t);
                                109                 : 
 2061 peter_e                   110               1 :     return 0;
                                111                 : }
        

Generated by: LCOV version v1.16-55-g56c0a2a