Commit d208e5e
Handle nested parentheses in INSERT subquery detection
When parsing `INSERT INTO t <source>`, the parser must decide whether
the tokens following the table name begin an explicit column list
`(a, b, ...)` or the source query `(SELECT ...)`. `peek_subquery_start`
made this decision by matching exactly `( SELECT`, so a source query
wrapped in more than one layer of parentheses — e.g.
`INSERT INTO t ((SELECT 1))` — was mistaken for a column list and
failed to parse.
Skip any number of leading `(` and treat the tokens as a subquery start
as long as at least one paren precedes the `SELECT`. This matches how
nested parentheses around subqueries are already handled elsewhere via
recursive descent.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent e79119c commit d208e5e
2 files changed
Lines changed: 20 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18476 | 18476 | | |
18477 | 18477 | | |
18478 | 18478 | | |
18479 | | - | |
| 18479 | + | |
18480 | 18480 | | |
18481 | | - | |
18482 | | - | |
18483 | | - | |
18484 | | - | |
18485 | | - | |
18486 | | - | |
18487 | | - | |
18488 | | - | |
18489 | | - | |
18490 | | - | |
18491 | | - | |
18492 | | - | |
18493 | | - | |
18494 | | - | |
18495 | | - | |
18496 | | - | |
| 18481 | + | |
| 18482 | + | |
| 18483 | + | |
| 18484 | + | |
| 18485 | + | |
| 18486 | + | |
| 18487 | + | |
| 18488 | + | |
| 18489 | + | |
| 18490 | + | |
| 18491 | + | |
18497 | 18492 | | |
18498 | 18493 | | |
18499 | 18494 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
354 | 362 | | |
355 | 363 | | |
356 | 364 | | |
| |||
0 commit comments