SQLite

View Ticket
Login
2019-01-25
20:09 Fixed ticket [bb4bdb9f]: Zeroblob truncated by an index on an expression plus 6 other changes (artifact: a2fbfd41 user: drh)
20:09
Do not accidently truncate zeroblob values when doing an arithmetic operation. Fix for ticket [bb4bdb9f7f654b0bb9f34cfba]. (check-in: 13f6942e user: drh tags: trunk)
20:01 New ticket [bb4bdb9f] Zeroblob truncated by an index on an expression. (artifact: f81a0799 user: drh)

Ticket Hash: bb4bdb9f7f654b0bb9f34cfbacf5462acb4ce09d
Title: Zeroblob truncated by an index on an expression
Status: Fixed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Virtual_Machine Resolution: Fixed
Last Modified: 2019-01-25 20:09:23
Version Found In:
User Comments:
drh added on 2019-01-25 20:01:15:

When a table has an index on an expression, then inserting a zeroblob into an indexed column of that table might cause the zeroblob to be truncated.

CREATE TABLE t1(a,b,c);
CREATE INDEX t1bbc ON t1(b, b+c);
INSERT INTO t1(a,b,c) VALUES(1,zeroblob(8),3);
SELECT a, b, length(b), c FROM t1;

The correct answer is

1,X'0000000000000000',8,3

But the answer returned is:

1,X'',0,3

This issue was discovered during internal testing. There have been no reports of this from the wild.