X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-postgresql%2Fpostgresql-sql.lisp;h=b4eaa821662e0304b0b02c52542b4ef488b7b723;hb=a3e1cd20eec3903790c6e8f126345558904488f4;hp=5758730e07f19486a79086b364456f3277a8a080;hpb=064bb338ef1375940085db10ec5a202d32e6b68b;p=clsql.git diff --git a/db-postgresql/postgresql-sql.lisp b/db-postgresql/postgresql-sql.lisp index 5758730..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 @@ -536,12 +543,7 @@ and a.attnum > 0 and a.attrelid = c.oid and a.atttypid = t.oid" - (sql-escape (string-downcase - (etypecase table - (string table) - (clsql-base-sys::sql-create-table - (symbol-name - (slot-value table 'clsql-base-sys::name))))))) + (sql-escape (string-downcase table))) database :auto)) (defun %pg-database-connection (connection-spec)