I have a sqlite table that contains a blob file, but you need to do size / length check on blob, how to do it?
According to some documentation I found, using length (blob) will not work, because length () only works with texts and will stop counting after the first NULL. My empirical tests have shown that this is true.
I am using SQLite 3.4.2
Update:
Since SQLite 3.7.6 seems like the length () function is returning the correct blobs value - I checked various sqlite change logs, but did not see which version it was fixed in.
From Sqlite 3.7.6:
payload_id | length (payload) | length (hex (payload)) / 2
1807913 | 194 | 194
1807914 | 171 | 171
The documentation has been modified to reflect this.
length (X) The length (X) function returns the length of X in characters if X is
a string, or in bytes if X is a blob. If X is NULL then length (X) is
NULL If X is numeric then length (X) returns the length of a string
representation of X.
source
share