From d7b05ba4113bb736609bf790de5158ad6d435416 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Sun, 11 May 2014 18:52:07 +0200 Subject: [PATCH] Handle more conditions, fix #57. Turns out that in cases it's not possible to call format-vector-row on MySQL result sets, because it's been sending us vector of bytes (blob) while the expected data (from the table definition) clearly is text. Handle the error as an input reading error, skipping the line and being verbose about it in the logs. This patch fails to update the stats about what's happening because, so might need later changes. --- src/queue.lisp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/queue.lisp b/src/queue.lisp index 6ddd49f..55925c8 100644 --- a/src/queue.lisp +++ b/src/queue.lisp @@ -46,17 +46,21 @@ ;; ;; All the data transformation takes place here, so that we batch fully ;; formed COPY TEXT string ready to go in the PostgreSQL stream. - (let ((copy-string (with-output-to-string (s) - (format-vector-row s row (transforms copy))))) - (with-slots (data count bytes) *current-batch* - (setf (aref data count) copy-string) - (when *copy-batch-size* ; running under memory watch - (incf bytes - #+sbcl (length - (sb-ext:string-to-octets copy-string :external-format :utf-8)) - #+ccl (ccl:string-size-in-octets copy-string :external-format :utf-8) - #- (or sbcl ccl) (length copy-string))) - (incf count)))) + (handler-case + (let ((copy-string (with-output-to-string (s) + (format-vector-row s row (transforms copy))))) + (with-slots (data count bytes) *current-batch* + (setf (aref data count) copy-string) + (when *copy-batch-size* ; running under memory watch + (incf bytes + #+sbcl (length + (sb-ext:string-to-octets copy-string :external-format :utf-8)) + #+ccl (ccl:string-size-in-octets copy-string :external-format :utf-8) + #- (or sbcl ccl) (length copy-string))) + (incf count))) + + (condition (e) + (log-message :error "~a" e)))) (defun map-push-queue (copy queue) "Apply MAP-ROWS on the COPY instance and a function of ROW that will push