From dca3dacf4bb016b2f928a730987392f543b1b52a Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Thu, 3 Dec 2015 19:24:00 +0100 Subject: [PATCH] Don't issue useless MySQL catalog queries... When the option "WITH no foreign keys" is in use, it's not necessary to go read the foreign key information_schema bits at all, so just don't issue the query, and same thing with the "create no indexes" option. In no that old versions of MySQL, the referential_constraints table of information_schema doesn't exist, so this should make pgloader compatible with MySQL 5.0 something and earlier. --- src/sources/mysql/mysql.lisp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/sources/mysql/mysql.lisp b/src/sources/mysql/mysql.lisp index ec25427..8369cd3 100644 --- a/src/sources/mysql/mysql.lisp +++ b/src/sources/mysql/mysql.lisp @@ -201,6 +201,8 @@ &key materialize-views only-tables + (create-indexes t) + (foreign-keys t) including excluding) "MySQL introspection to prepare the migration." @@ -230,14 +232,6 @@ :including including :excluding excluding) - all-fkeys (list-all-fkeys :only-tables only-tables - :including including - :excluding excluding) - - all-indexes (list-all-indexes :only-tables only-tables - :including including - :excluding excluding) - view-columns (cond (view-names (list-all-columns :only-tables view-names :table-type :view)) @@ -245,6 +239,16 @@ ((eq :all materialize-views) (list-all-columns :table-type :view)))) + (when foreign-keys + (setf all-fkeys (list-all-fkeys :only-tables only-tables + :including including + :excluding excluding))) + + (when create-indexes + (setf all-indexes (list-all-indexes :only-tables only-tables + :including including + :excluding excluding))) + ;; return how many objects we're going to deal with in total ;; for stats collection (+ (length all-columns) (length all-fkeys) @@ -307,6 +311,8 @@ (fetch-mysql-metadata mysql :materialize-views materialize-views :only-tables only-tables + :create-indexes create-indexes + :foreign-keys foreign-keys :including including :excluding excluding)