mirror of
https://github.com/michaeldv/pit.git
synced 2025-12-10 08:25:34 +00:00
Don't build the index unless table has primary key
This commit is contained in:
14
src/table.c
14
src/table.c
@@ -248,14 +248,16 @@ PTable pit_table_load(FILE *file) {
|
|||||||
pt->slots = pr = calloc(pt->number_of_slots, pt->record_size);
|
pt->slots = pr = calloc(pt->number_of_slots, pt->record_size);
|
||||||
pt->index = pi = calloc(pt->number_of_slots, sizeof(uchar *));
|
pt->index = pi = calloc(pt->number_of_slots, sizeof(uchar *));
|
||||||
/*
|
/*
|
||||||
** Now read the records into the slots and rebuild the index.
|
** Now read the records into the slots and rebuild the index if the
|
||||||
|
** table has primary key.
|
||||||
*/
|
*/
|
||||||
read += fread(pt->slots, pt->record_size, pt->number_of_records, file);
|
read += fread(pt->slots, pt->record_size, pt->number_of_records, file);
|
||||||
for(i = 1; i <= pt->number_of_slots; i++, pi++) {
|
if (pt->flags & TABLE_HAS_ID) {
|
||||||
// TODO: if table doesn't have id || has id && id matches...
|
for(i = 1; i <= pt->number_of_slots; i++, pi++) {
|
||||||
if ((ulong)*pr == i) {
|
if ((ulong)*pr == i) {
|
||||||
*pi = pr;
|
*pi = pr;
|
||||||
pr += pt->record_size;
|
pr += pt->record_size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pt;
|
return pt;
|
||||||
|
|||||||
Reference in New Issue
Block a user