first version
[csql.git] / test / cache / FailOver / deleteexeccsqldown.c
blob1591f198c7cde81654cc7fb72ce72d203d64b234
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];
15 strcpy(statement,"delete from t1 where f1 = 10;");
16 int rows=0;
17 con->beginTrans();
18 rv = stmt->prepare(statement);
19 if(rv!=OK) { delete stmt; delete con; return 1; }
20 rv = stmt->execute(rows);
21 if(rv!=OK) { delete stmt; delete con; return 2; }
22 sleep(15);
23 con->commit();
24 stmt->free();
25 printf("csql down: delete from t1(cached table) success\n");
27 strcpy(statement,"delete from t2 where f1 = 10;");
28 con->beginTrans();
29 rv = stmt->prepare(statement);
30 if(rv!=OK) { delete stmt; delete con; return 3; }
31 rv = stmt->execute(rows);
32 if(rv!=OK) { printf("csql down: delete from t2(not cached mysql table) failed\n"); delete stmt; delete con; return 4; }
33 printf("csql down: delete from t2(not cached mysql table) success\n");
34 con->commit();
35 stmt->free();
37 strcpy(statement,"delete from t3 where f1 = 10;");
38 con->beginTrans();
39 rv = stmt->prepare(statement);
40 if(rv!=OK) { printf("csql down: delete from t3(not cached csql table) failed\n"); delete stmt; delete con; return 5; }
41 rv = stmt->execute(rows);
42 if(rv!=OK) { printf("csql down: delete from t3(not cached csql table) failed\n"); delete stmt; delete con; return 6; }
43 printf("csql down: delete from t3(not cached csql table) success\n");
44 con->commit();
46 stmt->free();
48 delete stmt;
49 delete con;
50 return 0;