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,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;