+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
(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)))
(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))
(free-foreign-object desc)))
(nreverse results)))
+
(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)
;;((#.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)
))