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: 2025-01-18 12:13:41 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             : static char software_version[] = "$Id: paramcore.c,v 1.9 2011-07-12 10:16:59 freddy77 Exp $";
       8             : static void *no_unused_var_warn[] = { software_version, no_unused_var_warn };
       9             : 
      10             : #define SP_TEXT "{call sp_paramcore_test(?)}"
      11             : #define OUTSTRING_LEN 20
      12             : 
      13             : int
      14           8 : main(int argc, char *argv[])
      15             : {
      16           8 :         SQLLEN cb = SQL_NTS;
      17             : 
      18           8 :         odbc_use_version3 = 1;
      19             : 
      20           8 :         odbc_connect();
      21             : 
      22           8 :         odbc_command_with_result(odbc_stmt, "drop proc sp_paramcore_test");
      23           8 :         odbc_command("create proc sp_paramcore_test @s varchar(100) output as select @s = '12345'");
      24             : 
      25             :         /* here we pass a NULL buffer for input SQL_NTS */
      26           8 :         CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, NULL, OUTSTRING_LEN, &cb, "S");
      27             : 
      28           8 :         cb = SQL_NTS;
      29           8 :         CHKExecDirect(T(SP_TEXT), SQL_NTS, "E");
      30           8 :         odbc_reset_statement();
      31             : 
      32             :         /* here we pass a NULL buffer for input */
      33           8 :         CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_VARCHAR, 18, 0, NULL, OUTSTRING_LEN, &cb, "S");
      34             : 
      35           8 :         cb = 1;
      36           8 :         CHKExecDirect(T(SP_TEXT), SQL_NTS, "E");
      37           8 :         odbc_reset_statement();
      38             : 
      39           8 :         odbc_command("drop proc sp_paramcore_test");
      40           8 :         odbc_command("create proc sp_paramcore_test @s numeric(10,2) output as select @s = 12345.6");
      41           8 :         odbc_reset_statement();
      42             : 
      43             : #if 0   /* this fails even on native platforms */
      44             :         /* here we pass a NULL buffer for output */
      45             :         cb = sizeof(SQL_NUMERIC_STRUCT);
      46             :         SQLBindParameter(odbc_stmt, 1, SQL_PARAM_OUTPUT, SQL_C_NUMERIC, SQL_NUMERIC, 18, 0, NULL, OUTSTRING_LEN, &cb);
      47             :         odbc_read_error();
      48             : 
      49             :         cb = 1;
      50             :         odbc_command_with_result(odbc_stmt, SP_TEXT);
      51             :         odbc_read_error();
      52             :         odbc_reset_statement();
      53             : #endif
      54             : 
      55           8 :         odbc_command("drop proc sp_paramcore_test");
      56             : 
      57           8 :         odbc_disconnect();
      58             : 
      59           8 :         printf("Done successfully!\n");
      60             :         return 0;
      61             : }

Generated by: LCOV version 1.13