LCOV - differential code coverage report
Current view: top level - src/interfaces/ecpg/test/connect - test6.pgc (source / functions) Coverage Total Hit CBC
Current: bed3ffbf9d952be6c7d739d068cdce44c046dfb7 vs 574581b50ac9c63dd9e4abebb731a3b67e5b50f6 Lines: 100.0 % 32 32 32
Current Date: 2026-05-05 10:23:31 +0900 Functions: 100.0 % 1 1 1
Baseline: lcov-20260505-025707-baseline Line coverage date bins:
Baseline Date: 2026-05-05 10:27:06 +0900 (1,7] days: 100.0 % 32 32 32
Legend: Lines:     hit not hit Function coverage date bins:
(1,7] days: 100.0 % 1 1 1

 Age         Owner                  TLA  Line data    Source code
                                  1                 : /*
                                  2                 :  * This test verifies that ecpg functions properly handle NULL connections
                                  3                 :  * (i.e., when a connection name doesn't exist or has been disconnected).
                                  4                 :  * Before the fix, these operations would cause a segmentation fault.
                                  5                 :  */
                                  6                 : 
                                  7                 : #include <stdlib.h>
                                  8                 : #include <string.h>
                                  9                 : #include <stdio.h>
                                 10                 : 
                                 11                 : exec sql include ../regression;
                                 12                 : 
                                 13                 : int
    4 andrew@dunslane.net        14 CBC           1 : main(void)
                                 15                 : {
                                 16                 : exec sql begin declare section;
                                 17               1 :     int val1output = 2;
                                 18               1 :     int val1 = 1;
                                 19               1 :     char val2[6] = "data1";
                                 20               1 :     char *stmt1 = "SELECT * from test1 where a = $1 and b = $2";
                                 21                 : exec sql end declare section;
                                 22                 : 
                                 23               1 :     ECPGdebug(1, stderr);
                                 24                 : 
                                 25                 :     /* Connect to the database */
                                 26               1 :     exec sql connect to REGRESSDB1 as myconn;
                                 27                 : 
                                 28                 :     /* Test 1: Try to get descriptor on a disconnected connection */
                                 29               1 :     printf("Test 1: Try to get descriptor on a disconnected connection\n");
                                 30               1 :     exec sql create table test1 (a int, b text);
                                 31               1 :     exec sql insert into test1 (a,b) values (1, 'data1');
                                 32                 : 
                                 33               1 :     exec sql allocate descriptor indesc;
                                 34               1 :     exec sql allocate descriptor outdesc;
                                 35                 : 
                                 36               1 :     exec sql prepare foo2 from :stmt1;
                                 37                 : 
                                 38               1 :     exec sql set descriptor indesc value 1 DATA = :val1;
                                 39               1 :     exec sql set descriptor indesc value 2 DATA = :val2;
                                 40                 : 
                                 41               1 :     exec sql execute foo2 using sql descriptor indesc into sql descriptor outdesc;
                                 42                 : 
                                 43               1 :     exec sql rollback;
                                 44               1 :     exec sql disconnect;
                                 45               1 :     exec sql get descriptor outdesc value 1 :val1output = DATA;
                                 46               1 :     printf("sqlca.sqlcode = %ld\n", sqlca.sqlcode);
                                 47                 : 
                                 48                 :     /* Test 2: Try to deallocate all on a non-existent connection */
                                 49               1 :     printf("Test 2: deallocate all with non-existent connection\n");
                                 50               1 :     exec sql at nonexistent deallocate all;
                                 51               1 :     printf("sqlca.sqlcode = %ld\n", sqlca.sqlcode);
                                 52                 : 
                                 53                 :     /* Test 3: deallocate on disconnected connection */
                                 54               1 :     printf("Test 3: deallocate all on disconnected connection\n");
                                 55               1 :     exec sql deallocate all;
                                 56               1 :     printf("sqlca.sqlcode = %ld\n", sqlca.sqlcode);
                                 57                 : 
                                 58                 :     /* Test 4: Use prepared statement from non-existent connection */
                                 59               1 :     printf("Test 4: Use prepared statement from non-existent connection\n");
                                 60               1 :     exec sql at nonexistent prepare stmt1 FROM "SELECT 1";
                                 61                 :     exec sql at nonexistent declare cur1 cursor for stmt1;
                                 62               1 :     exec sql at nonexistent open cur1;
                                 63               1 :     printf("sqlca.sqlcode = %ld\n", sqlca.sqlcode);
                                 64                 : 
                                 65               1 :     printf("All tests completed !\n");
                                 66                 : 
                                 67               1 :     return 0;
                                 68                 : }
        

Generated by: LCOV version 2.5.0-beta