New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Index is not used for some date/time expressions in dialect 1 [CORE1812] #2242
Comments
Modified by: @dyemanovassignee: Dmitry Yemanov [ dimitr ] |
Modified by: @dyemanovstatus: Open [ 1 ] => Open [ 1 ] Fix Version: 2.5 Beta 1 [ 10251 ] Fix Version: 2.1.1 [ 10223 ] Planning Status: Unspecified => Considered for inclusion |
Modified by: @dyemanovstatus: Open [ 1 ] => Open [ 1 ] Planning Status: Considered for inclusion => Included to release |
Commented by: @pmakowski Q/A test ok |
Modified by: @pmakowskistatus: Resolved [ 5 ] => Closed [ 6 ] |
Commented by: @pmakowski Seems that we have a regression here with 2.5.1.26308 |
Commented by: @dyemanov Regression should be fixed now. |
Modified by: @pcisarstatus: Resolved [ 5 ] => Closed [ 6 ] |
Commented by: @pcisar Test added. |
Modified by: @pavel-zotovQA Status: No test |
Modified by: @pavel-zotovQA Status: No test => Done successfully |
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) ;
create index it on t (col) ;
commit ;
select * from t where col > timestamp 'now' - 7 ;
-- PLAN (T INDEX (IT))
-- OK
select * from t where col > 'now' - 7 ;
-- PLAN (T NATURAL)
-- PROBLEM
Commits: 113258b 8cf431c e0c6d0e 46836ef
The text was updated successfully, but these errors were encountered: