Skip to content

Commit

Permalink
Attempt to fix foreign-key creation to tables that have been filtered…
Browse files Browse the repository at this point in the history
… out.

See #1016 where we try to build the DDL for a foreign key that references
tables that are not found in our catalogs. We should probably just ignore
those foreign keys, as we might have a partial load to implement.
  • Loading branch information
dimitri committed Feb 12, 2020
1 parent 2e8ce7a commit 3b5c29b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pgsql/pgsql-create-schema.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,15 @@
(let ((fk-sql-list
(loop :for table :in (table-list catalog)
:append (loop :for fkey :in (table-fkey-list table)
:for sql := (format-create-sql fkey)
:collect sql)
;; we might have loaded fkeys referencing tables that
;; have not been included in (or have been excluded
;; from) the load
:unless (and (fkey-table fkey)
(fkey-foreign-table fkey))
:do (log-message :debug "Skipping foreign key ~a" fkey)
:when (and (fkey-table fkey)
(fkey-foreign-table fkey))
:collect (format-create-sql fkey))
:append (loop :for index :in (table-index-list table)
:do (loop :for fkey :in (index-fk-deps index)
:for sql := (format-create-sql fkey)
Expand Down

0 comments on commit 3b5c29b

Please sign in to comment.