adding test scripts
[csql.git] / test / cache / FailOver / updateexeccsqldownora.c
blob6a9627d9c0943133bc6c4f101436fd2122c09215
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,"update t1 set f2='NNN' where f1 = 40;");
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: update t1(cached table) success\n");
27 strcpy(statement,"update t2 set f2='NNN' where f1 = 40;");
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 f2='NNN' where f1 = 40;");
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 from 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;