Mysql port patch
Dave Watson <[email protected]>
| Newsgroups | gmane.lisp.clsql.devel |
|---|---|
| Message-ID | <[email protected]> |
The attached patch adds a port option to the mysql connection. As far as I've tested it it seems to work correctly, but someone else should double-check, as I did it rather quickly Thanks again for the great software! -Dave Watson _______________________________________________ CLSQL-Devel mailing list [email protected] http://lists.b9.com/mailman/listinfo/clsql-devel
clsql-mysql-port.patch
(text/plain, 3.3 KB)
--- db-mysql/mysql-sql.lisp 2005-01-24 11:28:10.000000000 -0800
+++ /usr/lib/sbcl/clsql-3.1.7/db-mysql/mysql-sql.lisp 2005-03-31 18:02:23.000000000 -0800
@@ -95,16 +95,16 @@
:mysql)
(defmethod database-name-from-spec (connection-spec (database-type (eql :mysql)))
- (check-connection-spec connection-spec database-type (host db user password))
- (destructuring-bind (host db user password) connection-spec
+ (check-connection-spec connection-spec database-type (host db port user password))
+ (destructuring-bind (host db port user password) connection-spec
(declare (ignore password))
(concatenate 'string
(if host host "localhost")
- "/" db "/" user)))
+ "/" db "/" port "/" user)))
(defmethod database-connect (connection-spec (database-type (eql :mysql)))
- (check-connection-spec connection-spec database-type (host db user password))
- (destructuring-bind (host db user password) connection-spec
+ (check-connection-spec connection-spec database-type (host db port user password))
+ (destructuring-bind (host db port user password) connection-spec
(let ((mysql-ptr (mysql-init (uffi:make-null-pointer 'mysql-mysql)))
(socket nil))
(if (uffi:null-pointer-p mysql-ptr)
@@ -123,7 +124,7 @@
(if (uffi:null-pointer-p
(mysql-real-connect
mysql-ptr host-native user-native password-native
- db-native 0 socket-native 0))
+ db-native (parse-integer port) socket-native 0))
(progn
(setq error-occurred t)
(error 'sql-connection-error
@@ -403,11 +404,13 @@
database :auto nil))))
(defmethod database-create (connection-spec (type (eql :mysql)))
- (destructuring-bind (host name user password) connection-spec
+ (destructuring-bind (host name port user password) connection-spec
(multiple-value-bind (output status)
- (clsql-sys:command-output "mysqladmin create -u~A -p~A -h~A ~A"
+ (clsql-sys:command-output "mysqladmin create -u~A -p~A -h~A ~A~A ~A"
user password
(if host host "localhost")
+ (if port "-P" "")
+ (if port port "")
name)
(if (or (not (eql 0 status))
(and (search "failed" output) (search "error" output)))
@@ -418,11 +421,13 @@
t))))
(defmethod database-destroy (connection-spec (type (eql :mysql)))
- (destructuring-bind (host name user password) connection-spec
+ (destructuring-bind (host name port user password) connection-spec
(multiple-value-bind (output status)
- (clsql-sys:command-output "mysqladmin drop -f -u~A -p~A -h~A ~A"
+ (clsql-sys:command-output "mysqladmin drop -f -u~A -p~A -h~A ~A~A ~A"
user password
(if host host "localhost")
+ (if port "-P" "")
+ (if port port "")
name)
(if (or (not (eql 0 status))
(and (search "failed" output) (search "error" output)))
@@ -438,9 +443,9 @@
t))
(defmethod database-list (connection-spec (type (eql :mysql)))
- (destructuring-bind (host name user password) connection-spec
+ (destructuring-bind (host name port user password) connection-spec
(declare (ignore name))
- (let ((database (database-connect (list host "mysql" user password) type)))
+ (let ((database (database-connect (list host "mysql" port user password) type)))
(unwind-protect
(progn
(setf (slot-value database 'clsql-sys::state) :open)