Boundaries of a query with recursive common table expression are detected incorrectly if a query contains an empty line
- Dominant language
- Java
- Stars
- 51.8k
- Forks
- 4.4k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 188
Description
### Description
- use this code (notice the empty line before the last word "select"):
```
with recursive all_data as (
select *
from (values(1, 1, 10),(1, 2, 3),(1, 3, 7),(1, 4, 1),(1, 5, 2),(2, 1, 6),(2, 2, 4),(2, 3, 5),(2, 4, 8),(2, 5, 1)) as s(gr, id, quantity)
),
ct AS (
select *, c.quantity AS sm
from all_data AS c
WHERE id = 1
UNION ALL
select c2.*, c.sm + c2.quantity AS sm
from ct AS c
JOIN all_data AS c2 ON c2.id = c.id + 1 AND c.gr = c2.gr
)
SELECT *
FROM ct
ORDER BY gr, id
```
- set caret to the 8th line
- press Ctrl + Enter (results - on the screen 1)
- set caret to the 16th line
- press Ctrl + Enter (results - on the screen 2)
- remove the empty line and repeat the same steps (there will be no error)
Screen 1:

Screen 2:

### DBeaver Version
Community Edition 24.1.5.202408012322
### Operating System
Windows 10
### Database and driver
PostgreSQL 16
PostgreSQL JDBC Driver 42.7.2
### Steps to reproduce
_No response_
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.