r10238: * db-mysql/mysql-sql.lisp: Apply patch from Yannick Gingras to
authorKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 29 Dec 2004 07:43:08 +0000 (07:43 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 29 Dec 2004 07:43:08 +0000 (07:43 +0000)
        implement database-sequence-last. Add support for detecting
        unsigned integers.
        * uffi/clsql-uffi.lisp: Add support for unsigned integers

ChangeLog
db-mysql/mysql-sql.lisp
uffi/clsql-uffi.lisp

index 3408ed667556991d066e8d03993c7ac737329f52..30ce6a7742d3ed1a829d5043d457ea24f8524a71 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 28 Dec 2004 Kevin Rosenberg <kevin@rosenberg.net>
        * 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 <kevin@rosenberg.net>
         * doc/ref-fdml.lisp: Fix variable tag name to varname
index 5f1306811fdc2f9d6836591909cc661242ac4238..c87da8699df6835c8693bd704e349070b25adabf 100644 (file)
     (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)
          (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)
              
index 7ac28c00e7f8c54418fde9f8459d5433e9557b4b..76e63eb95ebbc7f43ebc50a742e7dde6d0ae6aae 100644 (file)
@@ -57,6 +57,8 @@
              t))
           (:blob
            :blob)
+          (:uint
+           :uint)
           (t
            t))
         new-types))))
     ((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)
 
 (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))
        (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)))