X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-oracle%2Foracle.lisp;h=94b45a808d31b3b5c54022cea8566cb77ed63465;hb=75d1ee3641045c3041d1aa8b0e5bf5d1f382da44;hp=407d711082338a3dfea59ed99b2a00bf2f1f8d1b;hpb=39bc32836bdf5bdab576ba1e4ef3762f46000b98;p=clsql.git diff --git a/db-oracle/oracle.lisp b/db-oracle/oracle.lisp index 407d711..94b45a8 100644 --- a/db-oracle/oracle.lisp +++ b/db-oracle/oracle.lisp @@ -52,6 +52,7 @@ (pointer (uffi:allocate-foreign-object '(* :void)))) (defvar +null-void-pointer+ (uffi:make-null-pointer :void)) +(defvar +null-void-pointer-pointer+ (uffi:make-null-pointer (* :void))) (uffi:def-function "OCIInitialize" ((a :int) @@ -94,27 +95,30 @@ ,c-parms :returning ,c-return))) (defun ,lisp-oci-fn (,@ll &key database nulls-ok) - (case (funcall %lisp-oci-fn ,@ll) - (#.+oci-success+ - +oci-success+) - (#.+oci-error+ - (handle-oci-error :database database :nulls-ok nulls-ok)) - (#.+oci-no-data+ - (error "OCI No Data Found")) - (#.+oci-success-with-info+ - (error "internal error: unexpected +oci-SUCCESS-WITH-INFO")) - (#.+oci-no-data+ - (error "OCI No Data")) - (#.+oci-invalid-handle+ - (error "OCI Invalid Handle")) - (#.+oci-need-data+ - (error "OCI Need Data")) - (#.+oci-still-executing+ - (error "OCI Still Executing")) - (#.+oci-continue+ - (error "OCI Continue")) - (t - (error "OCI unknown error, code=~A" (values)))))))) + (let ((result (funcall %lisp-oci-fn ,@ll))) + (case result + (#.+oci-success+ + +oci-success+) + (#.+oci-error+ + (handle-oci-error :database database :nulls-ok nulls-ok)) + (#.+oci-no-data+ + (error "OCI No Data Found")) + (#.+oci-success-with-info+ + (error "internal error: unexpected +oci-SUCCESS-WITH-INFO")) + (#.+oci-no-data+ + (error "OCI No Data")) + (#.+oci-invalid-handle+ + (error "OCI Invalid Handle")) + (#.+oci-need-data+ + (error "OCI Need Data")) + (#.+oci-still-executing+ + (error "OCI Still Executing")) + (#.+oci-continue+ + (error "OCI Continue")) + (1804 + (error "Check ORACLE_HOME and NLS settings.")) + (t + (error "OCI unknown error, code=~A" result)))))))) (defmacro def-raw-oci-routine @@ -130,10 +134,10 @@ (def-oci-routine ("OCIInitialize" oci-initialize) :int (mode :unsigned-long) ; ub4 - (ctxp (* :void)) ; dvoid * - (malocfp (* :void)) ; dvoid *(*) - (ralocfp (* :void)) ; dvoid *(*) - (mfreefp (* :void))) ; void *(*) + (ctxp (* :void)) ; dvoid * + (malocfp (* :void)) ; dvoid *(*) + (ralocfp (* :void)) ; dvoid *(*) + (mfreefp (* (* :void)))) ; void *(*) (def-oci-routine ("OCIEnvInit" oci-env-init) @@ -141,7 +145,7 @@ (envpp (* :void)) ; OCIEnv ** (mode :unsigned-long) ; ub4 (xtramem-sz :unsigned-long) ; size_t - (usermempp (* :void))) ; dvoid ** + (usermempp (* (* :void)))) ; dvoid ** #+oci-8-1-5 (def-oci-routine ("OCIEnvCreate" oci-env-create) @@ -157,11 +161,11 @@ (def-oci-routine ("OCIHandleAlloc" oci-handle-alloc) :int - (parenth (* :void)) ; const dvoid * - (hndlpp (* :void)) ; dvoid ** - (type :unsigned-long) ; ub4 - (xtramem_sz :unsigned-long) ; size_t - (usrmempp (* :void))) ; dvoid ** + (parenth (* :void)) ; const dvoid * + (hndlpp (* (* :void))) ; dvoid ** + (type :unsigned-long) ; ub4 + (xtramem_sz :unsigned-long) ; size_t + (usrmempp (* (* :void)))) ; dvoid ** (def-oci-routine ("OCIServerAttach" oci-server-attach) :int @@ -179,15 +183,15 @@ (def-oci-routine ("OCILogon" oci-logon) :int - (envhp (* :void)) ; env - (errhp (* :void)) ; err - (svchp (* :void)) ; svc - (username :cstring) ; username - (uname-len :unsigned-long) ; - (passwd :cstring) ; passwd - (password-len :unsigned-long) ; - (dsn :cstring) ; datasource - (dsn-len :unsigned-long)) ; + (envhp (* :void)) ; env + (errhp (* :void)) ; err + (svchpp (* (* :void))) ; svc + (username :cstring) ; username + (uname-len :unsigned-long) ; + (passwd :cstring) ; passwd + (password-len :unsigned-long) ; + (dsn :cstring) ; datasource + (dsn-len :unsigned-long)) ; (def-oci-routine ("OCILogoff" oci-logoff) :int @@ -195,53 +199,52 @@ (p1 (* :void))) ; err (uffi:def-function ("OCIErrorGet" oci-error-get) - ((p0 (* :void)) - (p1 :unsigned-long) - (p2 :cstring) - (p3 (* :long)) - (p4 (* :void)) - (p5 :unsigned-long) - (p6 :unsigned-long)) + ((handlp (* :void)) + (recordno :unsigned-long) + (sqlstate :cstring) + (errcodep (* :long)) + (bufp (* :unsigned-char)) + (bufsize :unsigned-long) + (type :unsigned-long)) :returning :void) (def-oci-routine ("OCIStmtPrepare" oci-stmt-prepare) :int - (p0 (* :void)) - (p1 (* :void)) - (p2 :cstring) - (p3 :unsigned-long) - (p4 :unsigned-long) - (p5 :unsigned-long)) + (stmtp (* :void)) + (errhp (* :void)) + (stmt :cstring) + (stmt_len :unsigned-long) + (language :unsigned-long) + (mode :unsigned-long)) (def-oci-routine ("OCIStmtExecute" oci-stmt-execute) :int - (p0 (* :void)) - (p1 (* :void)) - (p2 (* :void)) - (p3 :unsigned-long) - (p4 :unsigned-long) - (p5 (* :void)) - (p6 (* :void)) - (p7 :unsigned-long)) + (svchp (* :void)) + (stmtp1 (* :void)) + (errhp (* :void)) + (iters :unsigned-long) + (rowoff :unsigned-long) + (snap_in (* :void)) + (snap_out (* :void)) + (mode :unsigned-long)) (def-raw-oci-routine ("OCIParamGet" oci-param-get) :int - (p0 (* :void)) - (p1 :unsigned-long) - (p2 (* :void)) - (p3 (* :void)) - (p4 :unsigned-long)) + (hndlp (* :void)) + (htype :unsigned-long) + (errhp (* :void)) + (parmdpp (* (* :void))) + (pos :unsigned-long)) (def-oci-routine ("OCIAttrGet" oci-attr-get) :int - (p0 (* :void)) - (p1 :unsigned-long) - (p2 (* :void)) - (p3 (* :unsigned-long)) - (p4 :unsigned-long) - (p5 (* :void))) + (trgthndlp (* :void)) + (trghndltyp :unsigned-int) + (attributep (* :void)) + (sizep (* :unsigned-int)) + (attrtype :unsigned-int) + (errhp (* :void))) -#+nil (def-oci-routine ("OCIAttrSet" oci-attr-set) :int (trgthndlp (* :void)) @@ -315,9 +318,9 @@ (oci-init)) (case type (:error - (let ((ptr (uffi:make-pointer 0 (* :void)))) + (let ((ptr (uffi:make-null-pointer (* :void)))) (let ((x (OCIHandleAlloc - (pointer-address (uffi:deref-pointer *oci-env* oci-env)) + (uffi:pointer-address (uffi:deref-pointer *oci-env* oci-env)) ptr +oci-default+ 0