LibSQL: Allow expressions and column names in SELECT ... FROM

Up to now the only ``SELECT`` statement that worked was ``SELECT *
FROM <table>``. This commit allows a column list consisting of
column names and expressions in addition to ``*``. ``WHERE``
still doesn't work though.
This commit is contained in:
Jan de Visser
2021-09-16 22:29:19 +02:00
committed by Andreas Kling
parent f33a288ca4
commit fe50598a03
Notes: sideshowbarker 2024-07-18 03:02:56 +09:00
8 changed files with 90 additions and 20 deletions

View File

@@ -87,4 +87,17 @@ Value UnaryOperatorExpression::evaluate(ExecutionContext& context) const
VERIFY_NOT_REACHED();
}
Value ColumnNameExpression::evaluate(ExecutionContext& context) const
{
auto& descriptor = *context.current_row->descriptor();
VERIFY(context.current_row->size() == descriptor.size());
for (auto ix = 0u; ix < context.current_row->size(); ix++) {
auto& column_descriptor = descriptor[ix];
if (column_descriptor.name == column_name())
return { (*context.current_row)[ix] };
}
// TODO: Error handling.
VERIFY_NOT_REACHED();
}
}