Fix setting of PostgreSQL GUCs and transaction usage for DDL.

This commit is contained in:
Dimitri Fontaine 2013-11-12 11:34:31 +01:00
parent a123cd472b
commit 2a65a1d39f
3 changed files with 12 additions and 12 deletions

View File

@ -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)))

View File

@ -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)

View File

@ -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