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

Generated by: LCOV version 1.13