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.
This commit is contained in:
Dimitri Fontaine 2017-08-25 01:47:49 +02:00
parent 9d4743f598
commit f20a5a0667

View File

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