Fixing failed tests
[csql.git] / tmptest / test.c
blob86d924c031cfb21d3425ca83c559ea600b496ca0
1 #include<SqlStatement.h>
2 #include<NanoTimer.h>
3 int main()
5 DbRetVal rv = OK;
6 SqlConnection *con = new SqlConnection();
7 con->connect("root", "manager");
8 printf("Connected\n");
9 SqlStatement *stmt = new SqlStatement();
10 stmt->setConnection(con);
11 char statement[1024];
12 //strcpy(statement, "INSERT INTO t1 (f1, f2) VALUES (100, 200);");
13 strcpy(statement, "INSERT INTO t1 (f1, f2) VALUES (?, ?);");
14 //strcpy(statement, "INSERT INTO t1 VALUES (100, 200);");
15 //strcpy(statement, "INSERT INTO t1 ");
16 int rows =0;
17 rv = stmt->prepare(statement);
18 printf("Prepeared\n");
19 int id1 =100, id2 = 100;
20 if (rv != OK) {delete stmt; delete con; return -1; }
21 NanoTimer timer;
22 con->beginTrans();
23 for (int i = 0 ; i < 10 ; i++)
25 timer.start();
26 id1 = i; id2 = i;
27 stmt->setIntParam(1, id1);
28 stmt->setIntParam(2, id2);
30 stmt->execute(rows);
31 timer.stop();
33 //{printf("Sleeping\n"); sleep(10);}
34 con->commit();
35 printf("Insert %lld %lld %lld\n", timer.min(), timer.max(), timer.avg());
36 stmt->free();
37 delete stmt;
38 delete con;
39 return 0;