Commit patch for ODBC unicode improvements debian-5.1.3-1 v5.1.3
authorKevin Rosenberg <kevin@rosenberg.net>
Mon, 16 Aug 2010 22:34:07 +0000 (16:34 -0600)
committerKevin Rosenberg <kevin@rosenberg.net>
Mon, 16 Aug 2010 22:34:07 +0000 (16:34 -0600)
ChangeLog
db-odbc/odbc-api.lisp
db-odbc/odbc-dbi.lisp
debian/changelog

index 6bb0e1de93490bce42d0fd01d9b1c41936b5a164..35156957b493e8e5556835a402d0e222f52fa0ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-08-16  Kevin Rosenberg <kevin@rosenberg.net>
+       * Version 5.1.3
+       * db-odbc/odbc-{api,dbi}.lisp: Commit patch from
+       Memet Bilgin to fix issue with unicode and ODBC.
+
 2010-08-16  Kevin Rosenberg <kevin@rosenberg.net>
        * Version 5.1.2
        * uffi/clsql-uffi.lisp: Commit patch from JT Klein fixing
index dfdbe21ed10fec7bb1e0b6dd6aa872a1efa986d1..2f200ca7db40e4da0bc95be08d64a31cb22d3275 100644 (file)
@@ -637,13 +637,13 @@ as possible second argument) to the desired representation of date/time/timestam
 
 (defun get-cast-binary (ptr len format)
   "FORMAT is one of :unsigned-byte-vector, :bit-vector (:string, :hex-string)"
-  (with-cast-pointer (casted ptr :byte)
+  (with-cast-pointer (casted ptr :unsigned-byte)
     (ecase format
       (:unsigned-byte-vector
        (let ((vector (make-array len :element-type '(unsigned-byte 8))))
          (dotimes (i len)
            (setf (aref vector i)
-                 (deref-array casted '(:array :byte) i)))
+                 (deref-array casted '(:array :unsigned-byte) i)))
          vector))
       (:bit-vector
        (let ((vector (make-array (ash len 3) :element-type 'bit)))
@@ -902,27 +902,28 @@ as possible second argument) to the desired representation of date/time/timestam
                                           (let ((*read-base* 10))
                                             (read-from-string str))
                                         str)))
-                   (otherwise
-                    (let ((str (make-string out-len)))
-                      (loop do (if (= c-type #.$SQL_CHAR)
-                                   (setf offset (%cstring-into-vector ;string
-                                                 data-ptr str
-                                                 offset
-                                                 (min out-len (1- +max-precision+))))
-                                 (error 'clsql:sql-database-error :message "wrong type. preliminary."))
-                            while
-                            (and (= res $SQL_SUCCESS_WITH_INFO)
-                                 #+ingore(eq (sql-state +null-handle-ptr+ +null-handle-ptr+ hstmt)
-                                             $sql-data-truncated)
-                                 (equal (sql-state +null-handle-ptr+ +null-handle-ptr+ hstmt)
-                                        "01004"))
-                            do (setf res (%sql-get-data hstmt column-nr c-type data-ptr
-                                                        +max-precision+ out-len-ptr)
-                                     out-len (deref-pointer out-len-ptr #.$ODBC-LONG-TYPE)))
+                    (otherwise
+                    (let ((str)
+                          (offset 0)
+                          (octets (make-array out-len :element-type '(unsigned-byte 8) :initial-element 0)))
+                      (loop
+                         do
+                             (loop for i from 0 to (1- (min out-len +max-precision+))
+                                do (setf (aref octets (+ offset i)) (deref-array data-ptr '(:array :unsigned-byte) i))
+                                finally (incf offset (1- i)))
+                         while
+                           (and (= res $SQL_SUCCESS_WITH_INFO)
+                                #+ingore(eq (sql-state +null-handle-ptr+ +null-handle-ptr+ hstmt)
+                                            $sql-data-truncated)
+                                (equal (sql-state +null-handle-ptr+ +null-handle-ptr+ hstmt) "01004"))
+                         do
+                           (setf res (%sql-get-data hstmt column-nr c-type data-ptr +max-precision+ out-len-ptr)
+                                 out-len (deref-pointer out-len-ptr #.$ODBC-LONG-TYPE)))
+                      (setf str (sb-ext:octets-to-string octets))
                       (if (= sql-type $SQL_DECIMAL)
                           (let ((*read-base* 10))
                             (read-from-string str))
-                        str))))))
+                          str))))))
     (setf (deref-pointer out-len-ptr #.$ODBC-LONG-TYPE) #.$SQL_NO_TOTAL) ;; reset the out length for the next row
     result))
 
@@ -1038,3 +1039,4 @@ as possible second argument) to the desired representation of date/time/timestam
         (free-foreign-object desc)))
     (nreverse results)))
 
+
index fb33f521bb63b3f0d6e279ec5ed8c10a26d24ed5..a07a5ee5e7cf6bf8353f4d68d4e15a5176f3ab85 100644 (file)
@@ -459,6 +459,7 @@ This makes the functions db-execute-command and db-query thread safe."
           (if (eq (aref column-sql-types i) odbc::$SQL_BIGINT)
               :number
             (case (aref column-c-types i)
+              (#.odbc::$SQL_BIT :short)
               (#.odbc::$SQL_C_SLONG :int)
               (#.odbc::$SQL_C_DOUBLE :double)
               (#.odbc::$SQL_C_FLOAT :float)
@@ -573,6 +574,7 @@ This makes the functions db-execute-command and db-query thread safe."
     ;;((#.odbc::$SQL_BINARY #.odbc::$SQL_VARBINARY #.odbc::$SQL_LONGVARBINARY) odbc::$SQL_C_BINARY) ; ??
     (#.odbc::$SQL_TINYINT :short)
     ;;(#.odbc::$SQL_BIT odbc::$SQL_C_BIT) ; ??
+    (#.odbc::$SQL_BIT :short)
     ((#.odbc::$SQL_VARBINARY #.odbc::$SQL_LONGVARBINARY) :binary)
     ))
 
index 978ad6c22368b9dd457b7dd5d84ce4f7d151b8c7..64fed4ac2d83f28a238c519800a82457a6464fd1 100644 (file)
@@ -1,3 +1,9 @@
+cl-sql (5.1.3-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Mon, 16 Aug 2010 16:29:09 -0600
+
 cl-sql (5.1.2-1) unstable; urgency=low
 
   * New upstream