Repository navigation
Commit d27b346
authored
fix: require end of input when parsing a single statement (#2733)
- `Statement()` lost its `<EOF>` validation in 063d244 ("feat: return any `UnsupportedStatement`
content"), which replaced `[ <ST_SEMICOLON> ] <EOF>` with `( <ST_SEMICOLON> | <EOF> )`; ever
since, input holding more than one statement silently returned a truncated AST instead of
failing, so callers such as PageHelper's count SQL parser reuse the full parameter mappings
against a partial statement
- `ST_SEMICOLON` also matches blank line runs such as `"\n\n\n"`, which makes the silent
truncation reachable from ordinary formatted SQL that has no semicolon at all
- restore the pre-063d2442 contract with `( <ST_SEMICOLON> )* <EOF>` in both `Statement()`
branches, keeping trailing separators and comments legal while rejecting any unconsumed
statement
- `Statements()` (which kept its trailing `<EOF>`) and `SingleStatement()` are untouched; walking
a script statement by statement stays the incremental API's job
- rewrite the routine boundary test that asserted the lenient behaviour to drive the parser with
`SingleStatement()`, which is how `streamStatements` consumes multi statement scripts1 parent 87e8814 commit d27b346
3 files changed
Lines changed: 39 additions & 4 deletions
File tree
- src
- main/jjtree/net/sf/jsqlparser/parser
- test/java/net/sf/jsqlparser
- parser
- statement/create
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3293 | 3293 | | |
3294 | 3294 | | |
3295 | 3295 | | |
| 3296 | + | |
3296 | 3297 | | |
3297 | 3298 | | |
3298 | 3299 | | |
3299 | 3300 | | |
3300 | 3301 | | |
3301 | 3302 | | |
3302 | | - | |
| 3303 | + | |
3303 | 3304 | | |
3304 | 3305 | | |
3305 | 3306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
528 | 558 | | |
529 | 559 | | |
530 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
111 | 113 | | |
112 | 114 | | |
113 | | - | |
| 115 | + | |
| 116 | + | |
114 | 117 | | |
115 | | - | |
| 118 | + | |
| 119 | + | |
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
| |||
0 commit comments