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

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : #include <stdio.h>
                                  2                 :                : #include <stdlib.h>
                                  3                 :                : #include <string.h>
                                  4                 :                : 
                                  5                 :                : #include <pgtypes_numeric.h>
                                  6                 :                : 
                                  7                 :                : EXEC SQL INCLUDE sqlda.h;
                                  8                 :                : 
                                  9                 :                : EXEC SQL INCLUDE ../regression;
                                 10                 :                : 
 2223 meskes@postgresql.or       11                 :CBC           3 : static void warn(void)
                                 12                 :                : {
                                 13                 :              3 :   fprintf(stderr, "Warning: At least one column was truncated\n");
                                 14                 :              3 : }
                                 15                 :                : 
                                 16                 :                : /* Compatible handling of char array to retrieve varchar field to char array
                                 17                 :                :    should be fixed-length, blank-padded, then null-terminated.
                                 18                 :                :    Conforms to the ANSI Fixed Character type. */
                                 19                 :                : 
                                 20                 :              1 : int main() {
                                 21                 :                : 
                                 22                 :                :   EXEC SQL WHENEVER SQLWARNING do warn();
                                 23                 :                :   EXEC SQL WHENEVER SQLERROR STOP;
                                 24                 :                : 
                                 25                 :              1 :   const char *ppppp = "XXXXX";
                                 26                 :                :   int loopcount;
  362 michael@paquier.xyz        27                 :              1 :   sqlda_t *sqlda = NULL;
                                 28                 :                : 
                                 29                 :                :   EXEC SQL BEGIN DECLARE SECTION;
                                 30                 :                :   char shortstr[5];
                                 31                 :                :   char bigstr[11];
 2223 meskes@postgresql.or       32                 :              1 :   short shstr_ind = 0;
                                 33                 :              1 :   short bigstr_ind = 0;
                                 34                 :                :   EXEC SQL END DECLARE SECTION;
                                 35                 :                : 
                                 36                 :              1 :   ECPGdebug(1, stderr);
                                 37                 :              1 :   EXEC SQL CONNECT TO REGRESSDB1;
                                 38   [ -  +  -  + ]:              1 : 
                                 39                 :              1 :   EXEC SQL CREATE TABLE strdbase (strval varchar(10));
                                 40   [ -  +  -  + ]:              1 :   EXEC SQL INSERT INTO strdbase values ('');
                                 41   [ -  +  -  + ]:              1 :   EXEC SQL INSERT INTO strdbase values ('AB');
                                 42   [ -  +  -  + ]:              1 :   EXEC SQL INSERT INTO strdbase values ('ABCD');
                                 43   [ -  +  -  + ]:              1 :   EXEC SQL INSERT INTO strdbase values ('ABCDE');
                                 44   [ -  +  -  + ]:              1 :   EXEC SQL INSERT INTO strdbase values ('ABCDEF');
                                 45   [ -  +  -  + ]:              1 :   EXEC SQL INSERT INTO strdbase values ('ABCDEFGHIJ');
                                 46   [ -  +  -  + ]:              1 : 
                                 47                 :                :   EXEC SQL declare C cursor for select strval, strval from strdbase;
                                 48                 :              1 :   EXEC SQL OPEN C;
                                 49   [ -  +  -  + ]:              1 : 
                                 50                 :                :   EXEC SQL WHENEVER NOT FOUND DO BREAK;
                                 51                 :                : 
                                 52                 :              1 :   printf("Full Str.  :  Short  Ind.\n");
 1907 tgl@sss.pgh.pa.us          53         [ +  - ]:              7 :   for (loopcount = 0; loopcount < 100; loopcount++) {
 2223 meskes@postgresql.or       54                 :              7 :     strncpy(shortstr, ppppp, sizeof shortstr);
                                 55                 :              7 :     memset(bigstr, 0, sizeof bigstr);
                                 56                 :              7 :     EXEC SQL FETCH C into :bigstr :bigstr_ind, :shortstr :shstr_ind;
                                 57   [ +  +  +  +  :              7 :     printf("\"%s\": \"%s\"  %d\n", bigstr, shortstr, shstr_ind);
                                              -  + ]
                                 58                 :                :   }
                                 59                 :                : 
 2215 peter_e@gmx.net            60                 :              1 :   EXEC SQL CLOSE C;
 2223 meskes@postgresql.or       61   [ -  +  -  + ]:              1 :   EXEC SQL DROP TABLE strdbase;
  362 michael@paquier.xyz        62   [ -  +  -  + ]:              1 :   EXEC SQL COMMIT WORK;
 2223 meskes@postgresql.or       63   [ -  +  -  + ]:              1 : 
                                 64                 :                :   /* SQLDA handling */
                                 65                 :                :   EXEC SQL WHENEVER SQLWARNING SQLPRINT;
                                 66                 :                :   EXEC SQL WHENEVER NOT FOUND STOP;
  362 michael@paquier.xyz        67                 :              1 :   EXEC SQL PREPARE stmt1 FROM "SELECT 123::numeric(3,0), 't'::varchar(2)";
                                 68   [ -  +  -  + ]:              1 :   EXEC SQL DECLARE cur1 CURSOR FOR stmt1;
                                 69                 :              1 :   EXEC SQL OPEN cur1;
                                 70   [ -  +  -  + ]:              1 :   EXEC SQL FETCH NEXT FROM cur1 INTO DESCRIPTOR sqlda;
                                 71   [ -  +  -  +  :              1 : 
                                              -  + ]
                                 72                 :              1 :   printf("\n-----------------\ntype    : data\n");
                                 73         [ +  + ]:              3 :   for (int i = 0 ; i < sqlda->sqld ; i++)
                                 74                 :                :   {
                                 75                 :              2 :       sqlvar_t v = sqlda->sqlvar[i];
                                 76                 :              2 :       char *sqldata = v.sqldata;
                                 77                 :                : 
                                 78         [ +  + ]:              2 :       if (v.sqltype == ECPGt_numeric)
                                 79                 :                :           sqldata =
                                 80                 :              1 :               PGTYPESnumeric_to_asc((numeric*) sqlda->sqlvar[i].sqldata, -1);
                                 81                 :                : 
                                 82                 :              2 :       printf("%-8s: \"%s\"\n", v.sqlname.data, sqldata);
                                 83                 :                :   }
                                 84                 :                : 
                                 85                 :              1 :   EXEC SQL CLOSE cur1;
 2223 meskes@postgresql.or       86   [ -  +  -  + ]:              1 :   EXEC SQL COMMIT WORK;
                                 87   [ -  +  -  + ]:              1 : 
  362 michael@paquier.xyz        88                 :              1 :   printf("\nGOOD-BYE!!\n\n");
                                 89                 :                : 
 2223 meskes@postgresql.or       90                 :              1 :   EXEC SQL DISCONNECT ALL;
                                 91   [ -  +  -  + ]:              1 : 
                                 92                 :              1 :   return 0;
                                 93                 :                : }
        

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