From 7af6c7ac41da332060566f79fd3a63dfe83dbfc8 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Tue, 19 Apr 2016 17:23:05 -0400 Subject: [PATCH] Filter out incomplete foreign key definitions. It's possible that in MySQL a foreign key constraint definition is pointing to a non-existing table. In such a case, issue an error message and refrain from trying to then reinstall the faulty foreign key definition. The lack of error handling at this point led to a frozen instance of pgloader apparently, I think because it could not display the interactive debugger at the point where the error occurs. See #328, also #337 that might be fixed here. --- src/sources/mysql/mysql-schema.lisp | 8 +++++++- src/utils/monitor.lisp | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/sources/mysql/mysql-schema.lisp b/src/sources/mysql/mysql-schema.lisp index 3ee29ec..6d86409 100644 --- a/src/sources/mysql/mysql-schema.lisp +++ b/src/sources/mysql/mysql-schema.lisp @@ -306,7 +306,13 @@ FROM (sq:split-sequence #\, fcols)) :update-rule update-rule :delete-rule delete-rule))) - (add-fkey table fk)) + (if (and name table ftable) + (add-fkey table fk) + (log-message :error + "Incomplete Foreign Key definition: constraint ~s on table ~s referencing table ~s" + name + (when table (format-table-name table)) + (when ftable (format-table-name ftable))))) :finally (return schema))) diff --git a/src/utils/monitor.lisp b/src/utils/monitor.lisp index a71136e..34924e3 100644 --- a/src/utils/monitor.lisp +++ b/src/utils/monitor.lisp @@ -198,7 +198,8 @@ (format nil "~{~}" (log-message-description event) (log-message-arguments event)) - (log-message-description event)))) + (log-message-description event))) + (*print-circle* t)) (cl-log:log-message (log-message-category event) "~a" mesg))) (new-label