Index is not used for some date/time expressions in dialect 1 [CORE1812] #2242
Submitted by: @dyemanov
Is related to QA213
This is a regression introduced in v2.1 and it's caused by a more strict checking for datatypes being compatible for an index scan. In dialect 1, expression ('now' - <const>) has the datatype "double precision" which is now considered incompatible with a timestamp. A workaround is to use CAST or the explicit datatype prefix before 'now'. This issue affects other date/time constants ('today', etc) as well.
In case we'll intend to fix that issue, a possible solution would be to check not only the descriptor datatype but also node flags (nod_date / nod_double). This should allow better compatibility with the legacy dialect.
Test case (database dialect 1):
create table t (col timestamp) ;
select * from t where col > timestamp 'now' - 7 ;
select * from t where col > 'now' - 7 ;
The text was updated successfully, but these errors were encountered: