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

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : #include <stdlib.h>
                                  2                 :                : #include <string.h>
                                  3                 :                : #include <stdlib.h>
                                  4                 :                : #include <stdio.h>
                                  5                 :                : 
                                  6                 :                : exec sql include ../regression;
                                  7                 :                : 
                                  8                 :                : exec sql whenever sqlerror sqlprint;
                                  9                 :                : 
                                 10                 :                : int
 6088 meskes@postgresql.or       11                 :CBC           1 : main(void)
                                 12                 :                : {
                                 13                 :                : exec sql begin declare section;
                                 14                 :                :     int amount[8];
                                 15                 :              1 :     int increment=100;
                                 16                 :                :     char name[8][8];
                                 17                 :                :     char letter[8][1];
                                 18                 :                :     char command[128];
                                 19                 :                : exec sql end declare section;
                                 20                 :                :     int i,j;
                                 21                 :                : 
                                 22                 :              1 :     ECPGdebug(1, stderr);
                                 23                 :                : 
                                 24                 :              1 :     exec sql connect to REGRESSDB1 as main;
 3351                            25         [ -  + ]:              1 : 
 6088                            26                 :              1 :     exec sql create table test (name char(8), amount int, letter char(1));
                                 27         [ -  + ]:              1 :     exec sql commit;
                                 28         [ -  + ]:              1 : 
                                 29                 :              1 :     sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')");
                                 30                 :              1 :     exec sql execute immediate :command;
                                 31         [ -  + ]:              1 : 
                                 32                 :              1 :     sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')");
                                 33                 :              1 :     exec sql execute immediate :command;
                                 34         [ -  + ]:              1 : 
                                 35                 :              1 :     sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test");
                                 36                 :              1 :     exec sql execute immediate :command;
                                 37         [ -  + ]:              1 : 
                                 38                 :              1 :     printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]);
                                 39                 :                : 
                                 40                 :              1 :     sprintf(command, "insert into test (name, amount, letter) select name, amount+$1, letter from test");
                                 41                 :              1 :     exec sql prepare I from :command;
                                 42         [ -  + ]:              1 :     exec sql execute I using :increment;
                                 43         [ -  + ]:              1 : 
                                 44                 :              1 :     printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]);
                                 45                 :                : 
                                 46                 :              1 :     exec sql commit;
                                 47         [ -  + ]:              1 : 
                                 48                 :              1 :     sprintf (command, "select * from test");
                                 49                 :                : 
                                 50                 :              1 :     exec sql prepare F from :command;
                                 51         [ -  + ]:              1 :     exec sql declare CUR cursor for F;
                                 52                 :                : 
                                 53                 :              1 :     exec sql open CUR;
                                 54         [ -  + ]:              1 :     exec sql fetch 8 in CUR into :name, :amount, :letter;
                                 55         [ -  + ]:              1 : 
                                 56         [ +  + ]:              9 :     for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
                                 57                 :                :     {
                                 58                 :              8 :         char n[8], l = letter[i][0];
                                 59                 :              8 :         int a = amount[i];
                                 60                 :                : 
                                 61                 :              8 :         strncpy(n, name[i], 8);
                                 62                 :              8 :         printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
                                 63                 :                :     }
                                 64                 :                : 
                                 65                 :              1 :     exec sql close CUR;
                                 66         [ -  + ]:              1 : 
                                 67                 :              1 :     sprintf (command, "select * from test where ? = amount");
                                 68                 :                : 
                                 69                 :              1 :     exec sql prepare F from :command;
                                 70         [ -  + ]:              1 :     exec sql declare CUR3 cursor for F;
                                 71                 :                : 
                                 72                 :              1 :     exec sql open CUR3 using 1;
                                 73         [ -  + ]:              1 :     exec sql fetch in CUR3 into :name, :amount, :letter;
                                 74         [ -  + ]:              1 : 
                                 75         [ +  + ]:              2 :     for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
                                 76                 :                :     {
                                 77                 :              1 :         char n[8], l = letter[i][0];
                                 78                 :              1 :         int a = amount[i];
                                 79                 :                : 
                                 80                 :              1 :         strncpy(n, name[i], 8);
                                 81                 :              1 :         printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
                                 82                 :                :     }
                                 83                 :                : 
                                 84                 :              1 :     exec sql close CUR3;
                                 85         [ -  + ]:              1 :     exec sql drop table test;
                                 86         [ -  + ]:              1 :     exec sql commit;
                                 87         [ -  + ]:              1 :     exec sql disconnect;
                                 88         [ -  + ]:              1 : 
 2432 peter_e@gmx.net            89                 :              1 :     return 0;
                                 90                 :                : }
        

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