grammar: 3c — INSERT … SELECT row source (ADR-0033 §4)

Make the INSERT row source a Choice between the VALUES clause and
Subgrammar(&sql_select::SQL_SELECT_COMPOUND). SQL_SELECT_COMPOUND
is itself a Choice that admits a leading WITH, so a WITH-prefixed
SELECT row source (R4) parses through it for free; the two
branches start on disjoint keywords (values vs select/with) so the
Choice never ambiguously commits. No worker change — do_sql_insert
already executes the validated SQL and re-persists, and the engine
handles insert-from-query.

Tests: grammar accept (plain / column-list+projection / WITH-
prefixed / trailing-semi) and reject (__rdbms_* on the SELECT's
FROM slot, incomplete select); integration parse-path lowering +
worker round-trip (rows land, CSV re-persisted) incl. R4 WITH end-
to-end; walker cross-cut that the Phase-2 unknown_column diagnostic
fires on the INSERT…SELECT projection; DA-gate test that a self-
sourced INSERT…SELECT runs as a plain insert (no cascade summary —
that is DELETE-only). Still behind the dev `sqlinsert` entry word
(shared `insert` is 3j). 1493 tests green, clippy clean.
This commit is contained in:
claude@clouddev1
2026-05-21 22:08:25 +00:00
parent 7f68a53f86
commit 6ff9144c7a
3 changed files with 230 additions and 2 deletions
+18
View File
@@ -3915,6 +3915,24 @@ mod tests {
);
}
#[test]
fn insert_select_unknown_projection_column_is_error() {
// ADR-0033 sub-phase 3c cross-cut: the Phase-2
// schema-existence pass fires on a SELECT row source
// embedded in an INSERT (no re-implementation needed).
// `nonexistent_col` is not a column of `a`.
let schema = two_table_schema();
let diags = diag_keys(
"sqlinsert into b select nonexistent_col from a",
&schema,
);
assert!(
diags.iter().any(|d| d.contains("no such column")),
"expected unknown_column on the INSERT…SELECT projection; \
got {diags:?}",
);
}
#[test]
fn cte_name_is_valid_table_source() {
let schema = schema_with("base", &[("id", Type::Int)]);