LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/sql - array.pgc (source / functions) Coverage Total Hit
Test: Code coverage Lines: 0.0 % 77 0
Test Date: 2026-01-26 10:56:24 Functions: 0.0 % 1 0
Legend: Lines:     hit not hit

            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
      16            0 : main (void)
      17              : {
      18              : EXEC SQL BEGIN DECLARE SECTION;
      19            0 :         int i = 1, j;
      20            0 :         int *did = &i;
      21            0 :         short a[10] = {9,8,7,6,5,4,3,2,1,0};
      22            0 :         timestamp ts[10];
      23            0 :         date d[10];
      24            0 :         interval in[10];
      25            0 :         numeric n[10];
      26            0 :         char text[25] = "klmnopqrst";
      27            0 :         char *t = (char *)malloc(11);
      28            0 :         double f;
      29              : EXEC SQL END DECLARE SECTION;
      30              : 
      31            0 :         strcpy(t, "0123456789");
      32            0 :         setlocale(LC_ALL, "C");
      33              : 
      34            0 :         ECPGdebug(1, stderr);
      35              : 
      36            0 :         for (j = 0; j < 10; j++) {
      37            0 :                 char str[28];
      38            0 :                 numeric *value;
      39            0 :                 interval *inter;
      40              : 
      41            0 :                 sprintf(str, "2000-1-1 0%d:00:00", j);
      42            0 :                 ts[j] = PGTYPEStimestamp_from_asc(str, NULL);
      43            0 :                 sprintf(str, "2000-1-1%d\n", j);
      44            0 :                 d[j] = PGTYPESdate_from_asc(str, NULL);
      45            0 :                 sprintf(str, "%d hours", j+10);
      46            0 :                 inter = PGTYPESinterval_from_asc(str, NULL);
      47            0 :                 in[j] = *inter;
      48            0 :                 value = PGTYPESnumeric_new();
      49            0 :                 PGTYPESnumeric_from_int(j, value);
      50            0 :                 n[j] = *value;
      51            0 :         }
      52              : 
      53            0 :         EXEC SQL CONNECT TO REGRESSDB1;
      54            0 : 
      55            0 :         EXEC SQL SET AUTOCOMMIT = ON;
      56            0 : 
      57            0 :         EXEC SQL BEGIN WORK;
      58            0 : 
      59            0 :         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]);
      60            0 : 
      61            0 :         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);
      62            0 : 
      63            0 :         EXEC SQL INSERT INTO test(f,i,a,text,ts,n,d,inter) VALUES(140787.0,2,:a,:text,:ts,:n,:d,:in);
      64            0 : 
      65            0 :         EXEC SQL INSERT INTO test(f,i,a,text,ts,n,d,inter) VALUES(14.07,:did,:a,:t,:ts,:n,:d,:in);
      66            0 : 
      67            0 :         EXEC SQL COMMIT;
      68            0 : 
      69            0 :         for (j = 0; j < 10; j++) {
      70            0 :                 ts[j] = PGTYPEStimestamp_from_asc("1900-01-01 00:00:00", NULL);
      71            0 :                 d[j] = PGTYPESdate_from_asc("1900-01-01", NULL);
      72            0 :                 in[j] = *PGTYPESinterval_new();
      73            0 :                 n[j] = *PGTYPESnumeric_new();
      74            0 :         }
      75            0 :         EXEC SQL BEGIN WORK;
      76            0 : 
      77            0 :         EXEC SQL SELECT f,text
      78              :          INTO :f,:text
      79              :          FROM test
      80            0 :          WHERE i = 1;
      81            0 : 
      82            0 :         printf("Found f=%f text=%10.10s\n", f, text);
      83              : 
      84            0 :         f=140787;
      85            0 :         EXEC SQL SELECT a,text,ts,n,d,inter
      86              :          INTO :a,:t,:ts,:n,:d,:in
      87              :          FROM test
      88            0 :          WHERE f = :f;
      89            0 : 
      90            0 :         for (i = 0; i < 10; i++)
      91            0 :                 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              : 
      93            0 :         printf("Found text=%10.10s\n", t);
      94              : 
      95            0 :         EXEC SQL SELECT a
      96              :          INTO :text
      97              :          FROM test
      98            0 :          WHERE f = :f;
      99            0 : 
     100            0 :         printf("Found text=%s\n", text);
     101              : 
     102            0 :         EXEC SQL DROP TABLE test;
     103            0 : 
     104            0 :         EXEC SQL COMMIT;
     105            0 : 
     106            0 :         EXEC SQL DISCONNECT;
     107            0 : 
     108            0 :         free(t);
     109              : 
     110            0 :         return 0;
     111            0 : }
        

Generated by: LCOV version 2.3.2-1