From: Kevin M. Rosenberg Date: Wed, 29 Dec 2004 07:43:08 +0000 (+0000) Subject: r10238: * db-mysql/mysql-sql.lisp: Apply patch from Yannick Gingras to X-Git-Tag: v3.8.6~193 X-Git-Url: http://git.kpe.io/?p=clsql.git;a=commitdiff_plain;h=38e68ca9528898217add34a81afa210073ba0340 r10238: * db-mysql/mysql-sql.lisp: Apply patch from Yannick Gingras to implement database-sequence-last. Add support for detecting unsigned integers. * uffi/clsql-uffi.lisp: Add support for unsigned integers --- diff --git a/ChangeLog b/ChangeLog index 3408ed6..30ce6a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 28 Dec 2004 Kevin Rosenberg * db-mysql/mysql-sql.lisp: Apply patch from Yannick Gingras to - implement database-sequence-last. + implement database-sequence-last. Add support for detecting + unsigned integers. + * uffi/clsql-uffi.lisp: Add support for unsigned integers 26 Dec 2004 Kevin Rosenberg * doc/ref-fdml.lisp: Fix variable tag name to varname diff --git a/db-mysql/mysql-sql.lisp b/db-mysql/mysql-sql.lisp index 5f13068..c87da86 100644 --- a/db-mysql/mysql-sql.lisp +++ b/db-mysql/mysql-sql.lisp @@ -41,16 +41,25 @@ (dotimes (i num-fields) (declare (fixnum i)) (let* ((field (uffi:deref-array field-vec '(:array mysql-field) i)) - (type (uffi:get-slot-value field 'mysql-field 'type))) + (flags (uffi:get-slot-value field 'mysql-field 'flags)) + (unsigned (plusp (logand flags 32))) + (type (uffi:get-slot-value field 'mysql-field 'type))) (push (case type ((#.mysql-field-types#tiny #.mysql-field-types#short - #.mysql-field-types#int24 - #.mysql-field-types#long) - :int32) - (#.mysql-field-types#longlong - :int64) + #.mysql-field-types#int24) + (if unsigned + :uint32 + :int32)) + (#.mysql-field-types#long + (if unsigned + :uint + :int)) + (#.mysql-field-types#longlong + (if unsigned + :uint64 + :int64)) ((#.mysql-field-types#double #.mysql-field-types#float #.mysql-field-types#decimal) @@ -523,7 +532,7 @@ (dotimes (i num-fields) (declare (fixnum i)) (let* ((field (uffi:deref-array field-vec '(:array mysql-field) i)) - (type (uffi:get-slot-value field mysql-field 'type)) + (type (uffi:get-slot-value field 'mysql-field 'type)) (binding (uffi:deref-array output-bind '(:array mysql-bind) i))) (setf (uffi:get-slot-value binding 'mysql-bind 'mysql::buffer-type) type) diff --git a/uffi/clsql-uffi.lisp b/uffi/clsql-uffi.lisp index 7ac28c0..76e63eb 100644 --- a/uffi/clsql-uffi.lisp +++ b/uffi/clsql-uffi.lisp @@ -57,6 +57,8 @@ t)) (:blob :blob) + (:uint + :uint) (t t)) new-types)))) @@ -65,6 +67,12 @@ ((str (* :unsigned-char))) :returning :int) +(uffi:def-function ("strtoul" c-strtoul) + ((str (* :unsigned-char)) + (endptr (* :unsigned-char)) + (radix :int)) + :returning :unsigned-long) + (uffi:def-function "atol" ((str (* :unsigned-char))) :returning :long) @@ -97,6 +105,11 @@ (uffi:def-type char-ptr-def (* :unsigned-char)) +(defun strtoul (char-ptr) + (declare (optimize (speed 3) (safety 0) (space 0)) + (type char-ptr-def char-ptr)) + (c-strtoul char-ptr uffi:+null-cstring-pointer+ 10)) + (defun convert-raw-field (char-ptr types index &optional length) (declare (optimize (speed 3) (safety 0) (space 0)) (type char-ptr-def char-ptr)) @@ -110,9 +123,15 @@ (case type (:double (atof char-ptr)) - ((:int32 :int) + (:int + (atol char-ptr)) + (:int32 (atoi char-ptr)) - (:int64 + (:uint32 + (strtoul char-ptr)) + (:uint + (strtoul char-ptr)) + ((:int64 :uint64) (uffi:with-foreign-object (high32-ptr :unsigned-int) (let ((low32 (atol64 char-ptr high32-ptr)) (high32 (uffi:deref-pointer high32-ptr :unsigned-int)))