Any well-formed single statement query which is terminated by a semi-colon and has extra space after the semi-colon raises 'multiple statements given' error.
The cause is any extra space after a terminating semi-colon in a SQL string passed to sqlite3_prepare_v2 procedure in the prepare1* method of `db` Sqlite3 connection% implementation will result in non-false tail and zero prep-status values being returned. The checking code sees the non-false tail value and raises the "multiple statements given" exception. The easy fix is to trim any trailing whitespace by calling string-trim on the buffer string before its converted to a byte string in the copy-buffer procedure used by sqlite3_prepare_v2 to initialize the sql-buffer. See Issue #1702
This commit is contained in:
parent
31d7dd0317
commit
dfd585db33
|
@ -2,6 +2,7 @@
|
||||||
(require (for-syntax racket/base
|
(require (for-syntax racket/base
|
||||||
setup/cross-system)
|
setup/cross-system)
|
||||||
racket/runtime-path
|
racket/runtime-path
|
||||||
|
racket/string
|
||||||
ffi/unsafe
|
ffi/unsafe
|
||||||
ffi/unsafe/define
|
ffi/unsafe/define
|
||||||
setup/cross-system)
|
setup/cross-system)
|
||||||
|
@ -60,7 +61,7 @@
|
||||||
;; -- Stmt --
|
;; -- Stmt --
|
||||||
|
|
||||||
(define (copy-buffer buffer)
|
(define (copy-buffer buffer)
|
||||||
(let* ([buffer (string->bytes/utf-8 buffer)]
|
(let* ([buffer (string->bytes/utf-8 (string-trim buffer))]
|
||||||
[n (bytes-length buffer)]
|
[n (bytes-length buffer)]
|
||||||
[rawcopy (malloc (add1 n) 'atomic-interior)]
|
[rawcopy (malloc (add1 n) 'atomic-interior)]
|
||||||
[copy (make-sized-byte-string rawcopy n)])
|
[copy (make-sized-byte-string rawcopy n)])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user