X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-postgresql%2Fpostgresql-sql.lisp;h=b4eaa821662e0304b0b02c52542b4ef488b7b723;hb=a3e1cd20eec3903790c6e8f126345558904488f4;hp=ae3c18ef936cf097ae5325b929ead2a73dbe14a3;hpb=6c70be35cc348b559d8aa869ecd0e14e27d5edbc;p=clsql.git diff --git a/db-postgresql/postgresql-sql.lisp b/db-postgresql/postgresql-sql.lisp index ae3c18e..b4eaa82 100644 --- a/db-postgresql/postgresql-sql.lisp +++ b/db-postgresql/postgresql-sql.lisp @@ -517,16 +517,23 @@ (defmethod database-probe (connection-spec (type (eql :postgresql))) + (when (find (second connection-spec) (database-list connection-spec type) + :key #'car :test #'string-equal) + t)) + +(defmethod database-list (connection-spec (type (eql :postgresql))) (destructuring-bind (host name user password) connection-spec + (declare (ignore name)) (let ((database (database-connect (list host "template1" user password) type))) (unwind-protect - (when - (find name (database-query "select datname from pg_database" - database :auto) - :key #'car :test #'string-equal) - t) - (database-disconnect database))))) + (progn + (setf (slot-value database 'clsql-base-sys::state) :open) + (mapcar #'car (database-query "select datname from pg_database" + database :auto))) + (progn + (database-disconnect database) + (setf (slot-value database 'clsql-base-sys::state) :closed)))))) (defmethod database-describe-table ((database postgresql-database) table) (database-query