On Tue, Mar 13, 2012 at 7:06 PM, Rob Richardson <rdrichard...@rad-con.com>wrote:

> Thank you very much for your quick reply, Dr. Hipp, and I will fix my
> code.  Probably I was trying to execute a statement before opening the
> database.
>
> But the question remains:  Should sqlite_exec() always generate an error
> message, or should I be prepared to handle the case in which it does not?
>  (Which I've already done: not hard and cleaner code anyway.)
>

SQLite3_exec() should always generate an error message, but with two
exceptions:

(1) When malloc() fails trying to allocate space to hold the error message
(2) In an SQLITE_MISUSE situation because the malloc() subsystem might not
even be initialized.


>
> RobR
>
> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org [mailto:
> sqlite-users-boun...@sqlite.org] On Behalf Of Richard Hipp
> Sent: Tuesday, March 13, 2012 6:47 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] No error message generated by sqlite_exec()
>
> On Tue, Mar 13, 2012 at 6:43 PM, Rob Richardson <rdrichard...@rad-con.com
> >wrote:
>
> > Hello!
> >
> > I am sending a badly formed query string to sqlite_exec().  It is
> > giving me error 21 (misuse of library), but it is not giving me an error
> message.
> >  The value of the pointer sent as the fifth argument of sqlite_exec()
> > is not changed.  Is this expected behavior?  Is there something I have
> > to do to tell sqlite that I want the error message to be generated?
> >
>
> If you are getting back SQLITE_MISUSE, that probably means you are calling
> sqlite3_exec() with a database connection that has previously been closed.
> SQLite tries to catch that situation and report the SQLITE_MISUSE error,
> but there are no guarantees that doing so will work.  Depending on how
> malloc() is implemented on your system, it might segfault instead.
>
> So:  Don't call sqlite3_exec() with a closed database connection.
>
> General rule:  You should never do anything to SQLite that causes it to
> return SQLITE_MISUSE.  If you do, there is an error in your code.  Fix your
> code.
>
>
> >
> > Thank you very much.
> >
> > RobR
> > _______________________________________________
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> >
>
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to