4 void* runTest(void *p
);
9 DbRetVal rv
= conn
.open("praba", "manager");
12 printf("Error during connection %d\n", rv
);
15 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
16 if (dbMgr
== NULL
) { printf("Auth failed\n"); return -1;}
18 tabDef
.addField("f1", typeInt
, 0, NULL
, true, true);
19 tabDef
.addField("f2", typeString
, 196);
20 rv
= dbMgr
->createTable("t1", tabDef
);
21 if (rv
!= OK
) { printf("Table creation failed\n"); return -1; }
22 printf("Table created\n");
23 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
24 strcpy(idxInfo
->tableName
, "t1");
25 idxInfo
->list
.append("f1");
26 idxInfo
->indType
= hashIndex
;
27 rv
= dbMgr
->createIndex("indx1", idxInfo
);
28 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
29 printf("Index created %d %lu\n", os::getpid(), os::getthrid());
31 pthread_t thr
[THREADS
];
34 for (int i
=0; i
<THREADS
; i
++) {
36 pthread_create (&thr
[i
], NULL
,
37 &runTest
, (void *) &message
[i
]);
40 printf("All threads started\n");
41 for (int i
=0; i
<THREADS
; i
++) {
42 pthread_join(thr
[i
], (void**)&status
);
44 //dbMgr->dropTable("t1");
48 void* runTest(void *message
)
51 DbRetVal rv
= conn
.open("praba", "manager");
54 printf("Error during connection %d\n", rv
);
57 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
58 if (dbMgr
== NULL
) { printf("Auth failed\n"); return NULL
;}
59 printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid());
60 Table
*table
= dbMgr
->openTable("t1");
61 if (table
== NULL
) { printf("Unable to open table\n"); return NULL
; }
63 char name
[196] = "PRABAKARAN";
64 table
->bindFld("f1", &id
);
65 table
->bindFld("f2", name
);
71 int val
= *(int*)message
;
73 //printf("PRABA::val in this thread %d is %d\n", val, os::getthrid());
74 printf("PRABA::val in this thread %d is %lu\n", val
, ::pthread_self());
75 if (val
== 0) sleep(1);
76 for(i
= val
* 10; i
< (val
*10) +10; i
++)
79 rv
= conn
.startTransaction();
80 if (rv
!= OK
) exit(1);
82 strcpy(name
, "PRABAKARAN0123456750590");
83 printf("%d %lu \n ", i
, os::getthrid());
84 ret
= table
->insertTuple();
91 sprintf(msgBuf
,"Total rows inserted %d %lld %lld %lld\n",icount
, timer
.min(), timer
.max(), timer
.avg());
92 os::write(1,msgBuf
,strlen(msgBuf
));
93 dbMgr
->closeTable(table
);
95 printf("connc closed %d for Thread and pid is %d %lu\n", rv
, os::getpid(), os::getthrid());