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

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : #include <stdlib.h>
                                  2                 :                : #include <string.h>
                                  3                 :                : #include <stdio.h>
                                  4                 :                : 
                                  5                 :                : exec sql include ../regression;
                                  6                 :                : exec sql whenever sqlerror sqlprint;
                                  7                 :                : 
                                  8                 :                : static void
 1789 meskes@postgresql.or        9                 :CBC          17 : check_result_of_insert(void)
                                 10                 :                : {
                                 11                 :                :     exec sql begin declare section;
                                 12                 :             17 :     int ivar1 = 0, ivar2 = 0;
                                 13                 :                :     exec sql end declare section;
                                 14                 :                : 
                                 15                 :             17 :     exec sql select c1,c2 into :ivar1,:ivar2 from test;
                                 16         [ -  + ]:             17 :     printf("%d %d\n", ivar1, ivar2);
                                 17                 :             17 : }
                                 18                 :                : 
                                 19                 :              1 : int main(void)
                                 20                 :                : {
                                 21                 :                :     exec sql begin declare section;
                                 22                 :              1 :     int ivar1 = 1, ivar2 = 2;
                                 23                 :                :     char v_include_dq_name[16], v_include_ws_name[16], v_normal_name[16], v_query[64];
                                 24                 :                :     exec sql end declare section;
                                 25                 :                : 
                                 26                 :              1 :     strcpy(v_normal_name, "normal_name");
                                 27                 :              1 :     strcpy(v_include_dq_name, "include_\"_name");
                                 28                 :              1 :     strcpy(v_include_ws_name, "include_ _name");
                                 29                 :              1 :     strcpy(v_query, "insert into test values(?,?)");
                                 30                 :                : 
                                 31                 :                :     /*
                                 32                 :                :      * preparing for test
                                 33                 :                :      */
                                 34                 :              1 :     exec sql connect to REGRESSDB1;
                                 35         [ -  + ]:              1 :     exec sql begin;
                                 36         [ -  + ]:              1 :     exec sql create table test (c1 int, c2 int);
                                 37         [ -  + ]:              1 :     exec sql commit work;
                                 38         [ -  + ]:              1 :     exec sql begin;
                                 39         [ -  + ]:              1 : 
                                 40                 :                :     /*
                                 41                 :                :      * Non dynamic statement
                                 42                 :                :      */
                                 43                 :              1 :     exec sql truncate test;
                                 44         [ -  + ]:              1 :     printf("+++++ Test for prepnormal +++++\n");
                                 45                 :              1 :     printf("insert into test values(:ivar1,:ivar2)\n");
                                 46                 :              1 :     exec sql insert into test values(:ivar1,:ivar2);
                                 47         [ -  + ]:              1 :     check_result_of_insert();
                                 48                 :                : 
                                 49                 :              1 :     exec sql truncate test;
                                 50         [ -  + ]:              1 :     printf("+++++ Test for execute immediate +++++\n");
                                 51                 :              1 :     printf("execute immediate \"insert into test values(1,2)\"\n");
                                 52                 :              1 :     exec sql execute immediate "insert into test values(1,2)";
                                 53         [ -  + ]:              1 :     check_result_of_insert();
                                 54                 :                : 
                                 55                 :                :     /*
                                 56                 :                :      * PREPARE FROM
                                 57                 :                :      */
                                 58                 :              1 :     exec sql truncate test;
                                 59         [ -  + ]:              1 :     printf("+++++ Test for PREPARE ident FROM CString +++++\n");
                                 60                 :              1 :     printf("prepare ident_name from \"insert into test values(?,?)\"\n");
                                 61                 :              1 :     exec sql prepare ident_name from "insert into test values(?,?)";
                                 62         [ -  + ]:              1 :     printf("execute ident_name using :ivar1,:ivar2\n");
                                 63                 :              1 :     exec sql execute ident_name using :ivar1,:ivar2;
                                 64         [ -  + ]:              1 :     check_result_of_insert();
                                 65                 :                : 
                                 66                 :              1 :     exec sql truncate test;
                                 67         [ -  + ]:              1 :     printf("+++++ Test for PREPARE char_variable_normal_name FROM char_variable +++++\n");
                                 68                 :              1 :     printf("prepare :v_normal_name from :v_query\n");
                                 69                 :              1 :     exec sql prepare :v_normal_name from :v_query;
                                 70         [ -  + ]:              1 :     printf("execute :v_normal_name using :ivar1,:ivar2\n");
                                 71                 :              1 :     exec sql execute :v_normal_name using :ivar1,:ivar2;
                                 72         [ -  + ]:              1 :     check_result_of_insert();
                                 73                 :                : 
                                 74                 :              1 :     exec sql truncate test;
                                 75         [ -  + ]:              1 :     printf("+++++ Test for PREPARE char_variable_inc_dq_name FROM char_variable +++++\n");
                                 76                 :              1 :     printf("prepare :v_include_dq_name from :v_query\n");
                                 77                 :              1 :     exec sql prepare :v_include_dq_name from :v_query;
                                 78         [ -  + ]:              1 :     printf("execute :v_include_dq_name using :ivar1,:ivar2\n");
                                 79                 :              1 :     exec sql execute :v_include_dq_name using :ivar1,:ivar2;
                                 80         [ -  + ]:              1 :     check_result_of_insert();
                                 81                 :                : 
                                 82                 :              1 :     exec sql truncate test;
                                 83         [ -  + ]:              1 :     printf("+++++ Test for PREPARE char_variable_inc_ws_name FROM char_variable +++++\n");
                                 84                 :              1 :     printf("prepare :v_include_ws_name from :v_query\n");
                                 85                 :              1 :     exec sql prepare :v_include_ws_name from :v_query;
                                 86         [ -  + ]:              1 :     printf("execute :v_include_ws_name using :ivar1,:ivar2\n");
                                 87                 :              1 :     exec sql execute :v_include_ws_name using :ivar1,:ivar2;
                                 88         [ -  + ]:              1 :     check_result_of_insert();
                                 89                 :                : 
                                 90                 :              1 :     exec sql truncate test;
                                 91         [ -  + ]:              1 :     printf("+++++ Test for PREPARE CString_inc_ws_name FROM char_variable +++++\n");
                                 92                 :              1 :     printf("prepare \"include_ _name\" from :v_query\n");
                                 93                 :              1 :     exec sql prepare "include_ _name" from :v_query;
                                 94         [ -  + ]:              1 :     printf("exec sql execute \"include_ _name\" using :ivar1,:ivar2\n");
                                 95                 :              1 :     exec sql execute "include_ _name" using :ivar1,:ivar2;
                                 96         [ -  + ]:              1 :     check_result_of_insert();
                                 97                 :                : 
                                 98                 :              1 :     exec sql truncate test;
                                 99         [ -  + ]:              1 :     printf("+++++ Test for PREPARE CString_normal_name FROM char_variable +++++\n");
                                100                 :              1 :     printf("prepare \"norma_name\" from :v_query\n");
                                101                 :              1 :     exec sql prepare "normal_name" from :v_query;
                                102         [ -  + ]:              1 :     printf("exec sql execute \"normal_name\" using :ivar1,:ivar2\n");
                                103                 :              1 :     exec sql execute "normal_name" using :ivar1,:ivar2;
                                104         [ -  + ]:              1 :     check_result_of_insert();
                                105                 :                : 
                                106                 :                :     /*
                                107                 :                :      * PREPARE AS
                                108                 :                :      */
                                109                 :              1 :     exec sql deallocate "ident_name";
                                110         [ -  + ]:              1 :     exec sql deallocate "normal_name";
                                111         [ -  + ]:              1 :     exec sql deallocate "include_ _name";
                                112         [ -  + ]:              1 : 
                                113                 :              1 :     exec sql truncate test;
                                114         [ -  + ]:              1 :     printf("+++++ Test for PREPARE ident(typelist) AS +++++\n");
                                115                 :              1 :     printf("prepare ident_name(int,int) as insert into test values($1,$2)\n");
                                116                 :              1 :     exec sql prepare ident_name(int,int) as insert into test values($1,$2);
                                117         [ -  + ]:              1 :     printf("execute ident_name(:ivar1,:ivar2)\n");
                                118                 :              1 :     exec sql execute ident_name(:ivar1,:ivar2);
                                119         [ -  + ]:              1 :     check_result_of_insert();
                                120                 :              1 :     exec sql deallocate "ident_name";
                                121         [ -  + ]:              1 : 
                                122                 :              1 :     exec sql truncate test;
                                123         [ -  + ]:              1 :     printf("+++++ Test for PREPARE CString_normal_name(typelist) AS +++++\n");
                                124                 :              1 :     printf("prepare \"normal_name\"(int,int) as insert into test values($1,$2)\n");
                                125                 :              1 :     exec sql prepare "normal_name"(int,int) as insert into test values($1,$2);
                                126         [ -  + ]:              1 :     printf("execute \"normal_name\"(:ivar1,:ivar2)\n");
                                127                 :              1 :     exec sql execute "normal_name"(:ivar1,:ivar2);
                                128         [ -  + ]:              1 :     check_result_of_insert();
                                129                 :              1 :     exec sql deallocate "normal_name";
                                130         [ -  + ]:              1 : 
                                131                 :              1 :     exec sql truncate test;
                                132         [ -  + ]:              1 :     printf("+++++ Test for PREPARE CString_include_ws_name(typelist) AS +++++\n");
                                133                 :              1 :     printf("prepare \"include_ _name\"(int,int) as insert into test values($1,$2)\n");
                                134                 :              1 :     exec sql prepare "include_ _name"(int,int) as insert into test values($1,$2);
                                135         [ -  + ]:              1 :     printf("execute \"include_ _name\"(:ivar1,:ivar2)\n");
                                136                 :              1 :     exec sql execute "include_ _name"(:ivar1,:ivar2);
                                137         [ -  + ]:              1 :     check_result_of_insert();
                                138                 :              1 :     exec sql deallocate "include_ _name";
                                139         [ -  + ]:              1 : 
                                140                 :              1 :     exec sql truncate test;
                                141         [ -  + ]:              1 :     printf("+++++ Test for PREPARE char_variable_normal_name(typelist) AS +++++\n");
                                142                 :              1 :     printf("prepare :v_normal_name(int,int) as insert into test values($1,$2)\n");
                                143                 :              1 :     exec sql prepare :v_normal_name(int,int) as insert into test values($1,$2);
                                144         [ -  + ]:              1 :     printf("execute :v_normal_name(:ivar1,:ivar2)\n");
                                145                 :              1 :     exec sql execute :v_normal_name(:ivar1,:ivar2);
                                146         [ -  + ]:              1 :     check_result_of_insert();
                                147                 :              1 :     exec sql deallocate "normal_name";
                                148         [ -  + ]:              1 : 
                                149                 :              1 :     exec sql truncate test;
                                150         [ -  + ]:              1 :     printf("+++++ Test for PREPARE char_variable_include_ws_name(typelist) AS +++++\n");
                                151                 :              1 :     printf("prepare :v_include_ws_name(int,int) as insert into test values($1,$2)\n");
                                152                 :              1 :     exec sql prepare :v_include_ws_name(int,int) as insert into test values($1,$2);
                                153         [ -  + ]:              1 :     printf("execute :v_include_ws_name(:ivar1,:ivar2)\n");
                                154                 :              1 :     exec sql execute :v_include_ws_name(:ivar1,:ivar2);
                                155         [ -  + ]:              1 :     check_result_of_insert();
                                156                 :              1 :     exec sql deallocate "include_ _name";
                                157         [ -  + ]:              1 : 
                                158                 :              1 :     exec sql truncate test;
                                159         [ -  + ]:              1 :     printf("+++++ Test for EXECUTE :v_normal_name(const,const) +++++\n");
                                160                 :              1 :     printf("prepare :v_normal_name from :v_query\n");
                                161                 :              1 :     exec sql prepare :v_normal_name from :v_query;
                                162         [ -  + ]:              1 :     printf("execute :v_normal_name(1,2)\n");
                                163                 :              1 :     exec sql execute :v_normal_name(1,2);
                                164         [ -  + ]:              1 :     check_result_of_insert();
                                165                 :              1 :     exec sql deallocate "normal_name";
                                166         [ -  + ]:              1 : 
                                167                 :              1 :     exec sql truncate test;
                                168         [ -  + ]:              1 :     printf("+++++ Test for EXECUTE :v_normal_name(expr,expr) +++++\n");
                                169                 :              1 :     printf("prepare :v_normal_name from :v_query\n");
                                170                 :              1 :     exec sql prepare :v_normal_name from :v_query;
                                171         [ -  + ]:              1 :     printf("execute :v_normal_name(0+1,1+1)\n");
                                172                 :              1 :     exec sql execute :v_normal_name(0+1,1+1);
                                173         [ -  + ]:              1 :     check_result_of_insert();
                                174                 :              1 :     exec sql deallocate "normal_name";
                                175         [ -  + ]:              1 : 
                                176                 :              1 :     exec sql truncate test;
                                177         [ -  + ]:              1 :     printf("+++++ Test for combination PREPARE FROM and EXECUTE ident(typelist) +++++\n");
                                178                 :              1 :     printf("prepare ident_name from :v_query\n");
                                179                 :              1 :     exec sql prepare ident_name from :v_query;
                                180         [ -  + ]:              1 :     printf("execute ident_name(:ivar1,:ivar2)\n");
                                181                 :              1 :     exec sql execute ident_name(:ivar1,:ivar2);
                                182         [ -  + ]:              1 :     check_result_of_insert();
                                183                 :              1 :     exec sql deallocate "ident_name";
                                184         [ -  + ]:              1 : 
                                185                 :              1 :     exec sql truncate test;
                                186         [ -  + ]:              1 :     printf("+++++ Test for combination PREPARE FROM and EXECUTE CString_include_ws_name(typelist) +++++\n");
                                187                 :              1 :     printf("prepare \"include_ _name\" from :v_query\n");
                                188                 :              1 :     exec sql prepare "include_ _name" from :v_query;
                                189         [ -  + ]:              1 :     printf("execute \"include_ _name\"(:ivar1,:ivar2)\n");
                                190                 :              1 :     exec sql execute "include_ _name"(:ivar1,:ivar2);
                                191         [ -  + ]:              1 :     check_result_of_insert();
                                192                 :              1 :     exec sql deallocate "include_ _name";
                                193         [ -  + ]:              1 : 
                                194                 :              1 :     exec sql drop table test;
                                195         [ -  + ]:              1 :     exec sql commit work;
                                196         [ -  + ]:              1 : 
                                197                 :              1 :     return 0;
                                198                 :                : }
        

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