X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-postgresql-socket%2Fpostgresql-socket-sql.lisp;h=1e29c070d6749dfac59dcc88dde53898c397aff0;hb=6c70be35cc348b559d8aa869ecd0e14e27d5edbc;hp=9a2f02d04b60d843defdbae8ba9b298c8bc3c8e7;hpb=e5744a78271044484b3399d4fc1d55b3e8808784;p=clsql.git diff --git a/db-postgresql-socket/postgresql-socket-sql.lisp b/db-postgresql-socket/postgresql-socket-sql.lisp index 9a2f02d..1e29c07 100644 --- a/db-postgresql-socket/postgresql-socket-sql.lisp +++ b/db-postgresql-socket/postgresql-socket-sql.lisp @@ -194,6 +194,7 @@ doesn't depend on UFFI." (make-instance 'postgresql-socket-database :name (database-name-from-spec connection-spec database-type) + :database-type :postgresql-socket :connection-spec connection-spec :connection connection))))) @@ -430,16 +431,20 @@ doesn't depend on UFFI." (defmethod database-create (connection-spec (type (eql :postgresql-socket))) - (error 'clsql-access-error - :connection-spec connection-spec - :database-type type - :error "Unable to create databases on a socket connection.")) + (destructuring-bind (host name user password) connection-spec + (let ((database (database-connect (list host "template1" user password) + type))) + (unwind-protect + (execute-command (format nil "create database ~A" name)) + (database-disconnect database))))) (defmethod database-destroy (connection-spec (type (eql :postgresql-socket))) - (error 'clsql-access-error - :connection-spec connection-spec - :database-type type - :error "Unable to create databases on a socket connection.")) + (destructuring-bind (host name user password) connection-spec + (let ((database (database-connect (list host "template1" user password) + type))) + (unwind-protect + (execute-command (format nil "drop database ~A" name)) + (database-disconnect database))))) (defmethod database-probe (connection-spec (type (eql :postgresql-socket))) (destructuring-bind (host name user password) connection-spec @@ -453,5 +458,17 @@ doesn't depend on UFFI." t) (database-disconnect database))))) +(defmethod database-describe-table ((database postgresql-socket-database) + table) + (database-query + (format nil "select a.attname, t.typname + from pg_class c, pg_attribute a, pg_type t + where c.relname = '~a' + and a.attnum > 0 + and a.attrelid = c.oid + and a.atttypid = t.oid" + (sql-escape (string-downcase table))) + database :auto)) + (when (clsql-base-sys:database-type-library-loaded :postgresql-socket) (clsql-base-sys:initialize-database-type :database-type :postgresql-socket))