LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/compat_informix - test_informix.pgc (source / functions) Coverage Total Hit
Test: PostgreSQL 20devel Lines: 96.6 % 59 57
Test Date: 2026-07-25 22:15:46 Functions: 100.0 % 3 3
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 50.0 % 56 28

             Branch data     Line data    Source code
       1                 :             : #include "sqltypes.h"
       2                 :             : #include <stdlib.h>
       3                 :             : 
       4                 :             : $include ../regression;
       5                 :             : $define NUMBER 12;
       6                 :             : 
       7                 :             : static void openit(void);
       8                 :           4 : static void dosqlprint(void) {
       9                 :           4 :     printf("doSQLprint: Error: %s\n", sqlca.sqlerrm.sqlerrmc);
      10                 :           4 : }
      11                 :             : 
      12                 :           2 : int main(void)
      13                 :             : {
      14                 :           2 :     $int i = 14, loopcount;
      15                 :             :     $decimal j, m, n;
      16                 :             :     $string c[10];
      17                 :             : 
      18                 :           2 :     ECPGdebug(1, stderr);
      19                 :             :     $whenever sqlerror do dosqlprint();
      20                 :             : 
      21                 :           2 :     $connect to REGRESSDB1;
      22   [ -  +  -  + ]:           2 :     if (sqlca.sqlcode != 0) exit(1);
      23                 :             : 
      24                 :           2 :     $create table test(i int primary key, j int, c text);
      25         [ -  + ]:           2 : 
      26                 :             :     /* this INSERT works */
      27                 :           2 :     rsetnull(CDECIMALTYPE, (char *)&j);
      28                 :           2 :     $insert into test (i, j, c) values (7, :j, 'test   ');
      29         [ -  + ]:           2 :     $commit;
      30         [ -  + ]:           2 : 
      31                 :             :     /* this INSERT should fail because i is a unique column */
      32                 :           2 :     $insert into test (i, j, c) values (7, NUMBER, 'a');
      33         [ +  - ]:           2 :     printf("INSERT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
      34         [ +  - ]:           2 :     if (sqlca.sqlcode != 0) $rollback;
      35         [ -  + ]:           2 : 
      36                 :           2 :     $insert into test (i, j, c) values (:i, 1, 'a      ');
      37         [ -  + ]:           2 :     $commit;
      38         [ -  + ]:           2 : 
      39                 :             :     /* this will fail (more than one row in subquery) */
      40                 :           2 :     $select i from test where j=(select j from test);
      41         [ +  - ]:           2 :     $rollback;
      42         [ -  + ]:           2 : 
      43                 :             :     /* this however should be ok */
      44                 :           2 :     $select i from test where j=(select j from test order by i limit 1);
      45         [ -  + ]:           2 :     printf("SELECT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
      46         [ -  + ]:           2 :     if (sqlca.sqlcode != 0) $rollback;
      47         [ #  # ]:           0 : 
      48                 :           2 :     sqlca.sqlcode = 100;
      49                 :           2 :     $declare c cursor for select * from test where i <= :i;
      50         [ -  + ]:           2 :     printf ("%ld\n", sqlca.sqlcode);
      51                 :           2 :     openit();
      52                 :             : 
      53                 :           2 :     deccvint(0, &j);
      54                 :             : 
      55         [ +  - ]:           6 :     for (loopcount = 0; loopcount < 100; loopcount++)
      56                 :             :     {
      57                 :           6 :         $fetch forward c into :i, :j, :c;
      58   [ -  +  +  + ]:           6 :         if (sqlca.sqlcode == 100) break;
      59                 :             : 
      60         [ -  + ]:           4 :         if (risnull(CDECIMALTYPE, (char *)&j))
      61                 :           0 :             printf("%d NULL\n", i);
      62                 :             :         else
      63                 :             :         {
      64                 :             :             int a;
      65                 :             : 
      66                 :           4 :             dectoint(&j, &a);
      67                 :           4 :             printf("%d %d \"%s\"\n", i, a, c);
      68                 :             :         }
      69                 :             :     }
      70                 :             : 
      71                 :           2 :     deccvint(7, &j);
      72                 :           2 :     deccvint(14, &m);
      73                 :           2 :     decadd(&j, &m, &n);
      74                 :           2 :     $delete from test where i= :n::decimal;
      75         [ -  + ]:           2 :     printf("DELETE: %ld\n", sqlca.sqlcode);
      76                 :             : 
      77                 :           2 :     $select 1 from test where i=14;
      78         [ -  + ]:           2 :     printf("Exists: %ld\n", sqlca.sqlcode);
      79                 :             : 
      80                 :           2 :     $select 1 from test where i=147;
      81         [ -  + ]:           2 :     printf("Does not exist: %ld\n", sqlca.sqlcode);
      82                 :             : 
      83                 :           2 :     $commit;
      84         [ -  + ]:           2 :     $drop table test;
      85         [ -  + ]:           2 :     $commit;
      86         [ -  + ]:           2 : 
      87                 :           2 :     $close database;
      88         [ -  + ]:           2 : 
      89                 :           2 :     return 0;
      90                 :             : }
      91                 :             : 
      92                 :           2 : static void openit(void)
      93                 :             : {
      94                 :           2 :     $open c;
      95         [ -  + ]:           4 : }
        

Generated by: LCOV version 2.0-1