mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-09 07:47:00 +02:00
Process MS SQL smallint datatypes as unsigned, fix #262.
The freetds protocol apparently sends unsigned versions of the values on the wire, so that we have to convert them to signed numbers upon reception.
This commit is contained in:
parent
3af99051d2
commit
db0f21b5a5
@ -73,13 +73,19 @@
|
||||
(:syb-xml 163)
|
||||
)
|
||||
|
||||
(defun unsigned-to-signed (byte n)
|
||||
(declare (type fixnum n) (type unsigned-byte byte))
|
||||
(logior byte (- (mask-field (byte 1 (1- (* n 8))) byte))))
|
||||
|
||||
(defun sysdb-data-to-lisp (%dbproc data type len)
|
||||
(if (> len 0)
|
||||
(case (foreign-enum-keyword '%syb-value-type type)
|
||||
((:syb-varchar :syb-text) (foreign-string-to-lisp data :count len))
|
||||
(:syb-char (string-trim #(#\Space) (foreign-string-to-lisp data :count len)))
|
||||
((:syb-bit :syb-bitn) (mem-ref data :int))
|
||||
((:syb-int1 :syb-int2 :syb-int4) (mem-ref data :int))
|
||||
((:syb-int1 (unsigned-to-signed (mem-ref data :int) 1)))
|
||||
((:syb-int2 (unsigned-to-signed (mem-ref data :int) 2)))
|
||||
((:syb-int4 (unsigned-to-signed (mem-ref data :int) 4)))
|
||||
(:syb-int8 (mem-ref data :int8))
|
||||
(:syb-flt8 (mem-ref data :double))
|
||||
(:syb-datetime
|
||||
|
Loading…
Reference in New Issue
Block a user