diff --git a/src/pgsql/queries.lisp b/src/pgsql/queries.lisp index f5672f6..fd62722 100644 --- a/src/pgsql/queries.lisp +++ b/src/pgsql/queries.lisp @@ -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))) diff --git a/src/sources/mysql-schema.lisp b/src/sources/mysql-schema.lisp index 98b4f7d..00fa140 100644 --- a/src/sources/mysql-schema.lisp +++ b/src/sources/mysql-schema.lisp @@ -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) diff --git a/src/sources/mysql.lisp b/src/sources/mysql.lisp index ae6f653..b5fa644 100644 --- a/src/sources/mysql.lisp +++ b/src/sources/mysql.lisp @@ -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