r10262: add missing package name to mysql::flags
[clsql.git] / db-mysql / mysql-sql.lisp
index 82f43b8b177513a15714e5c05e37d9229714c86b..2945258de5f292f1f668a278a7f446e038d78d91 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 'mysql::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)
    (mysql:mysql-insert-id (clsql-mysql::database-mysql-ptr database))))
 
 (defmethod database-sequence-last (sequence-name (database mysql-database))
-  (declare (ignore sequence-name)))
+  (without-interrupts
+    (caar (database-query 
+          (concatenate 'string "SELECT id from " 
+                       (%sequence-name-to-table sequence-name))
+          database :auto nil))))
 
 (defmethod database-create (connection-spec (type (eql :mysql)))
   (destructuring-bind (host name user password) connection-spec
          (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)