From f97c6c182c9746cd6adbdacf8cdfebbaadef3c37 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Tue, 3 Aug 2004 06:27:00 +0000 Subject: [PATCH] r9831: * db-aodbc/aodbc-sql.lisp: Fix storage location of odbc connection. Specialize database-query since dbi's :types keyword is different than generic-odbc's :result-types keyword * sql/db-interface.lisp: Add warnings for methods not specialized by a db backends * tests/test-fddl.lisp: Fix case of symbols to support case-sensitive Allegro * db-oracle/oracle-sql.lisp: Rework errbuf in handle-oci-error * tests/test-init.lisp: Note that odbc driver for postgresql doesn't properly handle table ownership --- ChangeLog | 15 ++++++++ LATEST-TEST-RESULTS | 81 +++++++++++++++------------------------ db-aodbc/aodbc-sql.lisp | 19 +++++++-- db-oracle/oracle-sql.lisp | 61 ++++++++++++++--------------- debian/changelog | 6 +++ sql/db-interface.lisp | 36 ++++++++++++++++- tests/test-fddl.lisp | 2 +- tests/test-init.lisp | 8 +++- 8 files changed, 139 insertions(+), 89 deletions(-) diff --git a/ChangeLog b/ChangeLog index 801bd68..f9dd738 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +3 Aug 2004 Kevin Rosenberg + * Version 3.0.0 Release + * db-aodbc/aodbc-sql.lisp: Fix storage location + of odbc connection. Specialize database-query since + dbi's :types keyword is different than generic-odbc's + :result-types keyword + * sql/db-interface.lisp: Add warnings for methods + not specialized by a db backends + * tests/test-fddl.lisp: Fix case of symbols to support + case-sensitive Allegro + * db-oracle/oracle-sql.lisp: Rework errbuf in handle-oci-error + * tests/test-init.lisp: Note that odbc driver for postgresql + doesn't properly handle table ownership + * LATEST-TEST-RESULTS: update with version 3.0.0 + 1 Aug 2004 Marcus Pearce * sql/expressions.lisp: conditionalise escaping of backslash in generated SQL strings on backend. diff --git a/LATEST-TEST-RESULTS b/LATEST-TEST-RESULTS index cd03579..acc91b4 100644 --- a/LATEST-TEST-RESULTS +++ b/LATEST-TEST-RESULTS @@ -1,52 +1,31 @@ -Version 2.10.17 run on May 13, 2004 on x86, x86_64, and PowerPC platforms +Version 3.0.0 run on August 3, 2004 on x86, x86_64, and PowerPC platforms -POSTGRESQL: All 174 tests passed (64-bit AMD64, Allegro CL Enterprise Edition). -POSTGRESQL-SOCKET: All 174 tests passed (64-bit AMD64, Allegro CL Enterprise Edition). -MYSQL: All 158 tests passed (64-bit AMD64, Allegro CL Enterprise Edition). -SQLITE: All 168 tests passed (64-bit AMD64, Allegro CL Enterprise Edition). -ODBC/POSTGRESQL: All 174 tests passed (64-bit AMD64, Allegro CL Enterprise Edition). -ODBC/MYSQL: All 158 tests passed (64-bit AMD64, Allegro CL Enterprise Edition). - -POSTGRESQL: All 174 tests passed (X86, SBCL). -POSTGRESQL-SOCKET: All 174 tests passed (X86, SBCL). -MYSQL: All 158 tests passed (X86, SBCL). -SQLITE: All 168 tests passed (X86, SBCL). -ODBC/POSTGRESQL: All 174 tests passed (X86, SBCL). -ODBC/MYSQL: All 158 tests passed (X86, SBCL). -POSTGRESQL: All 174 tests passed (x86, Allegro CL Enterprise Edition). -POSTGRESQL-SOCKET: All 174 tests passed (x86, Allegro CL Enterprise Edition). -MYSQL: All 158 tests passed (x86, Allegro CL Enterprise Edition). -SQLITE: All 168 tests passed (x86, Allegro CL Enterprise Edition). -ODBC/POSTGRESQL: All 174 tests passed (x86, Allegro CL Enterprise Edition). -ODBC/MYSQL: All 158 tests passed (x86, Allegro CL Enterprise Edition). -POSTGRESQL: All 174 tests passed (X86, CMU Common Lisp). -POSTGRESQL-SOCKET: All 174 tests passed (X86, CMU Common Lisp). -MYSQL: All 158 tests passed (X86, CMU Common Lisp). -SQLITE: All 168 tests passed (X86, CMU Common Lisp). -ODBC/POSTGRESQL: All 174 tests passed (X86, CMU Common Lisp). -ODBC/MYSQL: All 158 tests passed (X86, CMU Common Lisp). -POSTGRESQL: All 174 tests passed (NIL, LispWorks). -POSTGRESQL-SOCKET: All 174 tests passed (NIL, LispWorks). -MYSQL: All 158 tests passed (NIL, LispWorks). -SQLITE: All 168 tests passed (NIL, LispWorks). -ODBC/POSTGRESQL: All 174 tests passed (NIL, LispWorks). -ODBC/MYSQL: All 158 tests passed (NIL, LispWorks). - -POSTGRESQL: All 174 tests passed (PowerPC, Allegro CL Enterprise Edition). -POSTGRESQL-SOCKET: All 174 tests passed (PowerPC, Allegro CL Enterprise Edition). -MYSQL: All 158 tests passed (PowerPC, Allegro CL Enterprise Edition). -SQLITE: All 168 tests passed (PowerPC, Allegro CL Enterprise Edition). -ODBC/MYSQL: All 158 tests passed (PowerPC, Allegro CL Enterprise Edition). -ODBC/POSTGRESQL: All 174 tests passed (PowerPC, Allegro CL Enterprise Edition). -POSTGRESQL: All 174 tests passed (PowerPC, SBCL). -POSTGRESQL-SOCKET: All 174 tests passed (PowerPC, SBCL). -MYSQL: All 158 tests passed (PowerPC, SBCL). -SQLITE: All 168 tests passed (PowerPC, SBCL). -ODBC/MYSQL: All 158 tests passed (PowerPC, SBCL). -ODBC/POSTGRESQL: All 174 tests passed (PowerPC, SBCL). -POSTGRESQL: All 174 tests passed (ppc, OpenMCL). -POSTGRESQL-SOCKET: All 174 tests passed (ppc, OpenMCL). -MYSQL: All 158 tests passed (ppc, OpenMCL). -SQLITE: All 168 tests passed (ppc, OpenMCL). -ODBC/MYSQL: All 158 tests passed (ppc, OpenMCL). -ODBC/POSTGRESQL: All 174 tests passed (ppc, OpenMCL). +POSTGRESQL: All 233 tests passed (x86, International Allegro CL Enterprise Edition). +POSTGRESQL-SOCKET/POSTGRESQL: All 233 tests passed (x86, International Allegro CL Enterprise Edition). +MYSQL: All 213 tests passed (x86, International Allegro CL Enterprise Edition). +SQLITE: All 224 tests passed (x86, International Allegro CL Enterprise Edition). +ODBC/POSTGRESQL: All 232 tests passed (x86, International Allegro CL Enterprise Edition). +ODBC/MYSQL: All 213 tests passed (x86, International Allegro CL Enterprise Edition). +ORACLE: All 227 tests passed (x86, International Allegro CL Enterprise Edition). +AODBC/UNKNOWN: 23 of 231 tests failed (x86, International Allegro CL Enterprise Edition). +POSTGRESQL: All 233 tests passed (X86, CMU Common Lisp). +POSTGRESQL-SOCKET/POSTGRESQL: All 233 tests passed (X86, CMU Common Lisp). +MYSQL: All 213 tests passed (X86, CMU Common Lisp). +SQLITE: All 224 tests passed (X86, CMU Common Lisp). +ODBC/POSTGRESQL: All 232 tests passed (X86, CMU Common Lisp). +ODBC/MYSQL: All 213 tests passed (X86, CMU Common Lisp). +ORACLE: All 227 tests passed (X86, CMU Common Lisp). +POSTGRESQL: All 233 tests passed (NIL, LispWorks). +POSTGRESQL-SOCKET/POSTGRESQL: All 233 tests passed (NIL, LispWorks). +MYSQL: All 213 tests passed (NIL, LispWorks). +SQLITE: All 224 tests passed (NIL, LispWorks). +ODBC/POSTGRESQL: All 232 tests passed (NIL, LispWorks). +ODBC/MYSQL: All 213 tests passed (NIL, LispWorks). +ORACLE: All 227 tests passed (NIL, LispWorks). +POSTGRESQL: All 233 tests passed (X86, SBCL). +POSTGRESQL-SOCKET/POSTGRESQL: All 233 tests passed (X86, SBCL). +MYSQL: All 213 tests passed (X86, SBCL). +SQLITE: All 224 tests passed (X86, SBCL). +ODBC/POSTGRESQL: All 232 tests passed (X86, SBCL). +ODBC/MYSQL: All 213 tests passed (X86, SBCL). +ORACLE: All 227 tests passed (X86, SBCL). diff --git a/db-aodbc/aodbc-sql.lisp b/db-aodbc/aodbc-sql.lisp index 7994892..8cd3076 100644 --- a/db-aodbc/aodbc-sql.lisp +++ b/db-aodbc/aodbc-sql.lisp @@ -34,8 +34,7 @@ ;; AODBC interface (defclass aodbc-database (generic-odbc-database) - ((aodbc-conn :accessor database-aodbc-conn :initarg :aodbc-conn) - (aodbc-db-type :accessor database-aodbc-db-type :initform :unknown))) + ((aodbc-db-type :accessor database-aodbc-db-type :initform :unknown))) (defmethod database-name-from-spec (connection-spec (database-type (eql :aodbc))) @@ -53,7 +52,7 @@ :name (database-name-from-spec connection-spec :aodbc) :database-type :aodbc :dbi-package (find-package '#:dbi) - :aodbc-conn + :odbc-conn (dbi:connect :user user :password password :data-source-name dsn)) @@ -66,6 +65,20 @@ :message "Connection failed"))))) +(defmethod database-query (query-expression (database aodbc-database) + result-types field-names) + #+aodbc-v2 + (handler-case + (dbi:sql query-expression + :db (clsql-sys::odbc-conn database) + :types result-types + :column-names field-names) + #+ignore + (error () + (error 'sql-database-data-error + :database database + :expression query-expression + :message "Query failed")))) (defmethod database-create (connection-spec (type (eql :aodbc))) (warn "Not implemented.")) diff --git a/db-oracle/oracle-sql.lisp b/db-oracle/oracle-sql.lisp index d59665d..0348068 100644 --- a/db-oracle/oracle-sql.lisp +++ b/db-oracle/oracle-sql.lisp @@ -126,36 +126,37 @@ the length of that format.") ;;; NULLS-OK are as in the OERR function. (defun handle-oci-error (&key database nulls-ok) - (cond (database - (with-slots (errhp) database - (uffi:with-foreign-objects ((errbuf '(:array :unsigned-char - #.+errbuf-len+)) - (errcode :long)) - ;; ensure errbuf empty string - (setf (uffi:deref-array errbuf '(:array :unsigned-char) 0) - (uffi:ensure-char-storable (code-char 0))) - (setf (uffi:deref-pointer errcode :long) 0) - - (uffi:with-cstring (sqlstate nil) - (oci-error-get (deref-vp errhp) 1 - sqlstate - errcode - (uffi:char-array-to-pointer errbuf) - +errbuf-len+ +oci-htype-error+)) - (let ((subcode (uffi:deref-pointer errcode :long))) - (unless (and nulls-ok (= subcode +null-value-returned+)) - (error 'sql-database-error - :database database - :error-id subcode - :message (uffi:convert-from-foreign-string errbuf))))))) - (nulls-ok - (error 'sql-database-error - :database database - :message "can't handle NULLS-OK without ERRHP")) - (t - (error 'sql-database-error - :database database - :message "OCI Error (and no ERRHP available to find subcode)")))) + (cond + (database + (with-slots (errhp) database + (uffi:with-foreign-object (errcode :long) + (let ((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))) + (setf (uffi:deref-pointer errcode :long) 0) + + (uffi:with-cstring (sqlstate nil) + (oci-error-get (deref-vp errhp) 1 + sqlstate + errcode + (uffi:char-array-to-pointer errbuf) + +errbuf-len+ +oci-htype-error+)) + (let ((subcode (uffi:deref-pointer errcode :long))) + (unless (and nulls-ok (= subcode +null-value-returned+)) + (error 'sql-database-error + :database database + :error-id subcode + :message (uffi:convert-from-foreign-string errbuf)))) + (uffi:free-foreign-object errbuf))))) + (nulls-ok + (error 'sql-database-error + :database database + :message "can't handle NULLS-OK without ERRHP")) + (t + (error 'sql-database-error + :database database + :message "OCI Error (and no ERRHP available to find subcode)")))) ;;; Require an OCI success code. ;;; diff --git a/debian/changelog b/debian/changelog index 9b9f7c6..c3d11b6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cl-sql (3.0.0-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Mon, 2 Aug 2004 19:32:39 -0600 + cl-sql (2.11.16-1) unstable; urgency=low * New upstream diff --git a/sql/db-interface.lisp b/sql/db-interface.lisp index d6b1abe..cc53287 100644 --- a/sql/db-interface.lisp +++ b/sql/db-interface.lisp @@ -172,6 +172,10 @@ the given lisp type and parameters.")) (defgeneric database-list-tables (database &key owner) (:documentation "List all tables in the given database") + (:method ((database database) &key owner) + (declare (ignore owner)) + (warn "database-list-tables not implemented for database type ~A." + (database-type database))) (:method ((database t) &key owner) (declare (ignore owner)) (signal-no-database-error database))) @@ -186,24 +190,40 @@ the given lisp type and parameters.")) (defgeneric database-list-views (database &key owner) (:documentation "List all views in the DATABASE.") + (:method ((database database) &key owner) + (declare (ignore owner)) + (warn "database-list-views not implemented for database type ~A." + (database-type database))) (:method ((database t) &key owner) (declare (ignore owner)) (signal-no-database-error database))) (defgeneric database-list-indexes (database &key owner) (:documentation "List all indexes in the DATABASE.") - (:method ((database t) &key owner) + (:method ((database database) &key owner) (declare (ignore owner)) - (signal-no-database-error database))) + (warn "database-list-indexes not implemented for database type ~A." + (database-type database))) + (:method ((database t) &key owner) + (declare (ignore owner)) + (signal-no-database-error database))) (defgeneric database-list-table-indexes (table database &key owner) (:documentation "List all indexes for a table in the DATABASE.") + (:method (table (database database) &key owner) + (declare (ignore table owner)) + (warn "database-list-table-indexes not implemented for database type ~A." + (database-type database))) (:method (table (database t) &key owner) (declare (ignore table owner)) (signal-no-database-error database))) (defgeneric database-list-attributes (table database &key owner) (:documentation "List all attributes in TABLE.") + (:method (table (database database) &key owner) + (declare (ignore table owner)) + (warn "database-list-attributes not implemented for database type ~A." + (database-type database))) (:method (table (database t) &key owner) (declare (ignore table owner)) (signal-no-database-error database))) @@ -211,18 +231,30 @@ the given lisp type and parameters.")) (defgeneric database-attribute-type (attribute table database &key owner) (:documentation "Return the type of ATTRIBUTE in TABLE. Returns multiple values of TYPE_NAME (keyword) PRECISION SCALE NULLABLE.") + (:method (attribute table (database database) &key owner) + (declare (ignore attribute table owner)) + (warn "database-list-attribute-type not implemented for database type ~A." + (database-type database))) (:method (attribute table (database t) &key owner) (declare (ignore attribute table owner)) (signal-no-database-error database))) (defgeneric database-add-attribute (table attribute database) (:documentation "Add the attribute to the table.") + (:method (table attribute (database database)) + (declare (ignore table attribute)) + (warn "database-add-attribute not implemented for database type ~A." + (database-type database))) (:method (table attribute (database t)) (declare (ignore table attribute)) (signal-no-database-error database))) (defgeneric database-rename-attribute (table oldatt newname database) (:documentation "Rename the attribute in the table to NEWNAME.") + (:method (table oldatt newname (database database)) + (declare (ignore table oldatt newname)) + (warn "database-rename-attribute not implemented for database type ~A." + (database-type database))) (:method (table oldatt newname (database t)) (declare (ignore table oldatt newname)) (signal-no-database-error database))) diff --git a/tests/test-fddl.lisp b/tests/test-fddl.lisp index 8c54c3f..f5527c7 100644 --- a/tests/test-fddl.lisp +++ b/tests/test-fddl.lisp @@ -354,7 +354,7 @@ (progn (clsql:cache-table-queries "EMPLOYEE" :action :flush) (gethash "EMPLOYEE" (clsql-sys::attribute-cache clsql:*default-database*)))) - (NIL (T NIL) T (T NIL))) + (nil (t nil) t (t nil))) )) diff --git a/tests/test-init.lisp b/tests/test-init.lisp index e3a0a03..5fc308d 100644 --- a/tests/test-init.lisp +++ b/tests/test-init.lisp @@ -596,9 +596,13 @@ (clsql-sys:in test :fdml/query/8 :fdml/select/21 :fddl/table/6)) (push (cons test "syntax not supported") skip-tests)) - ((and (not (member *test-database-underlying-type* + ((and (eq *test-database-type* :odbc) + (eq *test-database-underlying-type* :postgresql) + (clsql-sys:in test :fddl/owner/1)) + (push (cons test "table ownership not supported by postgresql odbc driver") skip-tests)) + ((and (not (member *test-database-underlying-type* '(:postgresql :oracle))) - (clsql-sys:in test :fddl/owner/1)) + (clsql-sys:in test :fddl/owner/1)) (push (cons test "table ownership not supported") skip-tests)) (t (push test-form test-forms))))) -- 2.34.1