Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
coshcage authored May 4, 2024
1 parent 4db51c1 commit 4653801
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 22 deletions.
50 changes: 50 additions & 0 deletions Samples/10000.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "svimrdb.h"
#include <stdio.h>

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;
}
11 changes: 5 additions & 6 deletions Samples/exp_2023-07-08_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

int main()
{
int i;
P_MATRIX pv;
P_TRANS ptrans;
P_TABLE ptbl, ptbl2;
Expand Down Expand Up @@ -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");

Expand Down
10 changes: 5 additions & 5 deletions Samples/exp_2023-08-09_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 5 additions & 11 deletions Samples/exp_2024-01-30_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4653801

Please sign in to comment.