Skip to content
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

Expression indexes bug: incorrect result for the inverted boolean [CORE2073] #2508

Closed
firebird-automations opened this issue Sep 9, 2008 · 14 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: freemanzav (freemanzav)

Is related to QA224

CREATE TABLE TMP_DATE1
(
DATE1 DATE,
DATE2 DATE
);

EXECUTE BLOCK
AS
DECLARE VARIABLE D DATE;
BEGIN
D = '01.01.2008';
WHILE (D < '01.08.2008') DO BEGIN
INSERT INTO TMP_DATE1(DATE1, DATE2)
VALUES(:D, :D + 100);
D = D + 1;
END
END;

CREATE INDEX TMP_DATE1_IDX1 ON TMP_DATE1 COMPUTED BY (DATE1+0)

---------------------------------------

without index

SELECT count(*) FROM TMP_DATE1 T WHERE '01.03.2008' BETWEEN T.DATE1 AND T.DATE2;

count = 61

---------------------------------------

with index

SELECT count(*) FROM TMP_DATE1 T WHERE '01.03.2008' BETWEEN T.DATE1+0 AND T.DATE2

count = 1

Commits: 278d0f8 049be04 2834254

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

status: Open [ 1 ] => Open [ 1 ]

Fix Version: 2.5 Beta 1 [ 10251 ]

Fix Version: 2.1.2 [ 10270 ]

Fix Version: 2.0.5 [ 10222 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Version: 2.1.1 [ 10223 ]

Version: 2.5 Alpha 1 [ 10224 ]

Version: 2.0.4 [ 10211 ]

Version: 2.1.0 [ 10041 ]

Version: 2.0.3 [ 10200 ]

Version: 2.0.2 [ 10130 ]

Version: 2.0.1 [ 10090 ]

Version: 2.0.0 [ 10091 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

Please provide PLANs generated for the statements.

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Sean, this is a complete test case :-) You can see exactly the same plans as the reporter:

PLAN (TMP_DATE1 NATURAL) -- for the first query
and
PLAN (TMP_DATE1 INDEX(TMP_DATE1_IDX1)) -- for the second one

Moreover:

CREATE INDEX TMP_DATE1_IDX2 ON TMP_DATE1 (DATE1) ;

SELECT count(*) FROM TMP_DATE1 T WHERE '01.03.2008' BETWEEN T.DATE1 AND T.DATE2;
-- PLAN (TMP_DATE1 INDEX(TMP_DATE1_IDX2))
-- returns correct result (count == 61)

The simplified predicate which exposes the bug is:
WHERE '01.03.2008' >= T.DATE1

The problem is that the inverted boolean (literal compared to an indexed object) works correctly for an indexed field but fails for an indexed expression.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

summary: Expression indexes bug => Expression indexes bug: incorrect result for the inverted boolean (i.e. when a literal is compared to an indexed object)

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

summary: Expression indexes bug: incorrect result for the inverted boolean (i.e. when a literal is compared to an indexed object) => Expression indexes bug: incorrect result for the inverted boolean

@firebird-automations
Copy link
Collaborator Author

Modified by: @pmakowski

Link: This issue block progress on QA224 [ QA224 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pmakowski

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA224 [ QA224 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue block progress on QA224 [ QA224 ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test => Done successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment