sqlite3_prepare_v2 with an empty statement.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

sqlite3_prepare_v2 with an empty statement.

Peter da Silva
In the documentation for sqlite3_prepare_v2, it says:

*ppStmt is left pointing to a compiled prepared statement<https://www.sqlite.org/c3ref/stmt.html> that can be executed using sqlite3_step()<https://www.sqlite.org/c3ref/step.html>. If there is an error, *ppStmt is set to NULL. If the input text contains no SQL (if the input is an empty string or a comment) then *ppStmt is set to NULL. The calling procedure is responsible for deleting the compiled SQL statement using sqlite3_finalize()<https://www.sqlite.org/c3ref/finalize.html> after it has finished with it. ppStmt may not be NULL.

Is an empty SQL statement always an error, i.e. is it possible for sqlite3_prepare_v2 to return SQLITE_OK while leaving *ppStmt NULL? I have been assuming not, but I’m tracking down a hard-to-find bug and double-checking all my assumptions.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: sqlite3_prepare_v2 with an empty statement.

Dan Kennedy-4
On 07/24/2018 09:05 PM, Peter Da Silva wrote:
> In the documentation for sqlite3_prepare_v2, it says:
>
> *ppStmt is left pointing to a compiled prepared statement<https://www.sqlite.org/c3ref/stmt.html> that can be executed using sqlite3_step()<https://www.sqlite.org/c3ref/step.html>. If there is an error, *ppStmt is set to NULL. If the input text contains no SQL (if the input is an empty string or a comment) then *ppStmt is set to NULL. The calling procedure is responsible for deleting the compiled SQL statement using sqlite3_finalize()<https://www.sqlite.org/c3ref/finalize.html> after it has finished with it. ppStmt may not be NULL.
>
> Is an empty SQL statement always an error, i.e. is it possible for sqlite3_prepare_v2 to return SQLITE_OK while leaving *ppStmt NULL?

No. An empty SQL statement is not an error. prepare_v2() should return
SQLITE_OK and sets *ppStmt to NULL.

Dan.

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users