NCBI C++ ToolKit
timeout.c
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #include "common.h"
2 
3 #include <common/test_assert.h>
4 
5 /* Test timeout of query */
6 
7 static char software_version[] = "$Id: timeout.c 80645 2017-12-28 17:20:38Z ucko $";
9 
10 static void
11 AutoCommit(int onoff)
12 {
14 }
15 
16 static void
18 {
20 }
21 
22 int
23 main(int argc, char *argv[])
24 {
25  HENV env;
26  HDBC dbc;
27  HSTMT stmt;
28  SQLINTEGER i;
29 
30  odbc_connect();
31 
32  /* here we can't use temporary table cause we use two connection */
33  odbc_command_with_result(odbc_stmt, "drop table test_timeout");
34  odbc_command("create table test_timeout(n numeric(18,0) primary key, t varchar(30))");
36 
37  odbc_command("insert into test_timeout(n, t) values(1, 'initial')");
39 
40  odbc_command("update test_timeout set t = 'second' where n = 1");
41 
42  /* save this connection and do another */
43  env = odbc_env;
44  dbc = odbc_conn;
45  stmt = odbc_stmt;
49 
50  odbc_connect();
51 
54 
55  i = 1;
57 
58  CHKPrepare(T("update test_timeout set t = 'bad' where n = ?"), SQL_NTS, "S");
59  CHKExecute("E");
61 
62  /* TODO should return error S1T00 Timeout expired, test error message */
63  odbc_command2("update test_timeout set t = 'bad' where n = 1", "E");
64 
66 
68 
69  odbc_env = env;
70  odbc_conn = dbc;
71  odbc_stmt = stmt;
72 
74 
75  /* Sybase do not accept DROP TABLE during a transaction */
77  odbc_command("drop table test_timeout");
78 
80 
81  return 0;
82 }
#define int2ptr(i)
Definition: common.h:101
#define CHKBindParameter(a, b, c, d, e, f, g, h, i, res)
Definition: common.h:96
#define CHKPrepare(a, b, res)
Definition: common.h:146
#define odbc_command(cmd)
Definition: common.h:179
#define CHKSetConnectAttr(a, b, c, res)
Definition: common.h:152
#define CHKExecute(res)
Definition: common.h:114
#define T(s)
Definition: common.h:230
#define odbc_command2(cmd, res)
Definition: common.h:180
#define CHKSetStmtAttr(a, b, c, res)
Definition: common.h:158
#define CHKEndTran(a, b, c, res)
Definition: common.h:110
int main(int argc, char **argv)
Definition: timeout.c:276
#define NULL
Definition: ncbistd.hpp:225
int i
HSTMT odbc_stmt
Definition: common.c:33
int odbc_disconnect(void)
Definition: common.c:290
HENV odbc_env
Definition: common.c:31
HDBC odbc_conn
Definition: common.c:32
SQLRETURN odbc_command_with_result(HSTMT stmt, const char *command)
Definition: common.c:312
static void EndTransaction(SQLSMALLINT type)
Definition: timeout.c:17
static void AutoCommit(int onoff)
Definition: timeout.c:11
static void * no_unused_var_warn[]
Definition: timeout.c:8
static char software_version[]
Definition: timeout.c:7
static SQLRETURN odbc_connect(TDS_DBC *dbc, TDSLOGIN *login)
Definition: odbc.c:356
static HSTMT stmt
Definition: rebindpar.c:12
#define SQL_COMMIT
Definition: sql.h:271
#define SQL_NULL_HSTMT
Definition: sql.h:277
#define SQL_NULL_HENV
Definition: sql.h:275
#define SQL_NULL_HDBC
Definition: sql.h:276
#define SQL_INTEGER
Definition: sql.h:170
#define SQL_NTS
Definition: sql.h:49
#define SQL_ROLLBACK
Definition: sql.h:272
#define SQL_HANDLE_DBC
Definition: sql.h:65
#define SQL_PARAM_INPUT
Definition: sqlext.h:1852
#define SQL_C_SLONG
Definition: sqlext.h:553
#define SQL_ATTR_AUTOCOMMIT
Definition: sqlext.h:124
#define SQL_ATTR_QUERY_TIMEOUT
Definition: sqlext.h:271
#define SQL_AUTOCOMMIT_ON
Definition: sqlext.h:183
#define SQL_AUTOCOMMIT_OFF
Definition: sqlext.h:182
SQLHANDLE HSTMT
Definition: sqltypes.h:238
void * SQLPOINTER
Definition: sqltypes.h:195
SQLHANDLE HDBC
Definition: sqltypes.h:237
long SQLINTEGER
Definition: sqltypes.h:176
SQLHANDLE HENV
Definition: sqltypes.h:236
signed short int SQLSMALLINT
Definition: sqltypes.h:201
Definition: type.c:6
static HENV env
Definition: transaction2.c:38
static HDBC dbc
Definition: transaction2.c:39
Modified on Thu Feb 22 17:08:01 2024 by modify_doxy.py rev. 669887