On Tue, Sep 4, 2018 at 2:11 PM Keith Medcalf <kmedc...@dessus.com> wrote:

>
> 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.
>

(for text)
column_bytes() returns the number of bytes specified for the string, and
has nothing to do with NUL unless you end up with a tranlsation from utf8
to utf16 or vice versa.  So it can/will return the number of bytes
including nulls in the text.


>
> 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. "
>
if there is no transform between utf16 or utf8, text returns a pointer
which may contain nuls; I do forget, but it may be the buffer is always
allocated +1 and include an extra nul... (probably does)
Such nuls can be isnerted with the escape '||char(0)||'


>
> 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
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to