X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-oracle%2Foracle-sql.lisp;h=fc3188f8b33a4e510c916e0b87ac8baa27f61317;hb=69e146090f7c78c4d51023c25a0c1a1eade224a1;hp=6a6aa3f4f5ba0ca6c88a93d00ebbf975d3426b3e;hpb=e105d1c4963b50edb966b2a3049bbe02ecdfabff;p=clsql.git diff --git a/db-oracle/oracle-sql.lisp b/db-oracle/oracle-sql.lisp index 6a6aa3f..fc3188f 100644 --- a/db-oracle/oracle-sql.lisp +++ b/db-oracle/oracle-sql.lisp @@ -37,11 +37,11 @@ likely that we'll have to worry about the CMUCL limit.")) (defmacro deref-vp (foreign-object) `(the vp-type (uffi:deref-pointer (the vpp-type ,foreign-object) :pointer-void))) -(defvar +unsigned-char-null-pointer+ +(uffi:def-pointer-var +unsigned-char-null-pointer+ (uffi:make-null-pointer :unsigned-char)) -(defvar +unsigned-short-null-pointer+ +(uffi:def-pointer-var +unsigned-short-null-pointer+ (uffi:make-null-pointer :unsigned-short)) -(defvar +unsigned-int-null-pointer+ +(uffi:def-pointer-var +unsigned-int-null-pointer+ (uffi:make-null-pointer :unsigned-int)) ;; constants - from OCI? @@ -99,7 +99,7 @@ likely that we'll have to worry about the CMUCL limit.")) (date-format :initarg :date-format :reader date-format - :initform "YYYY-MM-DD HH24:MI:SS\"+00\"") + :initform "YYYY-MM-DD HH24:MI:SS\".0\"") (date-format-length :type number :documentation @@ -154,8 +154,8 @@ the length of that format.") (cond (database (with-slots (errhp) database - (uffi:with-foreign-objects ((errcode 'sb4) - (errbuf '(:array :unsigned-char #.+errbuf-len+))) + (let ((errcode (uffi:allocate-foreign-object 'sb4)) + (errbuf (uffi:allocate-foreign-string #.+errbuf-len+))) ;; ensure errbuf empty string (setf (uffi:deref-array errbuf '(:array :unsigned-char) 0) (uffi:ensure-char-storable (code-char 0))) @@ -169,6 +169,8 @@ the length of that format.") +errbuf-len+ +oci-htype-error+)) (let ((subcode (uffi:deref-pointer errcode 'sb4)) (errstr (uffi:convert-from-foreign-string errbuf))) + (uffi:free-foreign-object errcode) + (uffi:free-foreign-object errbuf) (unless (and nulls-ok (= subcode +null-value-returned+)) (error 'sql-database-error :database database @@ -501,7 +503,7 @@ the length of that format.") (uffi:with-foreign-strings ((c-stmt-string sql-stmt-string)) (let ((stmthp (uffi:allocate-foreign-object :pointer-void)) select-p) - + (uffi:with-foreign-object (stmttype :unsigned-short) (unwind-protect (progn @@ -520,10 +522,10 @@ the length of that format.") +oci-attr-stmt-type+ (deref-vp errhp) :database db) - + (setq select-p (= (uffi:deref-pointer stmttype :unsigned-short) 1)) (let ((iters (if select-p 0 1))) - + (oci-stmt-execute (deref-vp svchp) (deref-vp stmthp) (deref-vp errhp) @@ -533,7 +535,7 @@ the length of that format.") (unless select-p (oci-handle-free (deref-vp stmthp) +oci-htype-stmt+) (uffi:free-foreign-object stmthp)))) - + (cond (select-p (make-query-cursor db stmthp result-types field-names))