You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unexpected result when casting integer as boolean #15537
Consider the test case below. It is unexpected that the third query returns an empty result, because the second query returns TRUE, and the value of the WHERE predicate should be TRUE. If removing the PK constraint, the third query returns 2, which is expected.
Steps to Reproduce
DROPTABLE IF EXISTS t0;
CREATETABLEt0(c0 INTEGER, PRIMARY KEY(c0)); -- PK is neededINSERT INTO t0 (c0) VALUES (2);
REFRESH TABLE t0;
SELECT*FROM t0; -- 2SELECT (CAST(t0.c0ASBOOLEAN)= true) FROM t0; -- TRUESELECT*FROM t0 WHERE (CAST(t0.c0ASBOOLEAN)= true);
-- Expected: 2-- Actual: Empty Table
This is in the same context as: #15326
but a bit different, since now we have an explicit cast which the symbol optimizer cannot optimize, so we end up with executing a Get plan with docKeys={true} (a boolean value), but the c0 column is an integer so we cannot match a boolean true for it.
The issue seems to me more complex, as we cannot simply do a symbol optimization and move the cast to the literal, t0.c0 = (CAST true AS INTEGER) , as the cast cannot give back 2 or any other integer that casts to boolean true.
Activity
matriv commentedon Feb 9, 2024
This is in the same context as: #15326
but a bit different, since now we have an explicit cast which the symbol optimizer cannot optimize, so we end up with executing a
Getplan withdocKeys={true}(a boolean value), but thec0column is an integer so we cannot match a booleantruefor it.The issue seems to me more complex, as we cannot simply do a symbol optimization and move the cast to the literal,
t0.c0 = (CAST true AS INTEGER), as the cast cannot give back2or any other integer that casts to booleantrue.Fix PK Lookup with cast on the PK column
Fix PK Lookup with cast on the PK column
Fix PK Lookup with cast on the PK column
matriv commentedon Feb 14, 2024
Thx a lot @suyZhong for reporting this issue, it has been fixed and will be available with the next hotfix release.
Fix PK Lookup with cast on the PK column
Fix PK Lookup with cast on the PK column
Fix PK Lookup with cast on the PK column