1501526 Composite primary keys
[csql.git] / tmptest / test.c
blob5abe12e19ebf080f111d64fbd38045c904f1e799
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, f3) 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 for (int i = 0 ; i < 100000 ; i++)
24 timer.start();
25 con->beginTrans();
26 id1 = i; id2 = i;
27 stmt->setIntParam(1, id1);
28 stmt->setIntParam(2, id1);
29 stmt->setIntParam(3, id1);
31 stmt->execute(rows);
32 timer.stop();
33 con->commit();
35 //{printf("Sleeping\n"); sleep(10);}
36 printf("Insert %lld %lld %lld\n", timer.min(), timer.max(), timer.avg());
37 stmt->free();
38 delete stmt;
39 delete con;
40 return 0;