diff --git a/Samples/10000.cc b/Samples/10000.cc new file mode 100644 index 0000000..091d76a --- /dev/null +++ b/Samples/10000.cc @@ -0,0 +1,50 @@ +#include "svimrdb.h" +#include + +int main() +{ + int i, * p = &i; + P_TRANS ptrans; + P_TABLE ptbl; + P_ARRAY_Z parrhdr; + P_ARRAY_Z parrg; + + parrg = strCreateArrayZ(1, sizeof(void *)); + + parrhdr = strCreateArrayZ(1, sizeof(TBLHDR)); + ((TBLHDR *)strLocateItemArrayZ(parrhdr, sizeof(TBLHDR), 0))->ct = CT_INTEGER; + ((TBLHDR *)strLocateItemArrayZ(parrhdr, sizeof(TBLHDR), 0))->phsh = NULL; + ((TBLHDR *)strLocateItemArrayZ(parrhdr, sizeof(TBLHDR), 0))->cr = CR_PRIMARY_KEY; + ((TBLHDR *)strLocateItemArrayZ(parrhdr, sizeof(TBLHDR), 0))->strname = "number"; + + strInsertItemArrayZ(parrg, &p, sizeof(void *), 0); + + ptrans = siBeginTransaction(); + + ptbl = siCreateTable(ptrans, "Student", parrhdr); + + while (TRUE != siTrylock(ptrans, ptbl, LT_S)) // Share lock. + ; + + while (TRUE != siTrylock(ptrans, ptbl, LT_X)) // Write lock. + ; + + for (i = 0; i < 10000; ++i) + { + if (TRUE != siInsertIntoTableBase(ptrans, ptbl, NULL, parrg)) + { + printf("%s, %d\n", "failed!", i); + siRollbackTransaction(NULL, ptrans); + siReleaseAllTransaction(); + return 1; + } + } + + siCommitTransaction(ptrans); + + siReleaseAllTransaction(); + + strDeleteArrayZ(parrg); + + return 0; +} diff --git a/Samples/exp_2023-07-08_1.c b/Samples/exp_2023-07-08_1.c index 4c854d3..374e01f 100644 --- a/Samples/exp_2023-07-08_1.c +++ b/Samples/exp_2023-07-08_1.c @@ -11,7 +11,6 @@ int main() { - int i; P_MATRIX pv; P_TRANS ptrans; P_TABLE ptbl, ptbl2; @@ -50,11 +49,11 @@ int main() while (TRUE != siTrylock(ptrans, ptbl, LT_S)) // Share lock. ; - i = 2; siInsertIntoTable(ptrans, ptbl, NULL, &i, "Lisa", L"CS"); - i = 2; siInsertIntoTable(ptrans, ptbl, NULL, &i, "Lisa", L"CS"); - i = 1; siInsertIntoTable(ptrans, ptbl, NULL, &i, "John", L"LT"); - i = 4; siInsertIntoTable(ptrans, ptbl, NULL, &i, "Amy", L"CS"); - i = 3; siInsertIntoTable(ptrans, ptbl, NULL, &i, "Jack", L"LT"); + siInsertIntoTable(ptrans, ptbl, NULL, 2, "Lisa", L"CS"); + siInsertIntoTable(ptrans, ptbl, NULL, 2, "Lisa", L"CS"); + siInsertIntoTable(ptrans, ptbl, NULL, 1, "John", L"LT"); + siInsertIntoTable(ptrans, ptbl, NULL, 4, "Amy", L"CS"); + siInsertIntoTable(ptrans, ptbl, NULL, 3, "Jack", L"LT"); fp = fopen("test.db", "wb"); diff --git a/Samples/exp_2023-08-09_1.c b/Samples/exp_2023-08-09_1.c index 69cba15..7384728 100644 --- a/Samples/exp_2023-08-09_1.c +++ b/Samples/exp_2023-08-09_1.c @@ -130,15 +130,15 @@ void InsertIntoTableSC(P_TRANS ptrans, P_TABLE ptbl) { float f; f = 92.0f; - siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 1, &f); + siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 1, 92.0); f = 85.0f; - siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 2, &f); + siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 2, 85.0); f = 88.0f; - siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 3, &f); + siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 3, 88.0); f = 90.0f; - siInsertIntoTable(ptrans, ptbl, NULL, 2023002, 2, &f); + siInsertIntoTable(ptrans, ptbl, NULL, 2023002, 2, 90.0); f = 80.0f; - siInsertIntoTable(ptrans, ptbl, NULL, 2023002, 3, &f); + siInsertIntoTable(ptrans, ptbl, NULL, 2023002, 3, 80.0); } int main() diff --git a/Samples/exp_2024-01-30_1.c b/Samples/exp_2024-01-30_1.c index 2b94a45..9a33c7e 100644 --- a/Samples/exp_2024-01-30_1.c +++ b/Samples/exp_2024-01-30_1.c @@ -129,17 +129,11 @@ P_TABLE CreateTableSC(P_TRANS ptrans) void InsertIntoTableSC(P_TRANS ptrans, P_TABLE ptbl) { - float f; - f = 92.0f; - siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 1, &f); - f = 85.0f; - siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 2, &f); - f = 88.0f; - siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 3, &f); - f = 90.0f; - siInsertIntoTable(ptrans, ptbl, NULL, 2023002, 2, &f); - f = 80.0f; - siInsertIntoTable(ptrans, ptbl, NULL, 2023002, 3, &f); + siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 1, 92.0); + siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 2, 85.0); + siInsertIntoTable(ptrans, ptbl, NULL, 2023001, 3, 88.0); + siInsertIntoTable(ptrans, ptbl, NULL, 2023002, 2, 90.0); + siInsertIntoTable(ptrans, ptbl, NULL, 2023002, 3, 80.0); } P_TABLE ptbl_student, ptbl_course, ptbl_sc;