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

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : #include <stdlib.h>
                                  2                 :                : #include <string.h>
                                  3                 :                : 
                                  4                 :                : exec sql include ../regression;
                                  5                 :                : 
                                  6                 :                : exec sql whenever sqlerror stop;
                                  7                 :                : 
                                  8                 :                : exec sql type c is char reference;
                                  9                 :                : typedef char* c;
                                 10                 :                : 
                                 11                 :                : exec sql type ind is union { int integer; short smallint; };
                                 12                 :                : typedef union { int integer; short smallint; } ind;
                                 13                 :                : 
                                 14                 :                : #define BUFFERSIZ 8
                                 15                 :                : exec sql type str is varchar[BUFFERSIZ];
                                 16                 :                : 
                                 17                 :                : #define CURNAME "mycur"
                                 18                 :                : 
                                 19                 :                : int
 5253 meskes@postgresql.or       20                 :CBC           1 : main (void)
                                 21                 :                : {
                                 22                 :                : exec sql begin declare section;
                                 23                 :              1 :     char    *stmt1 = "SELECT id, t FROM t1";
                                 24                 :              1 :     char    *curname1 = CURNAME;
                                 25                 :              1 :     char    *curname2 = CURNAME;
                                 26                 :              1 :     char    *curname3 = CURNAME;
                                 27                 :                :     varchar curname4[50];
 4501                            28                 :              1 :     char    *curname5 = CURNAME;
                                 29                 :                :     int count;
                                 30                 :                :     int id;
                                 31                 :                :     char    t[64];
                                 32                 :                : exec sql end declare section;
                                 33                 :                : 
                                 34                 :                :     char msg[128];
                                 35                 :                : 
 5253                            36                 :              1 :     ECPGdebug(1, stderr);
                                 37                 :                : 
                                 38                 :              1 :     strcpy(msg, "connect");
 4501                            39                 :              1 :     exec sql connect to REGRESSDB1 as test1;
                                 40         [ -  + ]:              1 :     exec sql connect to REGRESSDB2 as test2;
 5253                            41         [ -  + ]:              1 : 
                                 42                 :              1 :     strcpy(msg, "set");
 4501                            43                 :              1 :     exec sql at test1 set datestyle to iso;
 5253                            44         [ -  + ]:              1 : 
                                 45                 :              1 :     strcpy(msg, "create");
 4501                            46                 :              1 :     exec sql at test1 create table t1(id serial primary key, t text);
                                 47         [ -  + ]:              1 :     exec sql at test2 create table t1(id serial primary key, t text);
 5253                            48         [ -  + ]:              1 : 
                                 49                 :              1 :     strcpy(msg, "insert");
 4501                            50                 :              1 :     exec sql at test1 insert into t1(id, t) values (default, 'a');
                                 51         [ -  + ]:              1 :     exec sql at test1 insert into t1(id, t) values (default, 'b');
                                 52         [ -  + ]:              1 :     exec sql at test1 insert into t1(id, t) values (default, 'c');
                                 53         [ -  + ]:              1 :     exec sql at test1 insert into t1(id, t) values (default, 'd');
                                 54         [ -  + ]:              1 :     exec sql at test2 insert into t1(id, t) values (default, 'e');
 5253                            55         [ -  + ]:              1 : 
                                 56                 :              1 :     strcpy(msg, "commit");
 4501                            57                 :              1 :     exec sql at test1 commit;
                                 58         [ -  + ]:              1 :     exec sql at test2 commit;
 5253                            59         [ -  + ]:              1 : 
                                 60                 :                :     /* Dynamic cursorname test with INTO list in FETCH stmts */
                                 61                 :                : 
                                 62                 :              1 :     strcpy(msg, "declare");
 4501                            63                 :              1 :     exec sql at test1 declare :curname1 cursor for
                                 64                 :                :         select id, t from t1;
 5253                            65         [ -  + ]:              1 : 
                                 66                 :              1 :     strcpy(msg, "open");
 4501                            67                 :              1 :     exec sql at test1 open :curname1;
 5253                            68         [ -  + ]:              1 : 
                                 69                 :              1 :     strcpy(msg, "fetch from");
 4501                            70                 :              1 :     exec sql at test1 fetch forward from :curname1 into :id, :t;
 5253                            71         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                 72                 :                : 
                                 73                 :              1 :     strcpy(msg, "fetch");
 4501                            74                 :              1 :     exec sql at test1 fetch forward :curname1 into :id, :t;
 5253                            75         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                 76                 :                : 
                                 77                 :              1 :     strcpy(msg, "fetch 1 from");
 4501                            78                 :              1 :     exec sql at test1 fetch 1 from :curname1 into :id, :t;
 5253                            79         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                 80                 :                : 
                                 81                 :              1 :     strcpy(msg, "fetch :count from");
                                 82                 :              1 :     count = 1;
 4501                            83                 :              1 :     exec sql at test1 fetch :count from :curname1 into :id, :t;
 5253                            84         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                 85                 :                : 
                                 86                 :              1 :     strcpy(msg, "move in");
 4501                            87                 :              1 :     exec sql at test1 move absolute 0 in :curname1;
 5253                            88         [ -  + ]:              1 : 
                                 89                 :              1 :     strcpy(msg, "fetch 1");
 4501                            90                 :              1 :     exec sql at test1 fetch 1 :curname1 into :id, :t;
 5253                            91         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                 92                 :                : 
                                 93                 :              1 :     strcpy(msg, "fetch :count");
                                 94                 :              1 :     count = 1;
 4501                            95                 :              1 :     exec sql at test1 fetch :count :curname1 into :id, :t;
 5253                            96         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                 97                 :                : 
                                 98                 :              1 :     strcpy(msg, "close");
 4501                            99                 :              1 :     exec sql at test1 close :curname1;
 5253                           100         [ -  + ]:              1 : 
                                101                 :                :     /* Dynamic cursorname test with INTO list in DECLARE stmt */
                                102                 :                : 
                                103                 :              1 :     strcpy(msg, "declare");
 4501                           104                 :              1 :     exec sql at test1 declare :curname2 cursor for
 5253                           105                 :              1 :         select id, t into :id, :t from t1;
                                106         [ -  + ]:              1 : 
                                107                 :              1 :     strcpy(msg, "open");
 4501                           108                 :              1 :     exec sql at test1 open :curname2;
 5253                           109         [ -  + ]:              1 : 
                                110                 :              1 :     strcpy(msg, "fetch from");
 4501                           111                 :              1 :     exec sql at test1 fetch from :curname2;
 5253                           112         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                113                 :                : 
                                114                 :              1 :     strcpy(msg, "fetch");
 4501                           115                 :              1 :     exec sql at test1 fetch :curname2;
 5253                           116         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                117                 :                : 
                                118                 :              1 :     strcpy(msg, "fetch 1 from");
 4501                           119                 :              1 :     exec sql at test1 fetch 1 from :curname2;
 5253                           120         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                121                 :                : 
                                122                 :              1 :     strcpy(msg, "fetch :count from");
                                123                 :              1 :     count = 1;
 4501                           124                 :              1 :     exec sql at test1 fetch :count from :curname2;
 5253                           125         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                126                 :                : 
                                127                 :              1 :     strcpy(msg, "move");
 4501                           128                 :              1 :     exec sql at test1 move absolute 0 :curname2;
 5253                           129         [ -  + ]:              1 : 
                                130                 :              1 :     strcpy(msg, "fetch 1");
 4501                           131                 :              1 :     exec sql at test1 fetch 1 :curname2;
 5253                           132         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                133                 :                : 
                                134                 :              1 :     strcpy(msg, "fetch :count");
                                135                 :              1 :     count = 1;
 4501                           136                 :              1 :     exec sql at test1 fetch :count :curname2;
 5253                           137         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                138                 :                : 
                                139                 :              1 :     strcpy(msg, "close");
 4501                           140                 :              1 :     exec sql at test1 close :curname2;
 5253                           141         [ -  + ]:              1 : 
                                142                 :                :     /* Dynamic cursorname test with PREPARED stmt */
                                143                 :                : 
                                144                 :              1 :     strcpy(msg, "prepare");
 4501                           145                 :              1 :     exec sql at test1 prepare st_id1 from :stmt1;
                                146         [ -  + ]:              1 :     exec sql at test2 prepare st_id1 from :stmt1;
 5253                           147         [ -  + ]:              1 : 
                                148                 :              1 :     strcpy(msg, "declare");
 4501                           149                 :              1 :     exec sql at test1 declare :curname3 cursor for st_id1;
                                150         [ -  + ]:              1 :     exec sql at test2 declare :curname5 cursor for st_id1;
 5253                           151         [ -  + ]:              1 : 
                                152                 :              1 :     strcpy(msg, "open");
 4501                           153                 :              1 :     exec sql at test1 open :curname3;
                                154         [ -  + ]:              1 :     exec sql at test2 open :curname5;
 5253                           155         [ -  + ]:              1 : 
 4501                           156                 :              1 :     strcpy(msg, "fetch");
                                157                 :              1 :     exec sql at test2 fetch :curname5 into :id, :t;
 5253                           158         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                159                 :                : 
 4501                           160                 :              1 :     strcpy(msg, "fetch from");
                                161                 :              1 :     exec sql at test1 fetch from :curname3 into :id, :t;
 5253                           162         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                163                 :                : 
                                164                 :              1 :     strcpy(msg, "fetch 1 from");
 4501                           165                 :              1 :     exec sql at test1 fetch 1 from :curname3 into :id, :t;
 5253                           166         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                167                 :                : 
                                168                 :              1 :     strcpy(msg, "fetch :count from");
                                169                 :              1 :     count = 1;
 4501                           170                 :              1 :     exec sql at test1 fetch :count from :curname3 into :id, :t;
 5253                           171         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                172                 :                : 
                                173                 :              1 :     strcpy(msg, "move");
 4501                           174                 :              1 :     exec sql at test1 move absolute 0 :curname3;
 5253                           175         [ -  + ]:              1 : 
                                176                 :              1 :     strcpy(msg, "fetch 1");
 4501                           177                 :              1 :     exec sql at test1 fetch 1 :curname3 into :id, :t;
 5253                           178         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                179                 :                : 
                                180                 :              1 :     strcpy(msg, "fetch :count");
                                181                 :              1 :     count = 1;
 4501                           182                 :              1 :     exec sql at test1 fetch :count :curname3 into :id, :t;
 5253                           183         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                184                 :                : 
                                185                 :              1 :     strcpy(msg, "close");
 4501                           186                 :              1 :     exec sql at test1 close :curname3;
                                187         [ -  + ]:              1 :     exec sql at test2 close :curname5;
 5253                           188         [ -  + ]:              1 : 
                                189                 :              1 :     strcpy(msg, "deallocate prepare");
 4501                           190                 :              1 :     exec sql at test1 deallocate prepare st_id1;
                                191         [ -  + ]:              1 :     exec sql at test2 deallocate prepare st_id1;
 5253                           192         [ -  + ]:              1 : 
                                193                 :                :     /* Dynamic cursorname test with PREPARED stmt,
                                194                 :                :        cursor name in varchar */
                                195                 :                : 
                                196                 :              1 :     curname4.len = strlen(CURNAME);
                                197                 :              1 :     strcpy(curname4.arr, CURNAME);
                                198                 :                : 
                                199                 :              1 :     strcpy(msg, "prepare");
 4501                           200                 :              1 :     exec sql at test1 prepare st_id2 from :stmt1;
 5253                           201         [ -  + ]:              1 : 
                                202                 :              1 :     strcpy(msg, "declare");
 4501                           203                 :              1 :     exec sql at test1 declare :curname4 cursor for st_id2;
 5253                           204         [ -  + ]:              1 : 
                                205                 :              1 :     strcpy(msg, "open");
 4501                           206                 :              1 :     exec sql at test1 open :curname4;
 5253                           207         [ -  + ]:              1 : 
                                208                 :              1 :     strcpy(msg, "fetch from");
 4501                           209                 :              1 :     exec sql at test1 fetch from :curname4 into :id, :t;
 5253                           210         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                211                 :                : 
                                212                 :              1 :     strcpy(msg, "fetch");
 4501                           213                 :              1 :     exec sql at test1 fetch :curname4 into :id, :t;
 5253                           214         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                215                 :                : 
                                216                 :              1 :     strcpy(msg, "fetch 1 from");
 4501                           217                 :              1 :     exec sql at test1 fetch 1 from :curname4 into :id, :t;
 5253                           218         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                219                 :                : 
                                220                 :              1 :     strcpy(msg, "fetch :count from");
                                221                 :              1 :     count = 1;
 4501                           222                 :              1 :     exec sql at test1 fetch :count from :curname4 into :id, :t;
 5253                           223         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                224                 :                : 
                                225                 :              1 :     strcpy(msg, "move");
 4501                           226                 :              1 :     exec sql at test1 move absolute 0 :curname4;
 5253                           227         [ -  + ]:              1 : 
                                228                 :              1 :     strcpy(msg, "fetch 1");
 4501                           229                 :              1 :     exec sql at test1 fetch 1 :curname4 into :id, :t;
 5253                           230         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                231                 :                : 
                                232                 :              1 :     strcpy(msg, "fetch :count");
                                233                 :              1 :     count = 1;
 4501                           234                 :              1 :     exec sql at test1 fetch :count :curname4 into :id, :t;
 5253                           235         [ -  + ]:              1 :     printf("%d %s\n", id, t);
                                236                 :                : 
                                237                 :              1 :     strcpy(msg, "close");
 4501                           238                 :              1 :     exec sql at test1 close :curname4;
 5253                           239         [ -  + ]:              1 : 
                                240                 :              1 :     strcpy(msg, "deallocate prepare");
 4501                           241                 :              1 :     exec sql at test1 deallocate prepare st_id2;
 5253                           242         [ -  + ]:              1 : 
                                243                 :                :     /* End test */
                                244                 :                : 
                                245                 :              1 :     strcpy(msg, "drop");
 4501                           246                 :              1 :     exec sql at test1 drop table t1;
                                247         [ -  + ]:              1 :     exec sql at test2 drop table t1;
 5253                           248         [ -  + ]:              1 : 
                                249                 :              1 :     strcpy(msg, "commit");
 4501                           250                 :              1 :     exec sql at test1 commit;
 5253                           251         [ -  + ]:              1 : 
 4891 peter_e@gmx.net           252                 :              1 :     strcpy(msg, "disconnect");
 4501 meskes@postgresql.or      253                 :              1 :     exec sql disconnect all;
 5253                           254         [ -  + ]:              1 : 
 2432 peter_e@gmx.net           255                 :              1 :     return 0;
                                256                 :                : }
        

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