-(defun make-type-list-for-auto (num-fields res-ptr)
- (declare (fixnum num-fields))
- (let ((new-types '())
- (field-vec (mysql-fetch-fields res-ptr)))
- (dotimes (i num-fields)
- (declare (fixnum i))
- (let* ((field (uffi:deref-array field-vec '(:array mysql-field) i))
- (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)
- (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)
- :double)
- (otherwise
- t))
- new-types)))
+(defun make-type-list-for-auto (res-ptr)
+ (let ((new-types '()))
+ (mysql-field-seek res-ptr 0)
+ (loop
+ (let ((field (mysql-fetch-field res-ptr)))
+ (when (uffi:null-pointer-p field) (return))
+ (let* ((flags (clsql-mysql-field-flags field))
+ (unsigned (plusp (logand flags 32)))
+ (type (clsql-mysql-field-type field)))
+ (push
+ (case type
+ ((#.mysql-field-types#tiny
+ #.mysql-field-types#short
+ #.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)
+ :double)
+ (otherwise
+ t))
+ new-types))))