FirebirdSQL / firebird

Firebird server, client and tools
https://firebirdsql.org
1.26k stars 217 forks source link

SubQueryConversion = true --multiple rows in singleton select #8233

Closed EPluribusUnum closed 2 months ago

EPluribusUnum commented 2 months ago

Hi *!

https://www.firebirdsql.org/en/community-news/firebird-5-0-1-improvements-in-optimizer

This SQL works with SubQueryConversion = false, but fails with SubQueryConversion = true.

execute procedure kt_szvit_t_e_f_vissza_nyit(2000)

multiple rows in singleton select.
multiple rows in singleton select.
At trigger KTBF_BIU1 line: 88, col: 9
At procedure KTBF_KARTONRA line: 552, col: 1
At procedure KT_SZVIT_T_E_F_VISSZA_NYIT line: 112, col: 11.

And inside the trigger the failing statement is a "select first 1", so this should be impossible.

        select first 1 bt.ktfj_id, bt.gysor
          from ktbt bt
          where bt.ktbf_id = new.id and exists
                (select 1
                   from ktbt bt2
                   where bt2.st_id = bt.id and
                         (round(bt2.mertek, 2) <> round(bt.mertek, 2)))
          order by bt.gysor

Firebird-5.0.2.1486-0-5af13c1-windows-x64.zip

dyemanov commented 2 months ago

Somewhat related to #8224, my first fix didn't move the flags (singular in this case) to the top-level RSE.

EPluribusUnum commented 2 months ago

Fix confirmed, works fine with the latest snapshot.