*** empty log message ***
[csql.git] / test / cache / FailOver / selectexeccsqldown.c
blobb89b8d9a9a8685eab237f9a9ac671943c4b6ff9b
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,"select * from t1;");
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: select from t1(cached table) success\n");
27 strcpy(statement,"select * from t2;");
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: select from t2(not cached mysql table) failed\n"); delete stmt; delete con; return 4; }
33 printf("csql down: select from t2(not cached mysql table) success\n");
34 con->commit();
35 stmt->free();
37 strcpy(statement,"select * from t3;");
38 con->beginTrans();
39 rv = stmt->prepare(statement);
40 if(rv!=OK) { printf("csql down: select 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: select from t3(not cached csql table) failed\n"); delete stmt; delete con; return 6; }
43 printf("csql down: select from t3(not cached csql table) success\n");
44 con->commit();
46 stmt->free();
47 delete stmt;
48 delete con;
49 return 0;