X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=db-mysql%2Fmysql-sql.lisp;h=55918a935600d81aa07c738f2b026f948c04582f;hp=12279c35a41fd9116efa80e4ca0ae49b57eca53f;hb=e5744a78271044484b3399d4fc1d55b3e8808784;hpb=c4da3cfcbb955395d8a556e1f89aadad696302b7 diff --git a/db-mysql/mysql-sql.lisp b/db-mysql/mysql-sql.lisp index 12279c3..55918a9 100644 --- a/db-mysql/mysql-sql.lisp +++ b/db-mysql/mysql-sql.lisp @@ -397,47 +397,47 @@ (defmethod database-create (connection-spec (type (eql :mysql))) (destructuring-bind (host name user password) connection-spec - (let ((asdf::*verbose-out* (make-string-output-stream))) - (unwind-protect - (let* ((status (asdf:run-shell-command - "mysqladmin create -u~A -p~A -h~A ~A" - user password - (if host host "localhost") - name)) - (result (get-output-stream-string asdf::*verbose-out*))) - - (if (search "CREATE DATABASE failed;" result) - (error 'clsql-access-error - :connection-spec connection-spec - :database-type type - :error - (format nil "database-create failed: ~s" result)) - t)) - (close asdf::*verbose-out*))))) + (multiple-value-bind (output status) + (clsql-base-sys:command-output "mysqladmin create -u~A -p~A -h~A ~A" + user password + (if host host "localhost") + name) + (if (or (not (eql 0 status)) + (and (search "failed" output) (search "error" output))) + (error 'clsql-access-error + :connection-spec connection-spec + :database-type type + :error + (format nil "database-create failed: ~A" output)) + t)))) (defmethod database-destory (connection-spec (type (eql :mysql))) (destructuring-bind (host name user password) connection-spec - (let ((asdf::*verbose-out* (make-string-output-stream))) - (unwind-protect - (let* ((status (asdf:run-shell-command - "mysqladmin drop -f -u~A -p~A -h~A ~A" - user password - (if host host "localhost") - name)) - (result (get-output-stream-string asdf::*verbose-out*))) - - (if (search "DROP DATABASE failed;" result) - (error 'clsql-access-error - :connection-spec connection-spec - :database-type type - :error - (format nil "database-destory failed: ~s" result)) - t)) - (close asdf::*verbose-out*))))) + (multiple-value-bind (output status) + (clsql-base-sys:command-output "mysqladmin drop -u~A -p~A -h~A ~A" + user password + (if host host "localhost") + name) + (if (or (not (eql 0 status)) + (and (search "failed" output) (search "error" output))) + (error 'clsql-access-error + :connection-spec connection-spec + :database-type type + :error + (format nil "database-destroy failed: ~A" output)) + t)))) (defmethod database-probe (connection-spec (type (eql :mysql))) - (destructuring-bind (name user password) connection-spec - (error "not-yet-implemented"))) + (destructuring-bind (host name user password) connection-spec + (let ((database (database-connect (list host "mysql" user password) type))) + (unwind-protect + (when + (find name (database-query "select db from db" + database :auto) + :key #'car :test #'string-equal) + t) + (database-disconnect database))))) + (when (clsql-base-sys:database-type-library-loaded :mysql) (clsql-base-sys:initialize-database-type :database-type :mysql))