Fix corner cases and how we log them.

In the prepare-pgsql-database method we were logging too much details, such
as DDL warnings on if-not-exists for successful queries. And those logs are
to be found in PostgreSQL server logs anyway.

Also fix trying to create or drop a "nil" schema.
This commit is contained in:
Dimitri Fontaine 2017-06-17 18:16:18 +02:00
parent 6c931975de
commit 5faf8605ce
2 changed files with 11 additions and 5 deletions

View File

@ -70,15 +70,17 @@
;; if asked, first DROP the schema CASCADE.
(loop :for schema :in (catalog-schema-list catalog)
:for schema-name := (schema-name schema)
:when (member schema-name schema-list :test #'string=)
:when (and schema-name
(member schema-name schema-list :test #'string=))
:do (let ((sql (format nil "DROP SCHEMA ~a CASCADE;" schema-name)))
(pgsql-execute sql :client-min-messages client-min-messages))))
;; now create the schemas (again?)
(loop :for schema :in (catalog-schema-list catalog)
:for schema-name := (schema-name schema)
:when (or include-drop
(not (member schema-name schema-list :test #'string=)))
:when (and schema-name
(or include-drop
(not (member schema-name schema-list :test #'string=))))
:do (let ((sql (format nil "CREATE SCHEMA ~a;" (schema-name schema))))
(pgsql-execute sql :client-min-messages client-min-messages)))))

View File

@ -31,7 +31,9 @@
(with-stats-collection ("Create Schemas" :section :pre
:use-result-as-read t
:use-result-as-rows t)
(create-schemas catalog :include-drop include-drop)))
(create-schemas catalog
:include-drop include-drop
:client-min-messages :error)))
(if create-tables
(progn
@ -100,7 +102,9 @@
(with-stats-collection ("Create MatViews Tables" :section :pre
:use-result-as-read t
:use-result-as-rows t)
(create-views catalog :include-drop include-drop))))
(create-views catalog
:include-drop include-drop
:client-min-messages :error))))
;; log the catalog we just fetched and (maybe) merged
(log-message :data "CATALOG: ~s" catalog))