|Title:||Built-in RTRIM collating sequence yields incorrect comparisons|
|Last Modified:||2019-06-14 13:25:25|
|Version Found In:|
mrigger added on 2019-06-14 11:03:06:
Consider the following statements: <pre> 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 </pre> 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: (text/x-fossil-wiki)
Alternative test case: <blockquote><verbatim> SELECT ' '<char(31) COLLATE rtrim; </verbatim></blockquote> 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.