Re: [sqlite] Checking for errors in sqlite3_column_*

2018-06-11 Thread Simon Slavin
On 11 Jun 2018, at 8:29am, Christopher Head  wrote:

> It seemed potentially odd that many other
> threads got replies but this didn’t.

Your question was so good nobody had an answer to it.  I hope you see that DRH 
has now posted a reply, even if that reply doesn't include a solution.

Simon.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Checking for errors in sqlite3_column_*

2018-06-11 Thread Richard Hipp
On 6/11/18, Christopher Head  wrote:
> Hello! I noticed that there was some discussion about mailing list
> messages getting sent to spam boxes. So, not that I expect an immediate
> answer, but just in case people didn’t see this message for that
> reason, here it is again. It seemed potentially odd that many other
> threads got replies but this didn’t.

I clearly need to update the documentation.  It is on my to-do list.
That will be a big project.
-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Checking for errors in sqlite3_column_*

2018-06-11 Thread Christopher Head
Hello! I noticed that there was some discussion about mailing list
messages getting sent to spam boxes. So, not that I expect an immediate
answer, but just in case people didn’t see this message for that
reason, here it is again. It seemed potentially odd that many other
threads got replies but this didn’t.

On Thu, 7 Jun 2018 20:14:35 -0700
Christopher Head  wrote:

> Hello,
> I have a question regarding checking for errors that occur when
> calling sqlite3_column_*.
> 
> From this manual page:
> 
> https://sqlite.org/c3ref/column_blob.html
> 
> it seems that the only error that could occur (other than programmer
> error, like out-of-bounds column index or calling it after something
> other than SQLITE_ROW) is memory allocation error. That page says
> that, in the event of memory allocation error, an appropriate default
> value is returned and then sqlite3_errcode will return SQLITE_NOMEM.
> 
> From this manual page:
> 
> https://sqlite.org/c3ref/errcode.html
> 
> it states explicitly that, if the most recent call failed, then
> sqlite3_errcode returns the error code, but if the most recent call
> succeeded, then the return value is undefined.
> 
> So how do I check if sqlite3_column_int failed due to memory
> allocation error? If sqlite3_column_int returns zero, I don’t know
> whether it succeeded or failed. In the event that it succeeded, then
> the return value from sqlite3_errcode is undefined. So even if
> sqlite3_column_int returns zero and sqlite3_errcode returns
> SQLITE_NOMEM, it could be that an allocation failed, but it could
> just as well be that the actual column value was zero and
> sqlite3_errcode randomly decided to return SQLITE_NOMEM because the
> return value is undefined because sqlite3_column_int succeeded.
> 
> I discovered from inspecting the source code (and then confirmed by
> testing) that if an sqlite3_column_* function fails, then the next
> sqlite3_step call will *also* fail with SQLITE_NOMEM (and that’s
> detectable because sqlite3_step returns a result code as its return
> value), but that doesn’t seem to be documented anywhere in the manual
> at all.
> 
> So what’s the proper way to check for errors in these functions?
> 
> Thanks!
-- 
Christopher Head


pgpC81VZwXE36.pgp
Description: OpenPGP digital signature
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Checking for errors in sqlite3_column_*

2018-06-07 Thread Christopher Head
Hello,
I have a question regarding checking for errors that occur when calling
sqlite3_column_*.

From this manual page:

https://sqlite.org/c3ref/column_blob.html

it seems that the only error that could occur (other than programmer
error, like out-of-bounds column index or calling it after something
other than SQLITE_ROW) is memory allocation error. That page says that,
in the event of memory allocation error, an appropriate default value
is returned and then sqlite3_errcode will return SQLITE_NOMEM.

From this manual page:

https://sqlite.org/c3ref/errcode.html

it states explicitly that, if the most recent call failed, then
sqlite3_errcode returns the error code, but if the most recent call
succeeded, then the return value is undefined.

So how do I check if sqlite3_column_int failed due to memory allocation
error? If sqlite3_column_int returns zero, I don’t know whether it
succeeded or failed. In the event that it succeeded, then the return
value from sqlite3_errcode is undefined. So even if sqlite3_column_int
returns zero and sqlite3_errcode returns SQLITE_NOMEM, it could be that
an allocation failed, but it could just as well be that the actual
column value was zero and sqlite3_errcode randomly decided to return
SQLITE_NOMEM because the return value is undefined because
sqlite3_column_int succeeded.

I discovered from inspecting the source code (and then confirmed by
testing) that if an sqlite3_column_* function fails, then the next
sqlite3_step call will *also* fail with SQLITE_NOMEM (and that’s
detectable because sqlite3_step returns a result code as its return
value), but that doesn’t seem to be documented anywhere in the manual at
all.

So what’s the proper way to check for errors in these functions?

Thanks!
-- 
Christopher Head


pgpTnVwWkaqQ0.pgp
Description: OpenPGP digital signature
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users