mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 10:31:02 +02:00
Handle errors when processing data from SQLite.
Some errors could be related to encoding issues, as in #99.
This commit is contained in:
parent
de910321ff
commit
b538539fb3
@ -165,24 +165,29 @@
|
||||
(string-equal "bytea" (cast (coldef-type field))))
|
||||
(fields sqlite))
|
||||
'vector)))
|
||||
(loop
|
||||
with statement = (sqlite:prepare-statement (db sqlite) sql)
|
||||
with len = (loop :for name :in (sqlite:statement-column-names statement)
|
||||
:count name)
|
||||
while (sqlite:step-statement statement)
|
||||
for row = (let ((v (make-array len)))
|
||||
(loop :for x :below len
|
||||
:for raw := (sqlite:statement-column-value statement x)
|
||||
:for val := (if (and (aref blobs-p x) (stringp raw))
|
||||
(base64:base64-string-to-usb8-array raw)
|
||||
raw)
|
||||
:do (setf (aref v x) val))
|
||||
v)
|
||||
counting t into rows
|
||||
do (funcall process-row-fn row)
|
||||
finally
|
||||
(sqlite:finalize-statement statement)
|
||||
(return rows))))
|
||||
(handler-case
|
||||
(loop
|
||||
with statement = (sqlite:prepare-statement (db sqlite) sql)
|
||||
with len = (loop :for name :in (sqlite:statement-column-names statement)
|
||||
:count name)
|
||||
while (sqlite:step-statement statement)
|
||||
for row = (let ((v (make-array len)))
|
||||
(loop :for x :below len
|
||||
:for raw := (sqlite:statement-column-value statement x)
|
||||
:for val := (if (and (aref blobs-p x) (stringp raw))
|
||||
(base64:base64-string-to-usb8-array raw)
|
||||
raw)
|
||||
:do (setf (aref v x) val))
|
||||
v)
|
||||
counting t into rows
|
||||
do (funcall process-row-fn row)
|
||||
finally
|
||||
(sqlite:finalize-statement statement)
|
||||
(return rows))
|
||||
(condition (e)
|
||||
(progn
|
||||
(log-message :error "~a" e)
|
||||
(pgstate-incf *state* (target sqlite) :errs 1))))))
|
||||
|
||||
|
||||
(defmethod copy-to-queue ((sqlite copy-sqlite) queue)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user