X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-oracle%2Foracle-sql.lisp;h=b5876d44cbff9d96a6358d544af5e1728d65a43c;hb=1df8353cc15bcbf98078605cb6955aafa622ecea;hp=dfc3a155ae59a333f8255a95b50e57ddaf2723ed;hpb=5c67b804b62d2970685ebd8d28c88446457be975;p=clsql.git diff --git a/db-oracle/oracle-sql.lisp b/db-oracle/oracle-sql.lisp index dfc3a15..b5876d4 100644 --- a/db-oracle/oracle-sql.lisp +++ b/db-oracle/oracle-sql.lisp @@ -196,36 +196,21 @@ the length of that format.") (setf debug::*debug-print-length* nil)) -;;;; the OCI library, part V: converting from OCI representations to Lisp -;;;; representations - ;; Return the INDEXth string of the OCI array, represented as Lisp ;; SIMPLE-STRING. SIZE is the size of the fixed-width fields used by ;; Oracle to store strings within the array. -;; In the wild world of databases, trailing spaces aren't generally -;; significant, since e.g. "LARRY " and "LARRY " are the same string -;; stored in different fixed-width fields. OCI drops trailing spaces -;; for us in some cases but apparently not for fields of fixed -;; character width, e.g. -;; -;; (dbi:sql "create table employees (name char(15), job char(15), city -;; char(15), rate float)" :db orcl :types :auto) -;; In order to map the "same string" property above onto Lisp equality, -;; we drop trailing spaces in all cases: - (uffi:def-type string-pointer (* :unsigned-char)) (defun deref-oci-string (arrayptr string-index size) (declare (type string-pointer arrayptr)) (declare (type (mod #.+n-buf-rows+) string-index)) (declare (type (and unsigned-byte fixnum) size)) - (let* ((raw (uffi:convert-from-foreign-string - (uffi:make-pointer - (+ (uffi:pointer-address arrayptr) (* string-index size)) - :unsigned-char))) - (trimmed (string-trim " " raw))) - (if (equal trimmed "NULL") nil trimmed))) + (let ((str (uffi:convert-from-foreign-string + (uffi:make-pointer + (+ (uffi:pointer-address arrayptr) (* string-index size)) + :unsigned-char)))) + (if (string-equal str "NULL") nil str))) ;; the OCI library, part Z: no-longer used logic to convert from ;; Oracle's binary date representation to Common Lisp's native date @@ -916,17 +901,17 @@ the length of that format.") ) database :auto nil))) -;; FIXME: use lock (defmethod database-set-sequence-position (name position (database oracle-database)) - (let* ((next (database-sequence-next name database)) - (incr (- position next))) - (database-execute-command - (format nil "ALTER SEQUENCE ~A INCREMENT BY ~D" name incr) - database) - (database-sequence-next name database) - (database-execute-command - (format nil "ALTER SEQUENCE ~A INCREMENT BY 1" name) - database))) + (without-interrupts + (let* ((next (database-sequence-next name database)) + (incr (- position next))) + (database-execute-command + (format nil "ALTER SEQUENCE ~A INCREMENT BY ~D" name incr) + database) + (database-sequence-next name database) + (database-execute-command + (format nil "ALTER SEQUENCE ~A INCREMENT BY 1" name) + database)))) (defmethod database-list-sequences ((database oracle-database) &key owner) (let ((query