mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-08 07:16:58 +02:00
Fix schema qualified table names usage again.
When the list of columns of the PostgreSQL target table isn't given in the load command, pgloader will happily query the system catalogs to get that information. The list-columns query didn't get the memo about the qualified table name format and the with-schema macro... fix #288.
This commit is contained in:
parent
e054eb3838
commit
a0dc59624c
@ -184,20 +184,22 @@
|
|||||||
(defun list-columns (pgconn table-name &key schema)
|
(defun list-columns (pgconn table-name &key schema)
|
||||||
"Return a list of column names for given TABLE-NAME."
|
"Return a list of column names for given TABLE-NAME."
|
||||||
(with-pgsql-transaction (:pgconn pgconn)
|
(with-pgsql-transaction (:pgconn pgconn)
|
||||||
(pomo:query (format nil "
|
(with-schema (unqualified-table-name table-name)
|
||||||
|
(pomo:query (format nil "
|
||||||
select attname
|
select attname
|
||||||
from pg_class c
|
from pg_class c
|
||||||
join pg_namespace n on n.oid = c.relnamespace
|
join pg_namespace n on n.oid = c.relnamespace
|
||||||
left join pg_attribute a on c.oid = a.attrelid
|
left join pg_attribute a on c.oid = a.attrelid
|
||||||
join pg_type t on t.oid = a.atttypid
|
join pg_type t on t.oid = a.atttypid
|
||||||
where c.oid = '~:[~*~a~;~a.~a~]'::regclass and attnum > 0
|
where c.oid = '~:[~*~a~;~a.~a~]'::regclass and attnum > 0
|
||||||
order by attnum" schema schema table-name) :column)))
|
order by attnum" schema schema unqualified-table-name) :column))))
|
||||||
|
|
||||||
(defun list-indexes (table-name)
|
(defun list-indexes (table-name)
|
||||||
"List all indexes for TABLE-NAME in SCHEMA. A PostgreSQL connection must
|
"List all indexes for TABLE-NAME in SCHEMA. A PostgreSQL connection must
|
||||||
be already established when calling that function."
|
be already established when calling that function."
|
||||||
(loop :for (index-name table-name table-oid primary unique sql conname condef)
|
(with-schema (unqualified-table-name table-name)
|
||||||
:in (pomo:query (format nil "
|
(loop :for (index-name table-name table-oid primary unique sql conname condef)
|
||||||
|
:in (pomo:query (format nil "
|
||||||
select i.relname,
|
select i.relname,
|
||||||
indrelid::regclass,
|
indrelid::regclass,
|
||||||
indrelid,
|
indrelid,
|
||||||
@ -210,20 +212,18 @@ select i.relname,
|
|||||||
join pg_class i ON i.oid = x.indexrelid
|
join pg_class i ON i.oid = x.indexrelid
|
||||||
left join pg_constraint c ON c.conindid = i.oid
|
left join pg_constraint c ON c.conindid = i.oid
|
||||||
where indrelid = '~@[~a.~]~a'::regclass"
|
where indrelid = '~@[~a.~]~a'::regclass"
|
||||||
(when (typep table-name 'cons)
|
(when (typep table-name 'cons)
|
||||||
(car table-name))
|
(car table-name))
|
||||||
(typecase table-name
|
unqualified-table-name))
|
||||||
(cons (cdr table-name))
|
:collect (make-pgsql-index :name index-name
|
||||||
(string table-name))))
|
:table-name table-name
|
||||||
:collect (make-pgsql-index :name index-name
|
:table-oid table-oid
|
||||||
:table-name table-name
|
:primary primary
|
||||||
:table-oid table-oid
|
:unique unique
|
||||||
:primary primary
|
:columns nil
|
||||||
:unique unique
|
:sql sql
|
||||||
:columns nil
|
:conname (unless (eq :null conname) conname)
|
||||||
:sql sql
|
:condef (unless (eq :null condef) condef)))))
|
||||||
:conname (unless (eq :null conname) conname)
|
|
||||||
:condef (unless (eq :null condef) condef))))
|
|
||||||
|
|
||||||
(defun list-reserved-keywords (pgconn)
|
(defun list-reserved-keywords (pgconn)
|
||||||
"Connect to PostgreSQL DBNAME and fetch reserved keywords."
|
"Connect to PostgreSQL DBNAME and fetch reserved keywords."
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
LOAD CSV
|
LOAD CSV
|
||||||
FROM INLINE
|
FROM INLINE
|
||||||
INTO postgresql:///pgloader?header
|
INTO postgresql:///pgloader?public.header
|
||||||
|
|
||||||
WITH truncate,
|
WITH truncate,
|
||||||
fields terminated by ',',
|
fields terminated by ',',
|
||||||
|
Loading…
Reference in New Issue
Block a user