Issue Details (XML | Word | Printable)

Key: CORE-4322
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Adriano dos Santos Fernandes
Reporter: Pavel Zotov
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Engine crashes when use aggregate or window functions in recursive query

Created: 21/Jan/14 07:43 PM   Updated: 23/Sep/15 12:43 PM
Component/s: None
Affects Version/s: 2.5.2, 2.5.2 Update 1, 3.0 Alpha 1, 3.0 Alpha 2
Fix Version/s: 3.0 Beta 1

File Attachments: 1. Zip Archive gdb-firebird.140121_234028.1.zip (7 kB)

Issue Links:
Relate
 

QA Status: Done successfully


 Description  « Hide
LI-T3.0.0.30813

SQL> with recursive r as(select 0 i,count(*)over() c from rdb$database union all select r.i+1,sum(i)over() from r where r.i<10) select * from r;

Select Expression
    -> Recursion
        -> Materialize
            -> Window
                -> Record Buffer
                    -> Table "R RDB$DATABASE" Full Scan
        -> Materialize
            -> Filter

           I C
============ =====================
Statement failed, SQLSTATE = 08006
Error reading data from the connection.

Coredump see in attach.

Edit:

2.5:

with recursive r as(select 0 i, count(*) c from rdb$database union all select r.i + 1, sum(i) from r where r.i < 10) select * from r;

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Adriano dos Santos Fernandes added a comment - 22/Jan/14 02:50 PM - edited
.

Adriano dos Santos Fernandes added a comment - 27/Jan/14 01:01 AM
Another related problem: aggregate functions usage are not verified correctly.

-- Compiles, but should give an error.
with recursive r as(select 0 i,count(*) c from rdb$database union all select r.i + 1, 0 from r where sum(r.i) = 0) select * from r;

Adriano dos Santos Fernandes added a comment - 27/Jan/14 01:10 AM
I'm fixing this only in 3.0 for now. Will see about backport after fix review.

Pavel Cisar added a comment - 23/Sep/15 12:43 PM
Test created.