adding test scripts
[csql.git] / test / cache / FailOver / updateconncsqldown.c
blobe73c0902c0cfcbe3d8479f70ee144192f52eeb1f
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 sleep(15);
16 strcpy(statement,"update t1 set f4='poonam' where f1 = 4;");
17 int rows=0;
18 con->beginTrans();
19 rv = stmt->prepare(statement);
20 if(rv!=OK) { delete stmt; delete con; return 1; }
21 rv = stmt->execute(rows);
22 if(rv!=OK) { delete stmt; delete con; return 2; }
23 con->commit();
24 stmt->free();
25 printf("csql down: update t1(cached table) success\n");
27 strcpy(statement,"update t2 set f4='poonam' where f1 = 4;");
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: update t2(not cached mysql table) failed\n"); delete stmt; delete con; return 4; }
33 printf("csql down: update t2(not cached mysql table) success\n");
34 con->commit();
35 stmt->free();
37 strcpy(statement,"update t3 set f4='poonam' where f1 = 4;");
38 con->beginTrans();
39 rv = stmt->prepare(statement);
40 if(rv!=OK) { printf("csql down: update 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: update t3(not cached csql table) failed\n"); delete stmt; delete con; return 6; }
43 printf("csql down: update t3(not cached csql table) success\n");
44 con->commit();
46 stmt->free();
48 delete stmt;
49 delete con;
50 return 0;