r10836: 14 Nov 2005 Kevin Rosenberg <kevin@rosenberg.net>
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 15 Nov 2005 02:44:14 +0000 (02:44 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 15 Nov 2005 02:44:14 +0000 (02:44 +0000)
        * Version 3.4.4 [ Requires UFFI 1.5.7+]
        * db-oracle/oracle-{api,sql}.lisp: Patch from James Biel
        to fix lifetime of foreign strings for Oracle calls

ChangeLog
db-oracle/oracle-api.lisp
db-oracle/oracle-sql.lisp
debian/changelog

index c011dca1bae8df1a7ee1d5cb223dacd8fd3c5143..3b83773952fe80028bccdb50035aa35ed9fb8629 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,13 @@
+14 Nov 2005  Kevin Rosenberg <kevin@rosenberg.net>
+       * Version 3.4.4 [ Requires UFFI 1.5.7+] 
+       * db-oracle/oracle-{api,sql}.lisp: Patch from James Biel
+       to fix lifetime of foreign strings for Oracle calls
+
 13 Nov 2005  Kevin Rosenberg <kevin@rosenberg.net>
        * Version 3.4.3
        * db-oracle/oracle-{api,sql}.lisp: Patch from James Biel
        to improve performance
 13 Nov 2005  Kevin Rosenberg <kevin@rosenberg.net>
        * Version 3.4.3
        * db-oracle/oracle-{api,sql}.lisp: Patch from James Biel
        to improve performance
-               
+       
 12 Nov 2005  Kevin Rosenberg <kevin@rosenberg.net>
        * Version 3.4.2
        * clsql-uffi.asd: Patch from James Biel improving loading
 12 Nov 2005  Kevin Rosenberg <kevin@rosenberg.net>
        * Version 3.4.2
        * clsql-uffi.asd: Patch from James Biel improving loading
index 454011fafc5d81f97c63c4cbb8fab72264545c4f..377c3f3a9c943cee23bdfdaa9a56a1399e92615d 100644 (file)
   (envhp        :pointer-void)         ; env
   (errhp        :pointer-void)         ; err
   (svchpp       (* :pointer-void))     ; svc
   (envhp        :pointer-void)         ; env
   (errhp        :pointer-void)         ; err
   (svchpp       (* :pointer-void))     ; svc
-  (username     :cstring)              ; username
+  (username     (* :unsigned-char))    ; username
   (uname-len    ub4)                   ;
   (uname-len    ub4)                   ;
-  (passwd       :cstring)              ; passwd
+  (passwd       (* :unsigned-char))    ; passwd
   (password-len ub4)                   ;
   (password-len ub4)                   ;
-  (dsn          :cstring)              ; datasource
+  (dsn          (* :unsigned-char))    ; datasource
   (dsn-len      ub4))                  ;
 
 (def-oci-routine ("OCILogoff" oci-logoff)
   (dsn-len      ub4))                  ;
 
 (def-oci-routine ("OCILogoff" oci-logoff)
     :int
   (stmtp      :pointer-void)
   (errhp      :pointer-void)
     :int
   (stmtp      :pointer-void)
   (errhp      :pointer-void)
-  (stmt       :cstring)
+  (stmt       (* :unsigned-char))
   (stmt_len   ub4)
   (language   ub4)
   (mode       ub4))
   (stmt_len   ub4)
   (language   ub4)
   (mode       ub4))
index b18bad77e40fc22f35b9079fe02d8675e3e1de32..6a6aa3f4f5ba0ca6c88a93d00ebbf975d3426b3e 100644 (file)
@@ -498,46 +498,47 @@ the length of that format.")
 
 (defun sql-stmt-exec (sql-stmt-string db result-types field-names)
   (with-slots (envhp svchp errhp) db
 
 (defun sql-stmt-exec (sql-stmt-string db result-types field-names)
   (with-slots (envhp svchp errhp) db
-    (let ((stmthp (uffi:allocate-foreign-object :pointer-void))
-          select-p)
+    (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
-              (oci-handle-alloc (deref-vp envhp)
-                                stmthp
-                                +oci-htype-stmt+ 0 +null-void-pointer-pointer+)
-              (oci-stmt-prepare (deref-vp stmthp)
-                                (deref-vp errhp)
-                                (uffi:convert-to-cstring sql-stmt-string)
-                                (length sql-stmt-string)
-                                +oci-ntv-syntax+ +oci-default+ :database db)
-              (oci-attr-get (deref-vp stmthp)
-                            +oci-htype-stmt+
-                            stmttype
-                            +unsigned-int-null-pointer+
-                            +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)
-                                  iters 0 +null-void-pointer+ +null-void-pointer+ +oci-default+
-                                  :database db)))
-         ;; free resources unless a query
-         (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))
-       (t
-        nil)))))
+        (uffi:with-foreign-object (stmttype :unsigned-short)
+          (unwind-protect
+               (progn
+                 (oci-handle-alloc (deref-vp envhp)
+                                   stmthp
+                                   +oci-htype-stmt+ 0 +null-void-pointer-pointer+)
+                 (oci-stmt-prepare (deref-vp stmthp)
+                                   (deref-vp errhp)
+                                   c-stmt-string
+                                   (length sql-stmt-string)
+                                   +oci-ntv-syntax+ +oci-default+ :database db)
+                 (oci-attr-get (deref-vp stmthp)
+                               +oci-htype-stmt+
+                               stmttype
+                               +unsigned-int-null-pointer+
+                               +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)
+                                     iters 0 +null-void-pointer+ +null-void-pointer+ +oci-default+
+                                     :database db)))
+            ;; free resources unless a query
+            (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))
+          (t
+           nil))))))
 
 
 ;; Return a QUERY-CURSOR representing the table returned from the OCI
 
 
 ;; Return a QUERY-CURSOR representing the table returned from the OCI
