Commit a90d147
committed
feat: compound runtime values (TAG_ARRAY, TAG_TUPLE)
Implements the 2026-04-16 compound-value-support spec/plan: arrays,
tuples, and named tuples become first-class runtime Values instead of
collapsing to NULL in the expression evaluator. Local-runtime only:
no remote serialization or planner type inference (per spec scope).
Value layer (include/sql_engine/value.h):
- Two new tags: TAG_ARRAY and TAG_TUPLE, both backed by an arena-owned
CompoundValueData{count, elements, field_names?}. The tag, not the
payload shape, distinguishes array vs tuple semantics.
- New helpers: value_array, value_tuple, value_named_tuple, plus
the underlying make_compound_value. All deep-copy elements (and
optional field_names) into the supplied arena so the source storage
need not outlive the Value.
- New is_compound() predicate.
Evaluator (include/sql_engine/expression_eval.h):
- NODE_TUPLE and NODE_ARRAY_CONSTRUCTOR now evaluate each child and
return the corresponding compound Value. Previously both returned
NULL with a "not yet supported" comment.
- NODE_ARRAY_SUBSCRIPT first evaluates its left side; if the result
is TAG_ARRAY, indexes into the runtime descriptor. The previous
literal-AST-only path is gone (the new eval covers it). MySQL
remains 0-based and PostgreSQL 1-based.
- NODE_FIELD_ACCESS evaluates its left side; if the result is a
TAG_TUPLE with field_names, looks up by case-insensitive field
name match. All conservative cases (out-of-bounds, missing field,
non-compound LHS, unnamed tuple, NULL index) return NULL per spec.
Tests:
- tests/test_value.cpp gets two constructor-level coverage tests
(ArrayValue, NamedTupleValue) the prior session had already
written but couldn't compile.
- tests/test_expression_eval.cpp:
* TupleReturnsNull / ArrayConstructorReturnsNull are flipped to
positive TupleReturnsTupleValue / ArrayConstructorReturnsArrayValue.
* Removed the duplicate ArraySubscriptFromResolvedRuntimeArray and
NestedArraySubscriptUsesRuntimeValues definitions left over from
the prior session (gtest would have errored on duplicate names).
* New: FieldAccessByNameReturnsField, FieldAccessUnknownFieldReturnsNull,
FieldAccessOnUnnamedTupleReturnsNull.
Docs:
- docs/superpowers/plans/2026-04-16-compound-value-support.md is the
implementation plan that drove this change. Committed alongside
the implementation (the spec was already in tree at ae0e84b).
Verification:
- make test: 1208 passed, 37 skipped (live-backend), 0 failed.
- ValueTest + ExprEvalTest groups: 113 passed.
Closes the compound-value items in issue 05 (P2 expression and type
semantics). The remaining items in issue 05 (decimal as int128,
string-backed decimals, CHAR_LENGTH UTF-8 -- the last one is in the
working tree under the prior session's changes, not yet committed)
are independent and tracked separately.1 parent ab8b7fb commit a90d147
5 files changed
Lines changed: 809 additions & 23 deletions
File tree
- docs/superpowers/plans
- include/sql_engine
- tests
0 commit comments