adding test scripts
[csql.git] / test / cache / FailOver / insertexeccsqldown.c
blob07b09ac091e564a69eb1d1b203ba895a5835978a
1 #include<AbsSqlStatement.h>
2 #include<SqlFactory.h>
3 #include<Info.h>
4 int main()
6 DbRetVal rv = OK;
7 AbsSqlConnection *con = SqlFactory :: createConnection(CSqlGateway);
8 rv = con->connect("root","manager");
9 if(rv!=OK)return 1;
11 AbsSqlStatement *stmt = SqlFactory :: createStatement(CSqlGateway);
12 stmt->setConnection(con);
13 char statement[200];
14 if(0==strcmp(getenv("DSN"),"db2"))
15 strcpy(statement,"insert into t1 values(11, 33, 4234, 'mohan', 34.34, 345.543, '1999-02-23', '11:22:33', '1999-02-23 11:22:33');");
16 else
17 strcpy(statement,"insert into t1 values(11, 33, 4234, 'mohan', 34.34, 345.543, '1999/02/23', '11:22:33', '1999/02/23 11:22:33');");
18 int rows=0;
19 con->beginTrans();
20 rv = stmt->prepare(statement);
21 if(rv!=OK) { delete stmt; delete con; return 1; }
22 rv = stmt->execute(rows);
23 if(rv!=OK) { delete stmt; delete con; return 2; }
24 sleep (15);
25 con->commit();
26 stmt->free();
27 printf("csql down: insert into t1(cached table) success\n");
29 if(0==strcmp(getenv("DSN"),"db2"))
30 strcpy(statement,"insert into t2 values(11, 33, 4234, 'mohan', 34.34, 345.543, '1999-02-23', '11:22:33', '1999-02-23 11:22:33');");
31 else
32 strcpy(statement,"insert into t2 values(11, 33, 4234, 'mohan', 34.34, 345.543, '1999/02/23', '11:22:33', '1999/02/23 11:22:33');");
33 con->beginTrans();
34 rv = stmt->prepare(statement);
35 if(rv!=OK) { delete stmt; delete con; return 3; }
36 rv = stmt->execute(rows);
37 if(rv!=OK) { printf("csql down: insert into t2(not cached mysql table) failed\n"); delete stmt; delete con; return 4; }
38 printf("csql down: insert into t2(not cached mysql table) success\n");
39 con->commit();
41 if(0==strcmp(getenv("DSN"),"db2"))
42 strcpy(statement,"insert into t3 values(11, 33, 4234, 'mohan', 34.34, 345.543, '1999-02-23', '11:22:33', '1999-02-23 11:22:33');");
43 else
44 strcpy(statement,"insert into t3 values(11, 33, 4234, 'mohan', 34.34, 345.543, '1999/02/23', '11:22:33', '1999/02/23 11:22:33');");
45 con->beginTrans();
46 rv = stmt->prepare(statement);
47 if(rv!=OK) { delete stmt; delete con; return 5; }
48 rv = stmt->execute(rows);
49 if(rv!=OK) { printf("csql down: insert into t3(not cached csql table) failed\n"); delete stmt; delete con; return 6; }
50 printf("csql down: insert into t3(not cached csql table) success\n");
51 con->commit();
53 stmt->free();
55 delete stmt;
56 delete con;
57 return 0;