Don't build the index unless table has primary key

This commit is contained in:
Mike Dvorkin
2010-08-07 19:33:29 -07:00
parent 452d3afc9a
commit 6a653f3295

View File

@@ -248,16 +248,18 @@ PTable pit_table_load(FILE *file) {
pt->slots = pr = calloc(pt->number_of_slots, pt->record_size);
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);
if (pt->flags & TABLE_HAS_ID) {
for(i = 1; i <= pt->number_of_slots; i++, pi++) {
// TODO: if table doesn't have id || has id && id matches...
if ((ulong)*pr == i) {
*pi = pr;
pr += pt->record_size;
}
}
}
return pt;
}