Menu

#1506 "natural left outer join" bug

version 2.4.x
open-fixed
None
1
2019-06-04
2018-03-23
Carrel
No

When I input following SQL statements:

Create table r (A Int, B Int, primary key (A, B));
Create table s (B Int, C Int, primary key (B, C));
Create table t (B Int, D Int, primary key (B, D));
Insert into r values (1, 2);
Insert into s values (3, 4);
Insert into t values (5, 6);

select * from (r natural left outer join s) natural left outer join t

It's supposed to return
| A | B | C | D |
| :--: | :--: | :--: | :--: |
| 1 | 2 | | |

But HSQLDB returns:

Discussion

  • Carrel

    Carrel - 2018-03-23

    The HyperSQL version is 2.4.0

     
  • Fred Toussi

    Fred Toussi - 2018-03-27

    The column order returned by HSQLDB is correct for the SELECT statement.

    The NATURAL JOIN S is joined on column B. This column appears first in the table returned by the subquery following SQL Standard.

     
    • Carrel

      Carrel - 2018-03-28

      The column order is OK, the key problem is that in HSQLDB, the column B is null.
      First, r and s process NATURE LEFT OUTER JOIN. and return A, B, C: 1, 2, null.
      Then, above result process NATURE LEFT OUTER JOIN with t and should return A, B, C, D: 1, 2, null, null following SQL Standard.

       
  • Fred Toussi

    Fred Toussi - 2018-04-02

    This will be fixed later. You can use one of the following alternatives

    select * from  r natural left outer join s natural left outer join t
    select * from (select * from r natural left outer join s) natural left outer join t
    
     
  • Fred Toussi

    Fred Toussi - 2018-04-09
    • status: open --> open-fixed
    • assigned_to: Fred Toussi
    • Priority: 5 --> 1
     
  • Fred Toussi

    Fred Toussi - 2018-04-09

    Fixed and committed to SVN.

     

Log in to post a comment.

MongoDB Logo MongoDB