Ticket Hash: | fa146dcfe625f6f2de0b10bb7bfa66ee7abef7a9 | |||
Title: | Unexpected result for MIN on string that contains a null character | |||
Status: | Fixed | Type: | Documentation | |
Severity: | Minor | Priority: | Low | |
Subsystem: | Unknown | Resolution: | Fixed | |
Last Modified: | 2020-03-06 00:15:57 | |||
Version Found In: | 3.32.0 | |||
User Comments: | ||||
mrigger added on 2020-03-05 16:37:44:
I believe that the two queries listed below should yield a consistent result; however, he first fetches '0000', while the second fetches '0001': SELECT HEX(MIN(a)) FROM (SELECT CHAR(0, 1) COLLATE NOCASE as a UNION SELECT CHAR(0, 0) as a); -- 0000 SELECT HEX(MIN(a)) FROM (SELECT CHAR(0, 0) COLLATE NOCASE as a UNION SELECT CHAR(0, 1) as a); -- 0001 This issue seems to only affect COLLATE NOCASE. drh added on 2020-03-06 00:15:57: Simpler test case: SELECT char(0,1)=char(0,2) COLLATE NOCASE; The issue here is that the NOCASE collating function stops its comparison at the first zero character it sees. This fact has been clarified in the documentation. See documentation check-in https://www.sqlite.org/docsrc/info/e751b0c91a80dd31 |