X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-postgresql%2Fpostgresql-sql.lisp;h=2d74fc1179e160d765645b66597038a2344080d9;hb=eb52183ddb786552d5abf6fdfaaca657e0c56ea0;hp=9b4e2503f0b5ac415a64147cad594385c20b6283;hpb=fc58e4fb7d908985389c86adf57ddee6c1dde5d2;p=clsql.git diff --git a/db-postgresql/postgresql-sql.lisp b/db-postgresql/postgresql-sql.lisp index 9b4e250..2d74fc1 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) @@ -220,7 +222,7 @@ (error 'sql-database-data-error :database database :expression sql-expression - :error-id (PQresultStatus result) + :error-id (uffi:convert-from-foreign-string (PQresultErrorField result +PG-DIAG-SQLSTATE+)) :message (tidy-error-message (PQresultErrorMessage result))))) (PQclear result))))))