Repository navigation
Commit a8761a6
Sean Kenneth Doherty
Guard insert placeholder zero (apache#22299)
## Which issue does this PR close?
- Fixes apache#22224.
## Rationale for this change
`EXPLAIN INSERT INTO t VALUES ($0)` currently panics while inferring
parameter types for INSERT VALUES. Other SQL paths already reject `$0`
as an invalid placeholder index, and the INSERT inference path should do
the same instead of subtracting one from zero.
## What changes are included in this PR?
- Adds a zero-index guard before INSERT VALUES placeholder numbers are
converted to parameter vector positions.
- Aligns the INSERT VALUES error with the existing invalid-placeholder
planning error.
- Adds a standalone SQL logic regression for `EXPLAIN INSERT INTO ...
VALUES ($0)`.
## Are these changes tested?
Yes.
- `cargo fmt --check --all`
- `cargo test -p datafusion-sqllogictest --test sqllogictests --
insert_values_placeholders`
- `cargo test -p datafusion-sql --test sql_integration
test_insert_schema_errors` -> 6 passed
- `git diff --check origin/main...HEAD`
- `git diff --cached --check`
## Are there any user-facing changes?
Yes. `INSERT ... VALUES ($0)` now returns a planning error instead of
panicking.
## Scope note
The change is limited to INSERT VALUES placeholder type inference and
the new regression coverage. I did not find any broader placeholder
semantics that needed to change.1 parent 305b6fa commit a8761a6
2 files changed
Lines changed: 37 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2485 | 2485 | | |
2486 | 2486 | | |
2487 | 2487 | | |
2488 | | - | |
2489 | | - | |
2490 | | - | |
2491 | | - | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
2492 | 2498 | | |
2493 | 2499 | | |
2494 | 2500 | | |
2495 | 2501 | | |
2496 | 2502 | | |
2497 | 2503 | | |
2498 | | - | |
| 2504 | + | |
2499 | 2505 | | |
2500 | 2506 | | |
2501 | 2507 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
0 commit comments