2 //READ_UNCOMMITTED isolation testing
3 // T1 and T2 both doing select for same tuple
5 void* runTest1(void *p
);
6 void* runTest2(void *p
);
11 DbRetVal rv
= conn
.open("root", "manager");
12 if (rv
!= OK
) { printf("Error during connection %d\n", rv
); return 1; }
13 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
14 int ret
= createTable(dbMgr
);
15 if (ret
!= 0) { return 1; }
17 rv
= conn
.startTransaction();
18 if (rv
!= OK
) {printf ("Unable to start trans\n"); return 1; }
19 rv
= insert(dbMgr
, 100, false);
20 if (rv
!= OK
) { printf("Unable to insert\n"); return 2; }
22 printf("Tuple inserted\n");
25 int *status1
, *status2
;
26 pthread_create (&thr
[0], NULL
, &runTest1
, NULL
);
27 pthread_create (&thr
[1], NULL
, &runTest2
, NULL
);
28 printf("All threads started\n");
30 pthread_join(thr
[0], (void**)&status1
);
31 pthread_join(thr
[1], (void**)&status2
);
33 if (*status1
!= 0 || *status2
!= 0) ret
= 1;
34 dbMgr
->dropTable("t1");
38 void* runTest1(void *message
)
41 DbRetVal rv
= conn
.open("root", "manager");
42 if (rv
!= OK
) { printf("Error during connection %d\n", rv
); return NULL
; }
43 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
44 if (dbMgr
== NULL
) { printf("Auth failed\n"); return NULL
;}
45 rv
= conn
.startTransaction(READ_UNCOMMITTED
);
46 if (rv
!= OK
) return NULL
;
47 printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid());
48 int *retval
= new int();
50 rv
= select(dbMgr
, 100, true);
51 if (rv
!= OK
) { printf("Test Failed:first thread failed to select\n"); *retval
= 1; }
57 void* runTest2(void *message
)
60 DbRetVal rv
= conn
.open("root", "manager");
61 if (rv
!= OK
) { printf("Error during connection %d\n", rv
); return NULL
; }
62 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
63 if (dbMgr
== NULL
) { printf("Auth failed\n"); return NULL
;}
64 rv
= conn
.startTransaction(READ_UNCOMMITTED
);
65 if (rv
!= OK
) return NULL
;
66 printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid());
68 int *retval
= new int();
70 rv
= select(dbMgr
, 100, false);
71 if (rv
!= OK
) { printf("Test Failed:second thread failed to select\n"); *retval
= 1; }