adding test scripts
[csql.git] / test / cache / FailOver / insertprepcsqldownora.c
blobf00a24651e3b998c612b807821acbeabce064010
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 strcpy(statement,"insert into t1 values(60,'GGG');");
15 int rows=0;
16 con->beginTrans();
17 rv = stmt->prepare(statement);
18 if(rv!=OK) { delete stmt; delete con; return 1; }
19 sleep (2);
20 rv = stmt->execute(rows);
21 if(rv!=OK) { delete stmt; delete con; return 2; }
22 con->commit();
23 stmt->free();
24 printf("csql down: insert into t1(cached table) success\n");
26 strcpy(statement,"insert into t2 values(60,'GGG');");
27 con->beginTrans();
28 rv = stmt->prepare(statement);
29 if(rv!=OK) { delete stmt; delete con; return 3; }
30 rv = stmt->execute(rows);
31 if(rv!=OK) { printf("csql down: insert into t2(not cached mysql table) failed\n"); delete stmt; delete con; return 4; }
32 printf("csql down: insert into t2(not cached mysql table) success\n");
33 con->commit();
35 strcpy(statement,"insert into t3 values(60,'GGG');");
36 con->beginTrans();
37 rv = stmt->prepare(statement);
38 if(rv!=OK) { delete stmt; delete con; return 5; }
39 rv = stmt->execute(rows);
40 if(rv!=OK) { printf("csql down: insert into t3(not cached csql table) failed\n"); stmt->free(); delete stmt; con->disconnect();delete con; return 6; }
41 printf("csql down: insert into t3(not cached csql table) success\n");
42 con->commit();
44 stmt->free();
45 con->disconnect();
46 delete stmt;
47 delete con;
48 return 0;