From 44452a3f9f128b5deb54b4dfe7249583eb4e090d Mon Sep 17 00:00:00 2001 From: Kevin Rosenberg Date: Mon, 16 Aug 2010 16:34:07 -0600 Subject: [PATCH] Commit patch for ODBC unicode improvements --- ChangeLog | 5 +++++ db-odbc/odbc-api.lisp | 42 ++++++++++++++++++++++-------------------- db-odbc/odbc-dbi.lisp | 2 ++ debian/changelog | 6 ++++++ 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6bb0e1d..3515695 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-08-16 Kevin Rosenberg + * 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 * Version 5.1.2 * uffi/clsql-uffi.lisp: Commit patch from JT Klein fixing diff --git a/db-odbc/odbc-api.lisp b/db-odbc/odbc-api.lisp index dfdbe21..2f200ca 100644 --- a/db-odbc/odbc-api.lisp +++ b/db-odbc/odbc-api.lisp @@ -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))) + diff --git a/db-odbc/odbc-dbi.lisp b/db-odbc/odbc-dbi.lisp index fb33f52..a07a5ee 100644 --- a/db-odbc/odbc-dbi.lisp +++ b/db-odbc/odbc-dbi.lisp @@ -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) )) diff --git a/debian/changelog b/debian/changelog index 978ad6c..64fed4a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cl-sql (5.1.3-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Mon, 16 Aug 2010 16:29:09 -0600 + cl-sql (5.1.2-1) unstable; urgency=low * New upstream -- 2.34.1