X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-postgresql%2Fpostgresql-sql.lisp;h=d5a13f29befdbbc5eb86c7a5737e2a98e41f9954;hb=e8c000a120f978e464441838fe1576e6afc94d9d;hp=2d307c243f439db4848a38243618010cb718c159;hpb=31507a81fff1da3460625fbc07107de931907a8e;p=clsql.git diff --git a/db-postgresql/postgresql-sql.lisp b/db-postgresql/postgresql-sql.lisp index 2d307c2..d5a13f2 100644 --- a/db-postgresql/postgresql-sql.lisp +++ b/db-postgresql/postgresql-sql.lisp @@ -127,12 +127,14 @@ (declare (type pgsql-conn-def connection)) (when (not (eq (PQstatus connection) pgsql-conn-status-type#connection-ok)) - (error 'sql-connection-error - :database-type database-type - :connection-spec connection-spec - :error-id (PQstatus connection) - :message (tidy-error-message - (PQerrorMessage connection)))) + (let ((pqstatus (PQstatus connection)) + (pqmessage (tidy-error-message (PQerrorMessage connection)))) + (PQfinish connection) + (error 'sql-connection-error + :database-type database-type + :connection-spec connection-spec + :error-id pqstatus + :message pqmessage))) (make-instance 'postgresql-database :name (database-name-from-spec connection-spec database-type) @@ -412,7 +414,7 @@ (defmethod database-probe (connection-spec (type (eql :postgresql))) (when (find (second connection-spec) (database-list connection-spec type) - :key #'car :test #'string-equal) + :test #'string-equal) t)) @@ -428,7 +430,8 @@ (coerce-string user) (let ((connection (PQsetdbLogin host port options tty db user password))) (declare (type postgresql::pgsql-conn-ptr connection)) - (unless (eq (PQstatus connection) :connection-ok) + (unless (eq (PQstatus connection) + pgsql-conn-status-type#connection-ok) ;; Connect failed (error 'sql-connection-error :database-type :postgresql