On Tuesday, 4 September, 2018 14:00, Clemens Ladisch <clem...@ladisch.de> wrote:
>Keith Medcalf wrote: >> 6) If the column type is SQLITE_BLOB >> a) Retrieve the column value pointer using column_blob >> b) If the returned pointer is NULL, then an error has occurred >"The return value from sqlite3_column_blob() for a zero-length BLOB >is a NULL pointer." Hmmm. Yes. " The values returned by sqlite3_column_bytes() and sqlite3_column_bytes16() do not include the zero terminators at the end of the string. For clarity: the values returned by sqlite3_column_bytes() and sqlite3_column_bytes16() are the number of bytes in the string, not the number of characters. Strings returned by sqlite3_column_text() and sqlite3_column_text16(), even empty strings, are always zero-terminated. The return value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. " So, an empty string returns a valid pointer but the bytes count is zero. For an empty blob, the returned pointer is NULL and the bytes count is zero. So, for column_text the test for a NULL pointer will indicate an error. In the case of a BLOB if a NULL pointer is returned the error code must be retrieved and then if and only if the bytes counter is greater than 0 is the error valid. Does this mean that if you are retrieving the value of a blob via the colmn_blob interface you should ask for the column_bytes first and only expect a NULL pointer if the bytes count is zero? --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users