LCOV - code coverage report
Current view: top level - src/odbc/unittests - array_error.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 20 20 100.0 %
Date: 2025-01-18 11:50:39 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             : int
       9           8 : main(void)
      10             : {
      11             :         SQLSMALLINT num_params;
      12           8 :         SQLLEN sql_nts = SQL_NTS;
      13             :         char string[20];
      14             :         SQLINTEGER id;
      15             : 
      16           8 :         odbc_use_version3 = 1;
      17           8 :         odbc_connect();
      18             : 
      19           8 :         odbc_command("create table #tester (id int not null primary key, name varchar(20) not null)");
      20           8 :         odbc_command("insert into #tester(id, name) values(1, 'abc')");
      21           8 :         odbc_command("insert into #tester(id, name) values(2, 'duck')");
      22             : 
      23           8 :         odbc_reset_statement();
      24             : 
      25           8 :         CHKPrepare(T("insert into #tester(id, name) values(?,?)"), SQL_NTS, "S");
      26             : 
      27           8 :         CHKNumParams(&num_params, "S");
      28           8 :         assert(num_params == 2);
      29             : 
      30             :         /* now this is going to fail as id is duplicated, causing statement to not be prepared */
      31           8 :         id = 1;
      32           8 :         CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &id, 0, &sql_nts, "S");
      33           8 :         strcpy(string, "test");
      34           8 :         CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(string), 0, string, 0, &sql_nts, "S");
      35           8 :         CHKExecute("E");
      36             : 
      37             :         /* this should success */
      38           8 :         id = 4;
      39           8 :         strcpy(string, "test2");
      40           8 :         CHKExecute("S");
      41             : 
      42           8 :         odbc_disconnect();
      43             :         return 0;
      44             : }
      45             : 

Generated by: LCOV version 1.13