Skip to content

Commit a3bb1c8

Browse files
committed
Small fixes to where clause logic
1 parent 0a2cf91 commit a3bb1c8

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

data-generation/commands_50k.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:4a4a5b427c437bab2b9c7e0e76a58dde6f72e0379626d501e986d226ec61376a
3-
size 5932421
2+
oid sha256:65cc586dc93a57806c48beabc75d67668cc652f4dbdc754c7a5bde10b77f8247
3+
size 5931870

engine/serial/executeEngine-serial.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,14 @@ struct resultSetS *executeQuerySelectSerial(
357357
// Get all indexed attributes in the WHERE clause, using the B+ tree indexes where possible
358358
struct whereClauseS *wc = whereClause;
359359
while (wc != NULL) {
360+
// Skip nested conditions for index lookup (they don't have a direct attribute)
361+
if (wc->attribute == NULL) {
362+
wc = wc->next;
363+
continue;
364+
}
365+
360366
for (int i = 0; i < engine->num_indexes; i++) {
361367
if (strcmp(wc->attribute, engine->indexed_attributes[i]) == 0) {
362-
anyIndexExists = true;
363368
indexExists[i] = true;
364369

365370
// Use B+ tree index for this attribute
@@ -427,6 +432,8 @@ struct resultSetS *executeQuerySelectSerial(
427432
continue;
428433
}
429434

435+
anyIndexExists = true;
436+
430437
// Allocating for keys, using num_records as upper bound.
431438
KEY_T *returned_keys = malloc(engine->num_records * sizeof(KEY_T));
432439
ROW_PTR *returned_pointers = malloc(engine->num_records * sizeof(ROW_PTR));

sample-queries.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ WHERE sudo_used = TRUE OR (risk_level = 5 AND shell_type = "bash");
3636
# -- Sample 8:
3737
SELECT user_name, working_directory, base_command
3838
FROM Commands
39-
WHERE user_id = 1001 OR (user_name = "student1002" AND shell_type = "zsh");
39+
WHERE user_id = 1001 OR (user_name = "student1002" AND shell_type = "zsh");

0 commit comments

Comments
 (0)