Implement support for Foreign Tables and Partitionned Tables.

Due to the way pgloader queries the PostgreSQL catalogs, it restricted the
target table to be “ordinary” tables, as per the relkind description in the
https://www.postgresql.org/docs/current/static/catalog-pg-class.html
PostgreSQL documentation.

Extend this to support relkind of 'r', 'f' and 'p'.

Fixes #587, fixes #690.
This commit is contained in:
Dimitri Fontaine 2017-12-01 22:13:47 +01:00
parent 52f13456d9
commit c05183fcba
3 changed files with 8 additions and 6 deletions

View File

@ -108,10 +108,11 @@
:single)))
(defvar *table-type* '((:table . "r")
(:view . "v")
(:index . "i")
(:sequence . "S"))
(defvar *table-type*
'((:table . ("r" "f" "p")) ; ordinary, foreign and partitioned
(:view . ("v"))
(:index . ("i"))
(:sequence . ("S")))
"Associate internal table type symbol with what's found in PostgreSQL
pg_class.relkind column.")

View File

@ -16,7 +16,7 @@
and a.attnum = def.adnum
where nspname !~~ '^pg_' and n.nspname <> 'information_schema'
and relkind = '~a'
and relkind in (~{'~a'~^, ~})
~:[~*~;and (~{~a~^~&~10t or ~})~]
~:[~*~;and (~{~a~^~&~10t and ~})~]

View File

@ -27,7 +27,8 @@
JOIN pg_class cf on r.confrelid = cf.oid
JOIN pg_namespace nf on cf.relnamespace = nf.oid
where r.contype = 'f'
AND c.relkind = 'r' and cf.relkind = 'r'
AND c.relkind in ('r', 'f', 'p')
AND cf.relkind in ('r', 'f', 'p')
AND n.nspname !~~ '^pg_' and n.nspname <> 'information_schema'
AND nf.nspname !~~ '^pg_' and nf.nspname <> 'information_schema'
~:[~*~;and (~{~a~^~&~10t or ~})~]