From ba2d8669c3c22e4b4352ccaa6766f3f96edd80ea Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Mon, 22 Jan 2018 16:14:05 +0100 Subject: [PATCH] Add support for the newer Qmynd error handling. We now have a qmynd-impl::decoding-error condition to deal with, which as a very good error reporting, so that we don't need to poke into babel details anymore. The error message adds the column name, type and collation to the output, too. We keep the babel handlers for a while until people have all migrated to using the patch in qmynd. With the fix to Qmynd, Fix #716. --- src/sources/mysql/mysql.lisp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/sources/mysql/mysql.lisp b/src/sources/mysql/mysql.lisp index 34e5caf..78c5e06 100644 --- a/src/sources/mysql/mysql.lisp +++ b/src/sources/mysql/mysql.lisp @@ -88,12 +88,21 @@ (defun call-with-encoding-handler (copy-mysql table-name func) (handler-bind - ;; avoid trying to fetch the character at end-of-input position... - ((babel-encodings:end-of-input-in-character + ;; Newer versions of qmynd handle the babel error and signal this one + ;; with more details and an improved reporting: + ((qmynd-impl::decoding-error #'(lambda (c) (update-stats :data (target copy-mysql) :errs 1) (log-message :error "~a" c) (invoke-restart 'qmynd-impl::use-nil))) + + ;; Older versions of qmynd reported babel errors directly + (babel-encodings:end-of-input-in-character + #'(lambda (c) + (update-stats :data (target copy-mysql) :errs 1) + (log-message :error "~a" c) + (invoke-restart 'qmynd-impl::use-nil))) + (babel-encodings:character-decoding-error #'(lambda (c) (update-stats :data (target copy-mysql) :errs 1) @@ -104,7 +113,8 @@ (when (and position (< position (length buffer))) (aref buffer position)))) (log-message :error - "~a: Illegal ~a character starting at position ~a~@[: ~a~]." + "While decoding text data from MySQL table ~s: ~%~ +Illegal ~a character starting at position ~a~@[: ~a~].~%" table-name encoding position character)) (invoke-restart 'qmynd-impl::use-nil)))) (funcall func)))