From 5faf8605ce3de72b964eac48b3dfec73fe97569d Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Sat, 17 Jun 2017 18:16:18 +0200 Subject: [PATCH] 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. --- src/pgsql/pgsql-create-schema.lisp | 8 +++++--- src/sources/common/db-methods.lisp | 8 ++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/pgsql/pgsql-create-schema.lisp b/src/pgsql/pgsql-create-schema.lisp index 8818d3d..4def048 100644 --- a/src/pgsql/pgsql-create-schema.lisp +++ b/src/pgsql/pgsql-create-schema.lisp @@ -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))))) diff --git a/src/sources/common/db-methods.lisp b/src/sources/common/db-methods.lisp index 36bf53c..e24a5bb 100644 --- a/src/sources/common/db-methods.lisp +++ b/src/sources/common/db-methods.lisp @@ -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))