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.
This commit is contained in:
Dimitri Fontaine 2016-04-19 17:23:05 -04:00
parent 42e9e521e0
commit 7af6c7ac41
2 changed files with 9 additions and 2 deletions

View File

@ -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)))

View File

@ -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