mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 18:36:12 +02:00
Fix setting of PostgreSQL GUCs and transaction usage for DDL.
This commit is contained in:
parent
a123cd472b
commit
2a65a1d39f
@ -166,6 +166,7 @@ select relname, array_agg(case when typname in ('date', 'timestamptz')
|
||||
(defun reset-all-sequences (dbname &key tables)
|
||||
"Reset all sequences to the max value of the column they are attached to."
|
||||
(pomo:with-connection (get-connection-spec dbname)
|
||||
(set-session-gucs *pg-settings*)
|
||||
(pomo:execute "set client_min_messages to warning;")
|
||||
(pomo:execute "listen seqs")
|
||||
|
||||
@ -210,13 +211,12 @@ $$; " tables)))
|
||||
(cl-postgres:postgresql-notification (c)
|
||||
(parse-integer (cl-postgres:postgresql-notification-payload c))))))
|
||||
|
||||
(defun list-table-oids (dbname table-names)
|
||||
(defun list-table-oids (table-names)
|
||||
"Return an alist of (TABLE-NAME . TABLE-OID) for all table in the
|
||||
TABLE-NAMES list."
|
||||
(pomo:with-connection (get-connection-spec dbname)
|
||||
(loop for (name oid)
|
||||
in (pomo:query
|
||||
(format nil
|
||||
"select n, n::regclass::oid from (values ~{('~a')~^,~}) as t(n)"
|
||||
table-names))
|
||||
collect (cons name oid))))
|
||||
TABLE-NAMES list. A connection must be established already."
|
||||
(loop for (name oid)
|
||||
in (pomo:query
|
||||
(format nil
|
||||
"select n, n::regclass::oid from (values ~{('~a')~^,~}) as t(n)"
|
||||
table-names))
|
||||
collect (cons name oid)))
|
||||
|
||||
@ -179,7 +179,7 @@ GROUP BY table_name, index_name;" dbname)))
|
||||
;; free resources
|
||||
(cl-mysql:disconnect)))
|
||||
|
||||
(defun set-table-oids (dbname all-indexes)
|
||||
(defun set-table-oids (all-indexes)
|
||||
"MySQL allows using the same index name against separate tables, which
|
||||
PostgreSQL forbids. To get unicity in index names without running out of
|
||||
characters (we are allowed only 63), we use the table OID instead.
|
||||
@ -187,7 +187,7 @@ GROUP BY table_name, index_name;" dbname)))
|
||||
This function grabs the table OIDs in the PostgreSQL database and update
|
||||
the definitions with them."
|
||||
(let* ((table-names (mapcar #'car all-indexes))
|
||||
(table-oids (pgloader.pgsql:list-table-oids dbname table-names)))
|
||||
(table-oids (pgloader.pgsql:list-table-oids table-names)))
|
||||
(loop for (table-name . indexes) in all-indexes
|
||||
for table-oid = (cdr (assoc table-name table-oids :test #'string=))
|
||||
unless table-oid do (error "OID not found for ~s." table-name)
|
||||
|
||||
@ -224,7 +224,7 @@
|
||||
;; MySQL allows the same index name being used against several
|
||||
;; tables, so we add the PostgreSQL table OID in the index name,
|
||||
;; to differenciate. Set the table oids now.
|
||||
(set-table-oids dbname all-indexes))))
|
||||
(set-table-oids all-indexes))))
|
||||
|
||||
(loop
|
||||
for (table-name . columns) in all-columns
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user