mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 18:36:12 +02:00
Refrain from some introspections on non-PGDG PostgreSQL variants.
When dealing with PostgreSQL protocol compatible databases, often enough they don't support the same catalogs as PostgreSQL itself. Redshift for instance lacks foreign key support.
This commit is contained in:
parent
d3bfb1db31
commit
cb633aa092
@ -42,7 +42,9 @@
|
||||
(handler-case
|
||||
(with-pgsql-connection (pgconn)
|
||||
(setf pgsql-catalog
|
||||
(fetch-pgsql-catalog (db-name pgconn) :table (target copy)))
|
||||
(fetch-pgsql-catalog (db-name pgconn)
|
||||
:table (target copy)
|
||||
:variant (pgconn-variant pgconn)))
|
||||
|
||||
;; if the user didn't tell us the column list of the table, now is
|
||||
;; a proper time to set it in the copy object
|
||||
|
||||
@ -5,7 +5,12 @@
|
||||
(in-package :pgloader.pgsql)
|
||||
|
||||
(defun fetch-pgsql-catalog (dbname
|
||||
&key table source-catalog including excluding)
|
||||
&key
|
||||
table
|
||||
source-catalog
|
||||
including
|
||||
excluding
|
||||
(variant :pgdg))
|
||||
"Fetch PostgreSQL catalogs for the target database. A PostgreSQL
|
||||
connection must be opened."
|
||||
(let* ((*identifier-case* :quote)
|
||||
@ -18,10 +23,10 @@
|
||||
|
||||
(t
|
||||
including))))
|
||||
|
||||
(list-all-sqltypes catalog
|
||||
:including including
|
||||
:excluding excluding)
|
||||
(when (eq :pgdg variant)
|
||||
(list-all-sqltypes catalog
|
||||
:including including
|
||||
:excluding excluding))
|
||||
|
||||
(list-all-columns catalog
|
||||
:table-type :table
|
||||
@ -32,14 +37,15 @@
|
||||
:including including
|
||||
:excluding excluding)
|
||||
|
||||
(list-all-fkeys catalog
|
||||
:including including
|
||||
:excluding excluding)
|
||||
(when (eq :pgdg variant)
|
||||
(list-all-fkeys catalog
|
||||
:including including
|
||||
:excluding excluding)
|
||||
|
||||
;; fetch fkey we depend on with UNIQUE indexes but that have been
|
||||
;; excluded from the target list, we still need to take care of them to
|
||||
;; be able to DROP then CREATE those indexes again
|
||||
(list-missing-fk-deps catalog)
|
||||
;; fetch fkey we depend on with UNIQUE indexes but that have been
|
||||
;; excluded from the target list, we still need to take care of them to
|
||||
;; be able to DROP then CREATE those indexes again
|
||||
(list-missing-fk-deps catalog))
|
||||
|
||||
(log-message :debug "fetch-pgsql-catalog: ~d tables, ~d indexes, ~d+~d fkeys"
|
||||
(count-tables catalog)
|
||||
|
||||
@ -64,27 +64,29 @@
|
||||
:use-result-as-read t
|
||||
:section :pre)
|
||||
(with-pgsql-transaction (:pgconn (source-db pgsql))
|
||||
(list-all-sqltypes catalog
|
||||
(let ((variant (pgconn-variant (source-db pgsql))))
|
||||
(when (eq :pgdg variant)
|
||||
(list-all-sqltypes catalog
|
||||
:including including
|
||||
:excluding excluding))
|
||||
|
||||
(list-all-columns catalog
|
||||
:including including
|
||||
:excluding excluding)
|
||||
|
||||
(list-all-columns catalog
|
||||
:including including
|
||||
:excluding excluding)
|
||||
(when create-indexes
|
||||
(list-all-indexes catalog
|
||||
:including including
|
||||
:excluding excluding))
|
||||
|
||||
(when create-indexes
|
||||
(list-all-indexes catalog
|
||||
:including including
|
||||
:excluding excluding))
|
||||
(when (and (eq :pgdg variant) foreign-keys)
|
||||
(list-all-fkeys catalog
|
||||
:including including
|
||||
:excluding excluding))
|
||||
|
||||
(when foreign-keys
|
||||
(list-all-fkeys catalog
|
||||
:including including
|
||||
:excluding excluding))
|
||||
|
||||
;; return how many objects we're going to deal with in total
|
||||
;; for stats collection
|
||||
(+ (count-tables catalog) (count-indexes catalog))))
|
||||
;; return how many objects we're going to deal with in total
|
||||
;; for stats collection
|
||||
(+ (count-tables catalog) (count-indexes catalog)))))
|
||||
|
||||
;; be sure to return the catalog itself
|
||||
catalog)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user