From 533a49a261913e1346a3718966602ed421faf2f6 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Tue, 24 Nov 2015 10:52:25 +0100 Subject: [PATCH] Handle PostgreSQL notifications early, fix #311. In some cases, like when client_min_messages is set to debug5, PostgreSQL might send notification messages to the connecting client even while opening a connection. Those are still considered WARNINGs by the Postmodern driver... Handle those warnings by just printing them out in the pgloader logs, rather than considering those conditions as hard failures (signaling a db-connection-error). --- src/connection.lisp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/connection.lisp b/src/connection.lisp index ecc199e..8371c3a 100644 --- a/src/connection.lisp +++ b/src/connection.lisp @@ -140,7 +140,14 @@ (let ((conn (gensym "conn"))) `(let* ((,conn ,connection) (,var (handler-case - (open-connection ,conn) + ;; in some cases (client_min_messages set to debug5 + ;; for example), PostgreSQL might send us some + ;; WARNINGs already when opening a new connection + (handler-bind ((cl-postgres:postgresql-warning + #'(lambda (w) + (log-message :warning "~a" w) + (muffle-warning)))) + (open-connection ,conn)) (condition (e) (cond ((typep ,connection 'fd-connection) (error 'fd-connection-error