Ticket Hash: | cf5ed20fc8621b1651cc032caf94307e0bb7836d | ||
Title: | Incorrect join result with duplicate WHERE clause constraint | ||
Status: | Fixed | Type: | Code_Defect |
Severity: | Severe | Priority: | Immediate |
Subsystem: | Unknown | Resolution: | Fixed |
Last Modified: |
2018-10-25 15:17:51 6.52 years ago |
Created: |
2018-10-25 11:39:55 6.52 years ago |
Version Found In: | 3.25.2 |
User Comments: | ||||
drh added on 2018-10-25 11:39:55:
In the following SQL, the query with the duplicate "user.active=1" constraint returns an incorrect result. The one with a single "user.active=1" constraint works correctly. CREATE TABLE user ( id INTEGER NOT NULL, active INTEGER NOT NULL, account INTEGER, PRIMARY KEY(id) ); CREATE TABLE account ( id INTEGER NOT NULL, name TEXT, PRIMARY KEY(id) ); INSERT INTO user VALUES (1, 0, 1); INSERT INTO account VALUES (1, 'test'); SELECT user.id FROM user INNER JOIN account ON user.account = account.id WHERE user.active = 1 AND user.active = 1; SELECT user.id FROM user INNER JOIN account ON user.account = account.id WHERE user.active = 1; Bisecting shows that the problem was introduced by the WHERE-clause constraint propagation optimization added by check-in [f4229707ac08d66c5b0f5348] on 2018-07-27. This problem was reported on the mailing list by Sebastian Zwack. |