@@ -795,6 +796,7 @@ the length of that format.")
       (oci-env-create envhp +oci-default+ +null-void-pointer+
                      +null-void-pointer+ +null-void-pointer+
                      +null-void-pointer+ 0 +null-void-pointer-pointer+)
       (oci-env-create envhp +oci-default+ +null-void-pointer+
                      +null-void-pointer+ +null-void-pointer+
                      +null-void-pointer+ 0 +null-void-pointer-pointer+)
+
       #+oci7
       (progn
        (oci-initialize +oci-object+ +null-void-pointer+ +null-void-pointer+
       #+oci7
       (progn
        (oci-initialize +oci-object+ +null-void-pointer+ +null-void-pointer+
@@ -803,27 +805,12 @@ the length of that format.")
                                         +oci-htype-env+ 0
                                         +null-void-pointer-pointer+)) ;no testing return
         (oci-env-init envhp +oci-default+ 0 +null-void-pointer-pointer+))
                                         +oci-htype-env+ 0
                                         +null-void-pointer-pointer+)) ;no testing return
         (oci-env-init envhp +oci-default+ 0 +null-void-pointer-pointer+))
+
       (oci-handle-alloc (deref-vp envhp) errhp
                        +oci-htype-error+ 0 +null-void-pointer-pointer+)
       (oci-handle-alloc (deref-vp envhp) srvhp
                        +oci-htype-server+ 0 +null-void-pointer-pointer+)
 
       (oci-handle-alloc (deref-vp envhp) errhp
                        +oci-htype-error+ 0 +null-void-pointer-pointer+)
       (oci-handle-alloc (deref-vp envhp) srvhp
                        +oci-htype-server+ 0 +null-void-pointer-pointer+)
 
-      #+ignore ;; not used since CLSQL uses the OCILogon function instead
-      (uffi:with-cstring (dblink nil)
-       (oci-server-attach (deref-vp srvhp)
-                          (deref-vp errhp)
-                          dblink
-                          0 +oci-default+))
-
-      (oci-handle-alloc (deref-vp envhp) svchp
-                       +oci-htype-svcctx+ 0 +null-void-pointer-pointer+)
-      (oci-attr-set (deref-vp svchp)
-                   +oci-htype-svcctx+
-                   (deref-vp srvhp) 0 +oci-attr-server+
-                   (deref-vp errhp))
-      ;; oci-handle-alloc((dvoid *)encvhp, (dvoid **)&stmthp, OCI_HTYPE_STMT, 0, 0);
-      ;;#+nil
-
       (let ((db (make-instance 'oracle-database
                  :name (database-name-from-spec connection-spec
                                                 database-type)
       (let ((db (make-instance 'oracle-database
                  :name (database-name-from-spec connection-spec
                                                 database-type)
@@ -834,13 +821,16 @@ the length of that format.")
                  :svchp svchp
                  :dsn data-source-name
                  :user user)))
                  :svchp svchp
                  :dsn data-source-name
                  :user user)))
-       (oci-logon (deref-vp envhp)
-                  (deref-vp errhp)
-                  svchp
-                  (uffi:convert-to-cstring user) (length user)
-                  (uffi:convert-to-cstring password) (length password)
-                  (uffi:convert-to-cstring data-source-name) (length data-source-name)
-                  :database db)
+        (uffi:with-foreign-strings ((c-user user)
+                                    (c-password password)
+                                    (c-data-source-name data-source-name))
+          (oci-logon (deref-vp envhp)
+                     (deref-vp errhp)
+                     svchp
+                     c-user (length user)
+                     c-password (length password)
+                     c-data-source-name (length data-source-name)
+                     :database db))
        ;; :date-format-length (1+ (length date-format)))))
        (setf (slot-value db 'clsql-sys::state) :open)
         (database-execute-command
        ;; :date-format-length (1+ (length date-format)))))
        (setf (slot-value db 'clsql-sys::state) :open)
         (database-execute-command
index 22a5573fb0e5cd61440f4e30f9059b291e509630..29a55fbfe5a85f3a028c7fc70421aabfdd5e91a4 100644 (file)
@@ -1,3 +1,9 @@
+cl-sql (3.4.4-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Mon, 14 Nov 2005 19:41:24 -0700
+
 cl-sql (3.4.3-1) unstable; urgency=low
 
   * New upstream
 cl-sql (3.4.3-1) unstable; urgency=low
 
   * New upstream