/ View Ticket
Login
Ticket UUID: f1580ba1b574e9e92d0e6c3b9de519e398e0b10e
Title: Built-in RTRIM collating sequence yields incorrect comparisons
Status: Fixed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2019-06-14 13:25:25
Version Found In:
User Comments:
mrigger added on 2019-06-14 11:03:06:

Consider the following statements:

CREATE TABLE t0(c0 COLLATE RTRIM, c1 BLOB UNIQUE, PRIMARY KEY (c0, c1)) WITHOUT ROWID;
INSERT INTO t0 VALUES (123, 3), (' ', 1), ('	', 2), ('', 4);
SELECT * FROM t0 WHERE c1 = 1; -- expected: ' ', 1, actual: no row is fetched

I would expect a row to be fetched, which is not the case. Note that the whitespace seems to be significant: the first one is a space, the second one a tab, and the third one an empty string.


drh added on 2019-06-14 13:25:25:

Alternative test case:

SELECT ' '<char(31) COLLATE rtrim;

The above should give and answer of true since a zero-length string is less than a string of length 1. But the answer returned is false.

This problem has existing in the RTRIM collating sequence since it was first introduced by check-in [0bf4e7fefdbbf7be] on 2008-01-20 for SQLite version 3.5.5. Fixed 11 years later by check-in [86fa0087cd1f5c79] 11 years later.