From f20a5a0667e11c7253caf6c53e8651c011f525af Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Fri, 25 Aug 2017 01:47:49 +0200 Subject: [PATCH] Fix schema name comparing with quoted schema names. In the previous commit we introduced support for database names including spaces, which means that by default pgloader creates a target schema in PostgreSQL with a space in its name. That works well as soon as you always double-quote the schema name, which pgloader does. Now, in our internal catalogs, we keep the schema name double-quoted. And when comparing that schema names with quotes to the raw schema name from PostgreSQL, they won't match, and pgloader tries to create the schema again: ERROR Database error 42P06: schema "my sql" already exists Fix the comparing to compare unquoted schema name, fix #614 again: the previous fix would only work the first time. --- src/pgsql/pgsql-create-schema.lisp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pgsql/pgsql-create-schema.lisp b/src/pgsql/pgsql-create-schema.lisp index 8c3b1c4..e3fc370 100644 --- a/src/pgsql/pgsql-create-schema.lisp +++ b/src/pgsql/pgsql-create-schema.lisp @@ -69,7 +69,7 @@ (when include-drop ;; if asked, first DROP the schema CASCADE. (loop :for schema :in (catalog-schema-list catalog) - :for schema-name := (schema-name schema) + :for schema-name := (ensure-unquoted (schema-name schema)) :when (and schema-name (member schema-name schema-list :test #'string=)) :do (let ((sql (format nil "DROP SCHEMA ~a CASCADE;" schema-name))) @@ -77,7 +77,7 @@ ;; now create the schemas (again?) (loop :for schema :in (catalog-schema-list catalog) - :for schema-name := (schema-name schema) + :for schema-name := (ensure-unquoted (schema-name schema)) :when (and schema-name (or include-drop (not (member schema-name schema-list :test #'string=))))