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.
This commit is contained in:
Dimitri Fontaine 2015-12-03 19:24:00 +01:00
parent 7c64a713d0
commit dca3dacf4b

View File

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