r8930: add database-create for pg socket, documentation improvements
[clsql.git] / db-postgresql-socket / postgresql-socket-sql.lisp
index 9a2f02d04b60d843defdbae8ba9b298c8bc3c8e7..c304db07e1204c861cdb86c941224ae21d506e6d 100644 (file)
@@ -430,16 +430,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