X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-mysql%2Fmysql-sql.lisp;h=bb4940e59d4cb29fe69cec1eb70ba7cac4e30d7f;hb=44cd3f817f6f59ffe495db4cf2b9ea4637a57f75;hp=08f50fb582e0d0f67ebe8de0f9018319a4c8db3c;hpb=5398a720dd42b3c2787ff67414e6ce424bc34e1b;p=clsql.git diff --git a/db-mysql/mysql-sql.lisp b/db-mysql/mysql-sql.lisp index 08f50fb..bb4940e 100644 --- a/db-mysql/mysql-sql.lisp +++ b/db-mysql/mysql-sql.lisp @@ -99,11 +99,11 @@ (let ((mysql-ptr (mysql-init (uffi:make-null-pointer 'mysql-mysql))) (socket nil)) (if (uffi:null-pointer-p mysql-ptr) - (error 'clsql-connect-error + (error 'sql-connection-error :database-type database-type :connection-spec connection-spec - :errno (mysql-errno mysql-ptr) - :error (mysql-error-string mysql-ptr)) + :error-id (mysql-errno mysql-ptr) + :message (mysql-error-string mysql-ptr)) (uffi:with-cstrings ((host-native host) (user-native user) (password-native password) @@ -117,11 +117,11 @@ db-native 0 socket-native 0)) (progn (setq error-occurred t) - (error 'clsql-connect-error + (error 'sql-connection-error :database-type database-type :connection-spec connection-spec - :errno (mysql-errno mysql-ptr) - :error (mysql-error-string mysql-ptr))) + :error-id (mysql-errno mysql-ptr) + :message (mysql-error-string mysql-ptr))) (make-instance 'mysql-database :name (database-name-from-spec connection-spec database-type) @@ -173,16 +173,16 @@ (when field-names (result-field-names num-fields res-ptr)))) (mysql-free-result res-ptr)) - (error 'clsql-sql-error + (error 'sql-database-data-error :database database :expression query-expression - :errno (mysql-errno mysql-ptr) - :error (mysql-error-string mysql-ptr)))) - (error 'clsql-sql-error + :error-id (mysql-errno mysql-ptr) + :message (mysql-error-string mysql-ptr)))) + (error 'sql-database-data-error :database database :expression query-expression - :errno (mysql-errno mysql-ptr) - :error (mysql-error-string mysql-ptr)))))) + :error-id (mysql-errno mysql-ptr) + :message (mysql-error-string mysql-ptr)))))) (defmethod database-execute-command (sql-expression (database mysql-database)) (uffi:with-cstring (sql-native sql-expression) @@ -191,11 +191,11 @@ (if (zerop (mysql-real-query mysql-ptr sql-native (length sql-expression))) t - (error 'clsql-sql-error + (error 'sql-database-data-error :database database :expression sql-expression - :errno (mysql-errno mysql-ptr) - :error (mysql-error-string mysql-ptr)))))) + :error-id (mysql-errno mysql-ptr) + :message (mysql-error-string mysql-ptr)))))) (defstruct mysql-result-set @@ -233,16 +233,16 @@ (mysql-num-rows res-ptr)) (values result-set num-fields))) - (error 'clsql-sql-error + (error 'sql-database-data-error :database database :expression query-expression - :errno (mysql-errno mysql-ptr) - :error (mysql-error-string mysql-ptr)))) - (error 'clsql-sql-error + :error-id (mysql-errno mysql-ptr) + :message (mysql-error-string mysql-ptr)))) + (error 'sql-database-data-error :database database :expression query-expression - :errno (mysql-errno mysql-ptr) - :error (mysql-error-string mysql-ptr)))))) + :error-id (mysql-errno mysql-ptr) + :message (mysql-error-string mysql-ptr)))))) (defmethod database-dump-result-set (result-set (database mysql-database)) (mysql-free-result (mysql-result-set-res-ptr result-set)) @@ -398,12 +398,11 @@ 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)))) + (error 'sql-database-error + :message + (format nil "mysql database creation failed with connection-spec ~A." + connection-spec)) + t)))) (defmethod database-destroy (connection-spec (type (eql :mysql))) (destructuring-bind (host name user password) connection-spec @@ -414,11 +413,10 @@ 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)) + (error 'sql-database-error + :message + (format nil "mysql database deletion failed with connection-spec ~A." + connection-spec)) t)))) (defmethod database-probe (connection-spec (type (eql :mysql))) @@ -461,6 +459,10 @@ (let ((tuple (car (database-query "SHOW VARIABLES LIKE 'HAVE_INNODB'" database :auto nil)))) (and tuple (string-equal "YES" (second tuple))))) +(defmethod db-type-has-prepared-stmt? ((db-type (eql :mysql))) + #+mysql-client-v4.1 t + #-mysql-client-v4.1 nil) + (when (clsql-sys:database-type-library-loaded :mysql) (clsql-sys:initialize-database-type :database-type :mysql))