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 <ch...@chead.ca> 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
Description: OpenPGP digital signature
_______________________________________________ sqlite-users mailing list email@example.com http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users