+(defmethod database-create (connection-spec (type (eql :postgresql-socket)))
+ (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)))
+ (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)))
+ (when (find (second connection-spec) (database-list connection-spec type)
+ :key #'car :test #'string-equal)
+ t))
+
+
+;; Database capabilities
+
+(defmethod db-backend-has-create/destroy-db? ((db-type (eql :postgresql-socket)))
+ nil)
+
+(defmethod db-type-has-fancy-math? ((db-type (eql :postgresql-socket)))
+ t)
+
+(defmethod db-type-default-case ((db-type (eql :postgresql-socket)))
+ :lower)
+
+(defmethod database-underlying-type ((database postgresql-socket-database))
+ :postgresql)
+
+(when (clsql-sys:database-type-library-loaded :postgresql-socket)
+ (clsql-sys:initialize-database-type :database-type :postgresql-socket))