Skip to content

Regression. Result of cross join of two procedures + unioned with common datasource (e.g. rdb$database) is wrong since 5.0.3.1675 #8891

@pavel-zotov

Description

@pavel-zotov

Consider following script:

set bail on;
shell del r:\temp\tmp4test.fdb 2>nul;
create database 'localhost:r:\temp\tmp4test.fdb' user 'sysdba' password 'masterkey';
set echo on;

recreate table test(x int);
insert into test select row_number()over() from rdb$types rows 5;
commit;

set term ^;
create or alter procedure sp_issue_row_1 (a_x int default 1) returns (x int) as
begin
    x = a_x + 1;
    suspend;
end
^ 
set term ;^
commit;

set explain on;
with
c as (
    select first 1 p2.x
    from sp_issue_row_1 p1
    cross join sp_issue_row_1 (p1.x) p2
    union all
    select 4 from rdb$database
)
select * from c
join test n on n.x = c.x
;

Its output on 5.0.3.1674:

       X            X
======== ============
       3            3
       4            4

(and this is expected)

But since 5.0.3.1675 result became wrong:

       X            X
======== ============
       3            1
       3            2
       3            3
       3            4
       3            5
       4            1
       4            2
       4            3
       4            4
       4            5

(same on 6.x)

Key notes:

  1. p1 must be CROSS joined with p2
  2. input argument (p1.x) must be specified for procedure that is in the right part of cross join (alias p2)

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions