X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=db-oracle%2Foracle-sql.lisp;h=9460011db0d7f1a687d4faafa513eef7eeee9c0c;hp=b0f5457417af9918874c9a138a4d830604d05bce;hb=2ba41ebdcd4963728c8d5460e389a5381b8e2293;hpb=2a0e0fdaa59c9b431bad7ef35cab891f831a9d3b diff --git a/db-oracle/oracle-sql.lisp b/db-oracle/oracle-sql.lisp index b0f5457..9460011 100644 --- a/db-oracle/oracle-sql.lisp +++ b/db-oracle/oracle-sql.lisp @@ -4,8 +4,6 @@ ;;;; ;;;; Name: oracle-sql.lisp ;;;; -;;;; $Id$ -;;;; ;;;; This file is part of CLSQL. ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software @@ -168,7 +166,9 @@ the length of that format.") (uffi:char-array-to-pointer errbuf) +errbuf-len+ +oci-htype-error+)) (let ((subcode (uffi:deref-pointer errcode 'sb4)) - (errstr (uffi:convert-from-foreign-string errbuf))) + (errstr (uffi:convert-from-foreign-string + errbuf + :encoding (when database (encoding database))))) (uffi:free-foreign-object errcode) (uffi:free-foreign-object errbuf) (unless (and nulls-ok (= subcode +null-value-returned+)) @@ -217,14 +217,15 @@ the length of that format.") (uffi:def-type string-pointer (* :unsigned-char)) -(defun deref-oci-string (arrayptr string-index size) +(defun deref-oci-string (arrayptr string-index size encoding) (declare (type string-pointer arrayptr)) (declare (type (mod #.+n-buf-rows+) string-index)) (declare (type (and unsigned-byte fixnum) size)) (let ((str (uffi:convert-from-foreign-string (uffi:make-pointer (+ (uffi:pointer-address arrayptr) (* string-index size)) - :unsigned-char)))) + :unsigned-char) + :encoding encoding))) (if (string-equal str "NULL") nil str))) ;; the OCI library, part Z: no-longer used logic to convert from @@ -404,7 +405,7 @@ the length of that format.") ; from it after that.. -(defun fetch-row (qc &optional (eof-errorp t) eof-value) +(defun fetch-row (qc &optional (eof-errorp t) eof-value encoding) (declare (optimize (speed 3))) (cond ((zerop (qc-n-from-oci qc)) (if eof-errorp @@ -414,7 +415,7 @@ the length of that format.") ((>= (qc-n-to-dbi qc) (qc-n-from-oci qc)) (refill-qc-buffers qc) - (fetch-row qc nil eof-value)) + (fetch-row qc nil eof-value encoding)) (t (let ((cds (qc-cds qc)) (reversed-result nil) @@ -429,7 +430,7 @@ the length of that format.") (unless (= indicator -1) (ecase (cd-oci-data-type cd) (#.SQLT-STR - (deref-oci-string b irow (cd-sizeof cd))) + (deref-oci-string b irow (cd-sizeof cd) encoding)) (#.SQLT-FLT (locally (declare (type double-array b)) @@ -441,7 +442,7 @@ the length of that format.") (declare (type int-array b)) (uffi:deref-array b '(:array :int) irow))))) (#.SQLT-DATE - (deref-oci-string b irow (cd-sizeof cd)))))))) + (deref-oci-string b irow (cd-sizeof cd) encoding))))))) (when (and (eq :string (cd-result-type cd)) value (not (stringp value))) @@ -513,7 +514,7 @@ the length of that format.") (oci-stmt-prepare (deref-vp stmthp) (deref-vp errhp) c-stmt-string - (length sql-stmt-string) + (uffi:foreign-string-length c-stmt-string) +oci-ntv-syntax+ +oci-default+ :database db) (oci-attr-get (deref-vp stmthp) +oci-htype-stmt+ @@ -723,7 +724,8 @@ the length of that format.") (deref-vp errhp)) (setq colname-string (uffi:convert-from-foreign-string (uffi:deref-pointer colname '(* :unsigned-char)) - :length (uffi:deref-pointer colnamelen 'ub4)))) + :length (uffi:deref-pointer colnamelen 'ub4) + :encoding (encoding database)))) (push (make-cd :name colname-string :sizeof sizeof :buffer buffer @@ -896,7 +898,7 @@ the length of that format.") (do ((reversed-result nil)) (nil) (let* ((eof-value :eof) - (row (fetch-row cursor nil eof-value))) + (row (fetch-row cursor nil eof-value (encoding database)))) (when (eq row eof-value) (close-query cursor) (if field-names @@ -1021,7 +1023,7 @@ the length of that format.") (defmethod database-store-next-row (result-set (database oracle-database) list) (let* ((eof-value :eof) - (row (fetch-row result-set nil eof-value))) + (row (fetch-row result-set nil eof-value (encoding database)))) (unless (eq eof-value row) (loop for i from 0 below (length row) do (setf (nth i list) (nth i row)))