[plt-scheme] Re: SQLite error

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Jul 22 10:52:30 EDT 2009

A new version of the package is now available that fixes this message.


On Wed, Jul 22, 2009 at 4:42 AM, Jens Axel Søgaard<jensaxel at soegaard.net> wrote:
> 2009/7/22 Thomas Chust <chust at web.de>:
>> I'm not sure whether it would really be worth the effort, but you
>> should in principle be able to tell the difference by using the pzTail
>> output parameter of the SQLite API function that compiles the
>> statement: If the tail pointer passed out is identical to the SQL
>> source pointer passed in, nothing has been compiled, if it's
>> different, at least one statement has been consumed by the parser.
>> Probably it is not completely trivial to implement that logic, though,
>> because the SQL source pointer passed to the SQLite API call is not
>> directly visible to Scheme code but rather some buffer allocated by
>> the FFI.
> Fortunately, the tail is already available. It is used in the current
> error message:
> (define (prepare db sql)
>  (let*-values
>     ([(stmt prep-status tail)
>       (sqlite3_prepare_v2 (db-handle db) sql)]
>      [(the-stmt) (wrap-finalizer (make-statement db stmt)
>                                  finalize)])
>   (when (not (zero? (string-length tail)))
>     (sqlite-error "You should only prepare one statement at a time! ~s" tail))
>   (when (handle-status db prep-status)
>     (if stmt
>         the-stmt
>         ;; the pointer is null; SQLite didn't raise an
>         ;; error but should have!
>         (sqlite-error "sqlite3_prepare_v2 returned a NULL pointer")))))
> Yet another way to get the "prepare one statement at a time" error,
> is to prepare a CREATE TABLES statement with an already existing table
> name.
> --
> Jens Axel Søgaard
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.