(declare (optimize (speed 3) (safety 0) (debug 0) (space 0)))
(let ((mysql-ptr (database-mysql-ptr database)))
(uffi:with-cstring (query-native query-expression)
- (if (zerop (mysql-query mysql-ptr query-native))
+ (if (zerop (mysql-real-query mysql-ptr query-native
+ (length query-expression)))
(let ((res-ptr (mysql-use-result mysql-ptr)))
(if res-ptr
(unwind-protect
types num-fields
res-ptr))
(loop for row = (mysql-fetch-row res-ptr)
+ for lengths = (mysql-fetch-lengths res-ptr)
until (uffi:null-pointer-p row)
collect
(do* ((rlist (make-list num-fields))
(uffi:deref-array row '(:array
(* :unsigned-char))
i)
- types i)))))
+ types i
+ (uffi:deref-array lengths '(:array :unsigned-long)
+ i))))))
(mysql-free-result res-ptr))
(error 'clsql-sql-error
:database database
(uffi:with-cstring (sql-native sql-expression)
(let ((mysql-ptr (database-mysql-ptr database)))
(declare (type mysql-mysql-ptr-def mysql-ptr))
- (if (zerop (mysql-query mysql-ptr sql-native))
+ (if (zerop (mysql-real-query mysql-ptr sql-native
+ (length sql-expression)))
t
(error 'clsql-sql-error
:database database
(uffi:with-cstring (query-native query-expression)
(let ((mysql-ptr (database-mysql-ptr database)))
(declare (type mysql-mysql-ptr-def mysql-ptr))
- (if (zerop (mysql-query mysql-ptr query-native))
+ (if (zerop (mysql-real-query mysql-ptr query-native
+ (length query-expression)))
(let ((res-ptr (if full-set
(mysql-store-result mysql-ptr)
(mysql-use-result mysql-ptr))))
(defmethod database-store-next-row (result-set (database mysql-database) list)
(let* ((res-ptr (mysql-result-set-res-ptr result-set))
(row (mysql-fetch-row res-ptr))
+ (lengths (mysql-fetch-lengths res-ptr))
(types (mysql-result-set-types result-set)))
(declare (type mysql-mysql-res-ptr-def res-ptr)
(type mysql-row-def row))
(convert-raw-field
(uffi:deref-array row '(:array (* :unsigned-char)) i)
types
- i)))
+ i
+ (uffi:deref-array lengths :unsigned-long i))))
list)))
(uffi:def-type char-ptr-def (* :unsigned-char))
-(defun convert-raw-field (char-ptr types index)
+(defun convert-raw-field (char-ptr types index &optional length)
(declare (optimize (speed 3) (safety 0) (space 0))
- (type char-ptr-def char-ptr))
+ (type char-ptr-def char-ptr))
(let ((type (if (listp types)
(nth index types)
types)))
low32
(make-64-bit-integer high32 low32)))))
(t
- (uffi:convert-from-foreign-string char-ptr :locale :none)))))))
-
+ (if length
+ (uffi:convert-from-foreign-string char-ptr :locale :none
+ :null-terminated-p nil
+ :length length)
+ (uffi:convert-from-foreign-string char-ptr :locale :none))))))))
+