LCOV - code coverage report
Current view: top level - src/odbc/unittests - paramcore.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 20 20 100.0 %
Date: 2026-08-16 18:05:36 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "common.h"
       2             : 
       3             : /*
       4             :  * Try to make core dump using SQLBindParameter
       5             :  */
       6             : 
       7             : #define SP_TEXT "{call sp_paramcore_test(?)}"
       8             : #define OUTSTRING_LEN 20
       9             : 
      10          10 : TEST_MAIN()
      11             : {
      12          10 :         SQLLEN cb = SQL_NTS;
      13             : 
      14          10 :         odbc_connect();
      15             : 
      16          10 :         odbc_command_with_result(odbc_stmt, "drop proc sp_paramcore_test");
      17          10 :         odbc_command("create proc sp_paramcore_test @s varchar(100) output as select @s = '12345'");
      18             : 
      19             :         /* here we pass a NULL buffer for input SQL_NTS */
      20          10 :         CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, NULL, OUTSTRING_LEN, &cb, "S");
      21             : 
      22          10 :         cb = SQL_NTS;
      23          10 :         CHKExecDirect(T(SP_TEXT), SQL_NTS, "E");
      24          10 :         odbc_reset_statement();
      25             : 
      26             :         /* here we pass a NULL buffer for input */
      27          10 :         CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_VARCHAR, 18, 0, NULL, OUTSTRING_LEN, &cb, "S");
      28             : 
      29          10 :         cb = 1;
      30          10 :         CHKExecDirect(T(SP_TEXT), SQL_NTS, "E");
      31          10 :         odbc_reset_statement();
      32             : 
      33          10 :         odbc_command("drop proc sp_paramcore_test");
      34          10 :         odbc_command("create proc sp_paramcore_test @s numeric(10,2) output as select @s = 12345.6");
      35          10 :         odbc_reset_statement();
      36             : 
      37             : #if 0   /* this fails even on native platforms */
      38             :         /* here we pass a NULL buffer for output */
      39             :         cb = sizeof(SQL_NUMERIC_STRUCT);
      40             :         SQLBindParameter(odbc_stmt, 1, SQL_PARAM_OUTPUT, SQL_C_NUMERIC, SQL_NUMERIC, 18, 0, NULL, OUTSTRING_LEN, &cb);
      41             :         odbc_read_error();
      42             : 
      43             :         cb = 1;
      44             :         odbc_command_with_result(odbc_stmt, SP_TEXT);
      45             :         odbc_read_error();
      46             :         odbc_reset_statement();
      47             : #endif
      48             : 
      49          10 :         odbc_command("drop proc sp_paramcore_test");
      50             : 
      51          10 :         odbc_disconnect();
      52             : 
      53          10 :         printf("Done successfully!\n");
      54          10 :         return 0;
      55             : }

Generated by: LCOV version 1.13