performance fixes and fix for core dump in test tools/csql/test029.ksh
[csql.git] / tmptest / select.c
blobf4093b5608b66700b0c558d3ab7980acc7cde870
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 SqlStatement *stmt = new SqlStatement();
9 stmt->setConnection(con);
10 char statement[1024];
11 strcpy(statement, "SELECT * from t1 where f1 = 5;");
12 int rows =0;
13 rv = stmt->prepare(statement);
14 if (rv != OK) {delete stmt; delete con; return 1; }
15 int id1 =50, id2 = 100;
16 int icount=0;
17 rv = stmt->bindField(1, &id1);
18 if (rv != OK) {delete stmt; delete con; return 2; }
19 rv = stmt->bindField(2, &id2);
20 if (rv != OK) {delete stmt; delete con; return 3; }
21 void *tuple;
22 NanoTimer timer;
23 timer.start();
24 con->beginTrans();
25 stmt->execute(rows);
26 printf("\n");
27 while(true)
29 tuple = (char*)stmt->fetch() ;
30 if (tuple == NULL) { break; }
31 printf("f1=%d f2=%d\n", id1, id2);
32 icount++;
34 con->commit();
35 timer.stop();
37 printf("Select %d %lld %lld %lld\n", icount, timer.min(), timer.max(), timer.avg());
40 stmt->free();
41 delete stmt;
42 delete con;
43 return 0;