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