LCOV - code coverage report
Current view: top level - src/odbc/unittests - paramcore.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 21 21 100.0 %
Date: 2025-04-15 09:57:00 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_use_version3 = 1;
      15             : 
      16          10 :         odbc_connect();
      17             : 
      18          10 :         odbc_command_with_result(odbc_stmt, "drop proc sp_paramcore_test");
      19          10 :         odbc_command("create proc sp_paramcore_test @s varchar(100) output as select @s = '12345'");
      20             : 
      21             :         /* here we pass a NULL buffer for input SQL_NTS */
      22          10 :         CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, NULL, OUTSTRING_LEN, &cb, "S");
      23             : 
      24          10 :         cb = SQL_NTS;
      25          10 :         CHKExecDirect(T(SP_TEXT), SQL_NTS, "E");
      26          10 :         odbc_reset_statement();
      27             : 
      28             :         /* here we pass a NULL buffer for input */
      29          10 :         CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_VARCHAR, 18, 0, NULL, OUTSTRING_LEN, &cb, "S");
      30             : 
      31          10 :         cb = 1;
      32          10 :         CHKExecDirect(T(SP_TEXT), SQL_NTS, "E");
      33          10 :         odbc_reset_statement();
      34             : 
      35          10 :         odbc_command("drop proc sp_paramcore_test");
      36          10 :         odbc_command("create proc sp_paramcore_test @s numeric(10,2) output as select @s = 12345.6");
      37          10 :         odbc_reset_statement();
      38             : 
      39             : #if 0   /* this fails even on native platforms */
      40             :         /* here we pass a NULL buffer for output */
      41             :         cb = sizeof(SQL_NUMERIC_STRUCT);
      42             :         SQLBindParameter(odbc_stmt, 1, SQL_PARAM_OUTPUT, SQL_C_NUMERIC, SQL_NUMERIC, 18, 0, NULL, OUTSTRING_LEN, &cb);
      43             :         odbc_read_error();
      44             : 
      45             :         cb = 1;
      46             :         odbc_command_with_result(odbc_stmt, SP_TEXT);
      47             :         odbc_read_error();
      48             :         odbc_reset_statement();
      49             : #endif
      50             : 
      51          10 :         odbc_command("drop proc sp_paramcore_test");
      52             : 
      53          10 :         odbc_disconnect();
      54             : 
      55          10 :         printf("Done successfully!\n");
      56          10 :         return 0;
      57             : }

Generated by: LCOV version 1.13