3 //T1 doing delete and T2 doing insert for same tuple
6 void* runTest1(void *p
);
7 void* runTest2(void *p
);
12 DbRetVal rv
= conn
.open("root", "manager");
13 if (rv
!= OK
) { printf("Error during connection %d\n", rv
); return 1; }
14 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
15 int ret
= createTable(dbMgr
);
16 if (ret
!= 0) { return 1; }
18 rv
= conn
.startTransaction();
19 if (rv
!= OK
) {printf ("Unable to start trans\n"); return 1; }
20 rv
= insert(dbMgr
, 100, false);
21 if (rv
!= OK
) { printf("Unable to insert\n"); return 2; }
23 printf("Tuple inserted\n");
26 int *status1
, *status2
;
27 pthread_create (&thr
[0], NULL
, &runTest1
, NULL
);
28 pthread_create (&thr
[1], NULL
, &runTest2
, NULL
);
29 printf("All threads started\n");
31 pthread_join(thr
[0], (void**)&status1
);
32 pthread_join(thr
[1], (void**)&status2
);
34 if (*status1
!= 0 || *status2
!= 0) ret
= 1;
35 dbMgr
->dropTable("t1");
38 //Hardcoded to fail: It is giving wrong message. Check that and remove this
41 void* runTest1(void *message
)
44 DbRetVal rv
= conn
.open("root", "manager");
45 if (rv
!= OK
) { printf("Error during connection %d\n", rv
); return NULL
; }
46 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
47 if (dbMgr
== NULL
) { printf("Auth failed\n"); return NULL
;}
48 rv
= conn
.startTransaction(READ_UNCOMMITTED
);
49 if (rv
!= OK
) return NULL
;
50 printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid());
51 int *retval
= new int();
53 rv
= remove(dbMgr
, 100, true);
54 if (rv
!= OK
) { printf("Test Failed:first thread failed to delete\n"); *retval
= 1; }
60 void* runTest2(void *message
)
63 DbRetVal rv
= conn
.open("root", "manager");
64 if (rv
!= OK
) { printf("Error during connection %d\n", rv
); return NULL
; }
65 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
66 if (dbMgr
== NULL
) { printf("Auth failed\n"); return NULL
;}
67 rv
= conn
.startTransaction(READ_UNCOMMITTED
);
68 if (rv
!= OK
) return NULL
;
69 printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid());
71 int *retval
= new int();
73 rv
= insert(dbMgr
, 100, false);
74 if (rv
== OK
) { printf("Test Failed:second thread inserted\n"); *retval
= 1; }