FirebirdSQL / firebird

Firebird server, client and tools
https://www.firebirdsql.org/
1.19k stars 204 forks source link

The isc_array_lookup_bounds function returns invalid values for low and high array bounds #8100

Closed ViktorVDev closed 1 week ago

ViktorVDev commented 2 weeks ago

OFS_FB4.txt OFS_FB5.txt In FB5 and newer (tested for the latest snapshots of FB5 and FB6), there is an incorrect behavior upon calling the isc_array_lookup_bounds() function: the array bounds ALWAYS equal zero.

To reproduce, an EMPLOYEE.FDB from Firebird demo may be used. The query used is: SELECT * FROM JOB.

Upon the further investigation it turned out that upon making a call for select fd.rdb$lower_bound, fd.rdb$upper_bound from rdb$field_dimensions fd where fd.rdb$field_name = ? order by fd.rdb$dimension

As the parameter's value, the value from the rdb$field_name field of the rdb$relation_fields table is sent, instead of sending the value of the rdb$field_source field of the aforementioned table.

Please see the attached results from the sniffer for FB4 (everything works properly) and FB5.

asfernandes commented 1 week ago

@ViktorVDev could you please test fix in next snapshot of FB 5?

ViktorVDev commented 1 week ago

@ViktorVDev could you please test fix in next snapshot of FB 5?

Done. Fixed for 32 and 64 FB5. We've also tested the FB6 snapshot - unfortunately, the issue remains.

asfernandes commented 1 week ago

@ViktorVDev could you please test fix in next snapshot of FB 5?

Done. Fixed for 32 and 64 FB5.

Thanks.

We've also tested the FB6 snapshot - unfortunately, the issue remains.

I'm yet going to commit the fix in master.

TommiPrami commented 1 day ago

On our tests this also affects 4.0.4, but not 4.03.

Do Double Check is this needed to be backported also 4.05.

asfernandes commented 1 day ago

On our tests this also affects 4.0.4, but not 4.03.

Do Double Check is this needed to be backported also 4.05.

The function wasn't changed in v4 branch, so I don't see how the same bug could be there.