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

 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
 6428 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;
                                 25         [ -  + ]:              1 :     exec sql create table test (name char(8), amount int, letter char(1));
                                 26         [ -  + ]:              1 :     exec sql commit;
                                 27         [ -  + ]:              1 : 
                                 28                 :                :     /* test handling of embedded quotes in EXECUTE IMMEDIATE "literal" */
 1270 tgl@sss.pgh.pa.us          29                 :              1 :     exec sql execute immediate "insert into test (name, \042amount\042, letter) values ('db: ''r1''', 1, 'f')";
 6428 meskes@postgresql.or       30         [ -  + ]:              1 : 
                                 31                 :              1 :     sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')");
                                 32                 :              1 :     exec sql execute immediate :command;
                                 33         [ -  + ]:              1 : 
                                 34                 :              1 :     sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test");
                                 35                 :              1 :     exec sql execute immediate :command;
                                 36         [ -  + ]:              1 : 
                                 37                 :              1 :     printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]);
                                 38                 :                : 
 6088                            39                 :              1 :     sprintf(command, "insert into test (name, amount, letter) select name, amount+$1, letter from test");
 6428                            40                 :              1 :     exec sql prepare I from :command;
                                 41         [ -  + ]:              1 :     exec sql execute I using :increment;
                                 42         [ -  + ]:              1 : 
                                 43                 :              1 :     printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]);
                                 44                 :                : 
                                 45                 :              1 :     exec sql commit;
                                 46         [ -  + ]:              1 : 
                                 47                 :              1 :     sprintf (command, "select * from test");
                                 48                 :                : 
 6088                            49                 :              1 :     exec sql prepare f from :command;
                                 50         [ -  + ]:              1 :     exec sql declare CUR cursor for f;
                                 51                 :                : 
 6428                            52                 :              1 :     exec sql open CUR;
                                 53         [ -  + ]:              1 :     exec sql fetch 8 in CUR into :name, :amount, :letter;
                                 54         [ -  + ]:              1 : 
                                 55         [ +  + ]:              9 :     for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
                                 56                 :                :     {
                                 57                 :                :         exec sql begin declare section;
                                 58                 :              8 :         char n[8], l = letter[i][0];
                                 59                 :              8 :         int a = amount[i];
                                 60                 :                :         exec sql end declare section;
                                 61                 :                : 
                                 62                 :              8 :         strncpy(n, name[i], 8);
                                 63                 :              8 :         printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
                                 64                 :                :     }
                                 65                 :                : 
                                 66                 :              1 :     exec sql close CUR;
 6088                            67         [ -  + ]:              1 :     exec sql deallocate f;
 6428                            68         [ -  + ]:              1 : 
 6088                            69                 :              1 :     sprintf (command, "select * from test where amount = $1");
                                 70                 :                : 
                                 71                 :              1 :     exec sql prepare f from :command;
                                 72         [ -  + ]:              1 :     exec sql declare CUR2 cursor for f;
                                 73                 :                : 
 6428                            74                 :              1 :     exec sql open CUR2 using 1;
                                 75         [ -  + ]:              1 :     exec sql fetch in CUR2 into :name, :amount, :letter;
                                 76         [ -  + ]:              1 : 
                                 77         [ +  + ]:              2 :     for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
                                 78                 :                :     {
                                 79                 :                :         exec sql begin declare section;
                                 80                 :              1 :         char n[8], l = letter[i][0];
                                 81                 :              1 :         int a = amount[i];
                                 82                 :                :         exec sql end declare section;
                                 83                 :                : 
                                 84                 :              1 :         strncpy(n, name[i], 8);
                                 85                 :              1 :         printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
                                 86                 :                :     }
                                 87                 :                : 
                                 88                 :              1 :     exec sql close CUR2;
 5904                            89         [ -  + ]:              1 :     exec sql deallocate f;
                                 90         [ -  + ]:              1 : 
                                 91                 :              1 :     sprintf (command, "select * from test where amount = $1");
                                 92                 :                : 
                                 93                 :              1 :     exec sql prepare f from :command;
                                 94         [ -  + ]:              1 :     exec sql execute f using 2 into :name, :amount, :letter;
                                 95         [ -  + ]:              1 : 
                                 96         [ +  + ]:              2 :     for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
                                 97                 :                :     {
                                 98                 :                :         exec sql begin declare section;
                                 99                 :              1 :         char n[8], l = letter[i][0];
                                100                 :              1 :         int a = amount[i];
                                101                 :                :         exec sql end declare section;
                                102                 :                : 
                                103                 :              1 :         strncpy(n, name[i], 8);
                                104                 :              1 :         printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
                                105                 :                :     }
                                106                 :                : 
                                107                 :              1 :     exec sql deallocate f;
 6428                           108         [ -  + ]:              1 :     exec sql drop table test;
                                109         [ -  + ]:              1 :     exec sql commit;
                                110         [ -  + ]:              1 :     exec sql disconnect;
                                111         [ -  + ]:              1 : 
 2432 peter_e@gmx.net           112                 :              1 :     return 0;
                                113                 :                : }
        

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