Index: combined/src/odbc/column.lisp
===================================================================
--- combined/src/odbc/column.lisp	(revision combined,1)
+++ combined/src/odbc/column.lisp	(revision combined,2.1.2)
@@ -77,5 +77,5 @@
               column
             ;(setf value-ptr (cffi:foreign-alloc :long buffer-length))
-            (setf ind-ptr (cffi:foreign-alloc :long))
+            (setf ind-ptr (cffi:foreign-alloc 'sql-len))
             (%bind-column hstmt 
                           pos
@@ -112,10 +112,11 @@
           (cffi:foreign-alloc :char :count (slot-value column 'buffer-length))))
 
+;; dso+
 (defmethod get-column-value ((column string-column))
-  (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) :long)))
+  (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) 'sql-len)))
     (if (= len $SQL_NULL_DATA)
-      nil
-      (progn
-        (get-string (slot-value column 'value-ptr) len))))) 
+        nil
+        (progn
+          (get-string (slot-value column 'value-ptr) len)))))
 ;;;-------------------
 ;;;   unicode-string
@@ -146,12 +147,13 @@
           (cffi:foreign-alloc :uchar :count (slot-value column 'buffer-length))))
 
+;; dso+
 (defmethod get-column-value ((column unicode-string-column))
-  (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) :long)))
+  (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) 'sql-len)))
     ;; len is size in bytes, not characters!
     (if (= len $SQL_NULL_DATA)
-      nil
-      (progn
-;        (break)
-        (wchar-bytes-to-string (get-byte-vector (slot-value column 'value-ptr) len))))))
+        nil
+        (progn
+          ;; (break)
+          (wchar-bytes-to-string (get-byte-vector (slot-value column 'value-ptr) len))))))
 
 
@@ -166,15 +168,16 @@
   (declare (ignore args))
   (setf (slot-value column 'c-type) $SQL_C_SLONG)
-  (setf (slot-value column 'buffer-length) 
-          (cffi:foreign-type-size :long))
-  (setf (slot-value column 'value-ptr) 
-          (cffi:foreign-alloc :long)))
-
-
+  (setf (slot-value column 'buffer-length)
+        (cffi:foreign-type-size 'sql-integer))
+  (setf (slot-value column 'value-ptr)
+        (cffi:foreign-alloc 'sql-integer)))
+
+
+;; dso+
 (defmethod get-column-value ((column integer-column))
-  (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) :long)))
+  (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) 'sql-len)))
     (if (= len $SQL_NULL_DATA)
-      nil
-      (cffi:mem-ref (slot-value column 'value-ptr) :long))))
+        nil
+        (cffi:mem-ref (slot-value column 'value-ptr) 'sql-integer))))
 
 
@@ -185,4 +188,5 @@
 (defclass double-column (column) ())
 
+;; dso+
 (defmethod initialize-column ((column double-column) args)
   (declare (ignore args))
@@ -192,12 +196,13 @@
   (setf (slot-value column 'value-ptr) (cffi:foreign-alloc :double)))
 
+;; dso+
 (defmethod get-column-value ((column double-column))
-  ;(%get-long (slot-value column 'ind-ptr))
-  ;(%get-double-float (slot-value column 'value-ptr))
-   (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) :long)))
-     (if (= len $SQL_NULL_DATA)
-       nil
-       (progn
-         (cffi:mem-ref (slot-value column 'value-ptr) :double)))))
+  ;; (%get-long (slot-value column 'ind-ptr))
+  ;; (%get-double-float (slot-value column 'value-ptr))
+  (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) 'sql-len)))
+    (if (= len $SQL_NULL_DATA)
+        nil
+        (progn
+          (cffi:mem-ref (slot-value column 'value-ptr) :double)))))
 
 ;;;------------------------
@@ -206,4 +211,5 @@
 (defclass date-column (column) ())
 
+;; dso+
 (defmethod initialize-column ((column date-column) args)
   (declare (ignore args)) 
@@ -213,10 +219,11 @@
   (setf (slot-value column 'value-ptr) (cffi:foreign-alloc :uchar :count 32)))
 
+;; dso+
 (defmethod get-column-value ((column date-column))
-   (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) :long)))
+  (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) 'sql-len)))
     (if (= len $SQL_NULL_DATA)
-      nil
-      (funcall *universal-time-to-date-dataype*
-               (timestamp-to-universal-time (slot-value column 'value-ptr))))))
+        nil
+        (funcall *universal-time-to-date-dataype*
+                 (timestamp-to-universal-time (slot-value column 'value-ptr))))))
 
 ;;;--------------------------
@@ -251,4 +258,5 @@
 (defclass bigint-column (column) ())
 
+;; dso+
 (defmethod initialize-column ((column bigint-column) args)
   (declare (ignore args))
@@ -259,9 +267,10 @@
   (setf (slot-value column 'value-ptr) (cffi:foreign-alloc :uchar :count 25)))
 
+;; dso+
 (defmethod get-column-value ((column bigint-column))
-  (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) :long)))
-    (if (= len $SQL_NULL_DATA) 
-      nil
-      (parse-integer (get-string (slot-value column 'value-ptr) len)))))
+  (let ((len (cffi:mem-ref (slot-value column 'ind-ptr) 'sql-len)))
+    (if (= len $SQL_NULL_DATA)
+        nil
+        (parse-integer (get-string (slot-value column 'value-ptr) len)))))
 
 ;;;----------------------------
@@ -403,4 +412,5 @@
 ;;  fetch data via SQlGetData
 ;; ------------------------------
+;; dso+
 (defun get-character-data (hstmt position value-ptr buffer-length ind-ptr)
   ;; local error handling, we can not use the general error handling
@@ -423,22 +433,23 @@
                                       ind-ptr)))
       (handle-error sqlret)
-      (let ((len (cffi:mem-ref ind-ptr :long)))
-        ;(break)
+      (let ((len (cffi:mem-ref ind-ptr 'sql-len)))
+        ;;(break)
         (cond 
           ((= len $sql_null_data) nil)
-          ;; character data has a 0 byte appended, the length does not include it
-          ;; but it is taken into account when placing the data into the buffer
+          ;; character data has a 0 byte appended, the length does not
+          ;; include it but it is taken into account when placing the
+          ;; data into the buffer
           ((and (/= len $SQL_NO_TOTAL)
                 (<= (+ 1 len) buffer-length))
-            ;; the data fits into the buffer, return it
-            (get-string value-ptr len))
+           ;; the data fits into the buffer, return it
+           (get-string value-ptr len))
           
           ;; we have to fetch the data in several steps
           (t 
-            (let ((sos (make-string-output-stream)))
-              (loop
-                (if (and (= sqlret $SQL_SUCCESS_WITH_INFO)
-                         (equal (sql-state nil nil hstmt)
-                                "01004"))
+           (let ((sos (make-string-output-stream)))
+             (loop
+              (if (and (= sqlret $SQL_SUCCESS_WITH_INFO)
+                       (equal (sql-state nil nil hstmt)
+                              "01004"))
                   ;; an 0 byte is append to a string, ignore that
                   
@@ -446,20 +457,21 @@
                     (write-string str sos)
                     (setf sqlret (%sql-get-data-raw hstmt
-                                            position
-                                            $SQL_C_CHAR
-                                            value-ptr
-                                            buffer-length
-                                            ind-ptr))
+                                                    position
+                                                    $SQL_C_CHAR
+                                                    value-ptr
+                                                    buffer-length
+                                                    ind-ptr))
                     (handle-error sqlret))
                   (return)))
-              ;; fetch the last part of the data
-          (setf len (cffi:mem-ref ind-ptr :long))
-          (let ((str (get-string value-ptr len)))
-            (write-string str sos))
-          (get-output-stream-string sos))))))))
+             ;; fetch the last part of the data
+             (setf len (cffi:mem-ref ind-ptr 'sql-len))
+             (let ((str (get-string value-ptr len)))
+               (write-string str sos))
+             (get-output-stream-string sos))))))))
 
 ;;; the version for 16bit unicode 
 
-(defun get-unicode-character-data (hstmt position value-ptr buffer-length ind-ptr)
+(defun get-unicode-character-data (hstmt position value-ptr buffer-length
+                                   ind-ptr)
   ;; local error handling, we can not use the general error handling
   ;; since this resets the sql-state
@@ -481,39 +493,42 @@
                                       ind-ptr)))
       (handle-error sqlret)
-      (let ((len (cffi:mem-ref ind-ptr :long)))
+      (let ((len (cffi:mem-ref ind-ptr 'sql-len)))
         (cond 
           ((= len $sql_null_data) nil)
-          ;; character data has a 0 byte appended, the length does not include it
-          ;; but it is taken into account when placing the data into the buffer
+          ;; character data has a 0 byte appended, the length does not
+          ;; include it but it is taken into account when placing the
+          ;; data into the buffer
           ((and (/= len $SQL_NO_TOTAL)
                 (<= (+ 2 len) buffer-length))
-            ;; the data fits into the buffer, return it
-            (%get-unicode-string value-ptr len))
+           ;; the data fits into the buffer, return it
+           (%get-unicode-string value-ptr len))
           
           ;; we have to fetch the data in several steps
           (t 
-            (let ((sos (make-string-output-stream :element-type 'character)))
-              (loop
-                (if (and (= sqlret $SQL_SUCCESS_WITH_INFO)
-                         (equal (sql-state nil nil hstmt)
-                                "01004"))
+           (let ((sos (make-string-output-stream :element-type 'character)))
+             (loop
+              (if (and (= sqlret $SQL_SUCCESS_WITH_INFO)
+                       (equal (sql-state nil nil hstmt)
+                              "01004"))
                   ;; an 0 byte is append to a string, ignore that
                   
-                  (let ((str (%get-unicode-string value-ptr (- buffer-length 2))))
+                  (let ((str
+                         (%get-unicode-string value-ptr (- buffer-length 2))))
                     (write-string str sos)
                     (setf sqlret (%sql-get-data-raw hstmt
-                                            position
-                                            $SQL_C_WCHAR
-                                            value-ptr
-                                            buffer-length
-                                            ind-ptr))
+                                                    position
+                                                    $SQL_C_WCHAR
+                                                    value-ptr
+                                                    buffer-length
+                                                    ind-ptr))
                     (handle-error sqlret))
                   (return)))
-              ;; fetch the last part of the data
-          (setf len (cffi:mem-ref ind-ptr :long))
-          (let ((str (%get-unicode-string value-ptr len)))
-            (write-string str sos))
-          (get-output-stream-string sos))))))))
+             ;; fetch the last part of the data
+             (setf len (cffi:mem-ref ind-ptr 'sql-len))
+             (let ((str (%get-unicode-string value-ptr len)))
+               (write-string str sos))
+             (get-output-stream-string sos))))))))
     
+;; dso+
 (defun get-binary-data (hstmt position value-ptr buffer-length ind-ptr)
   ;; local error handling, we can not use the general error handling
@@ -530,38 +545,39 @@
                (error condition)))))
  
-  (let* ((sqlret (%sql-get-data-raw hstmt
-                                    position
-                                    $SQL_C_BINARY
-                                    value-ptr
-                                    buffer-length
-                                    ind-ptr)))
-    (handle-error sqlret)
-    (let ((len (cffi:mem-ref ind-ptr :long)))
-      (if (= len $sql_null_data)
-        nil
-        (let ((res (make-array 0 :element-type '(unsigned-byte 8) :adjustable t))
-              (res-len 0))
-          (loop
-            (if (and (= sqlret $SQL_SUCCESS_WITH_INFO)
-                     (equal (sql-state nil nil hstmt)
-                          "01004"))
+    (let* ((sqlret (%sql-get-data-raw hstmt
+                                      position
+                                      $SQL_C_BINARY
+                                      value-ptr
+                                      buffer-length
+                                      ind-ptr)))
+      (handle-error sqlret)
+      (let ((len (cffi:mem-ref ind-ptr 'sql-len)))
+        (if (= len $sql_null_data)
+            nil
+            (let ((res (make-array 0
+                                   :element-type '(unsigned-byte 8)
+                                   :adjustable t))
+                  (res-len 0))
+              (loop
+               (if (and (= sqlret $SQL_SUCCESS_WITH_INFO)
+                        (equal (sql-state nil nil hstmt)
+                               "01004"))
             
-            (let ((vec (get-byte-vector value-ptr buffer-length)))
-              (setf res (adjust-array res (+ res-len buffer-length)))
-              (setf (subseq res res-len (+ res-len buffer-length)) vec)
-              (setf res-len (length res))
-              (setf sqlret (%sql-get-data-raw hstmt
-                                              position
-                                              $SQL_C_BINARY
-                                              value-ptr
-                                              buffer-length
-                                              ind-ptr))
-              (handle-error sqlret))
-            (return)))
+                   (let ((vec (get-byte-vector value-ptr buffer-length)))
+                     (setf res (adjust-array res (+ res-len buffer-length)))
+                     (setf (subseq res res-len (+ res-len buffer-length)) vec)
+                     (setf res-len (length res))
+                     (setf sqlret (%sql-get-data-raw hstmt
+                                                     position
+                                                     $SQL_C_BINARY
+                                                     value-ptr
+                                                     buffer-length
+                                                     ind-ptr))
+                     (handle-error sqlret))
+                   (return)))
         
-        (setf len (cffi:mem-ref ind-ptr :long))
-        (let ((vec (get-byte-vector value-ptr len)))
-          (setf res (adjust-array res (+ res-len len)))
-          (setf (subseq res res-len (+ res-len len)) vec))
-        res))))))
-
+              (setf len (cffi:mem-ref ind-ptr 'sql-len))
+              (let ((vec (get-byte-vector value-ptr len)))
+                (setf res (adjust-array res (+ res-len len)))
+                (setf (subseq res res-len (+ res-len len)) vec))
+              res))))))
