LCOV - code coverage report
Current view: top level - src/odbc/unittests - array_error.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 21 21 100.0 %
Date: 2025-07-16 09:22:05 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "common.h"
       2             : #include <assert.h>
       3             : 
       4             : /*
       5             :         Test for a bug executing after a not successfully execute
       6             : */
       7             : 
       8          10 : TEST_MAIN()
       9             : {
      10             :         SQLSMALLINT num_params;
      11          10 :         SQLLEN sql_nts = SQL_NTS;
      12             :         char string[20];
      13             :         SQLINTEGER id;
      14             : 
      15          10 :         odbc_use_version3 = 1;
      16          10 :         odbc_connect();
      17             : 
      18          10 :         odbc_command("create table #tester (id int not null primary key, name varchar(20) not null)");
      19          10 :         odbc_command("insert into #tester(id, name) values(1, 'abc')");
      20          10 :         odbc_command("insert into #tester(id, name) values(2, 'duck')");
      21             : 
      22          10 :         odbc_reset_statement();
      23             : 
      24          10 :         CHKPrepare(T("insert into #tester(id, name) values(?,?)"), SQL_NTS, "S");
      25             : 
      26          10 :         CHKNumParams(&num_params, "S");
      27          10 :         assert(num_params == 2);
      28             : 
      29             :         /* now this is going to fail as id is duplicated, causing statement to not be prepared */
      30          10 :         id = 1;
      31          10 :         CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &id, 0, &sql_nts, "S");
      32          10 :         strcpy(string, "test");
      33          10 :         CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(string), 0, string, 0, &sql_nts, "S");
      34          10 :         CHKExecute("E");
      35             : 
      36             :         /* this should success */
      37          10 :         id = 4;
      38          10 :         strcpy(string, "test2");
      39          10 :         CHKExecute("S");
      40             : 
      41          10 :         odbc_disconnect();
      42          10 :         return 0;
      43             : }
      44             : 

Generated by: LCOV version 1.13