From 5bfa219c5e3b387b9dd7c819441f0182ccb16dc8 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sun, 30 May 2004 08:01:53 +0000 Subject: [PATCH] r9522: * sql/odbc-api.lisp: Update to using ODBC V3 protocol --- ChangeLog | 1 + db-odbc/odbc-api.lisp | 17 ++++++++++------- db-odbc/odbc-constants.lisp | 10 ++++++++++ db-odbc/odbc-dbi.lisp | 6 +++--- db-odbc/odbc-sql.lisp | 3 +++ sql/generic-odbc.lisp | 1 + 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 711551d..6a7e1af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ * sql/generic-postgresql.lisp: Add support for prepared statements. * tests/test-internal.lisp: New file + * sql/odbc-api.lisp: Update to using ODBC V3 protocol 27 May 2004 Kevin Rosenberg * Version 2.11.3 diff --git a/db-odbc/odbc-api.lisp b/db-odbc/odbc-api.lisp index b17af02..492bf82 100644 --- a/db-odbc/odbc-api.lisp +++ b/db-odbc/odbc-api.lisp @@ -153,7 +153,7 @@ as possible second argument) to the desired representation of date/time/timestam () (SQLAllocEnv phenv) (deref-pointer phenv 'sql-handle))))) - (%set-attr-odbc-version henv $SQL_OV_ODBC2) + (%set-attr-odbc-version henv $SQL_OV_ODBC3) henv)) @@ -568,6 +568,9 @@ as possible second argument) to the desired representation of date/time/timestam (#.$SQL_DATE $SQL_C_DATE) (#.$SQL_TIME $SQL_C_TIME) (#.$SQL_TIMESTAMP $SQL_C_TIMESTAMP) + (#.$SQL_TYPE_DATE $SQL_C_TYPE_DATE) + (#.$SQL_TYPE_TIME $SQL_C_TYPE_TIME) + (#.$SQL_TYPE_TIMESTAMP $SQL_C_TYPE_TIMESTAMP) ((#.$SQL_BINARY #.$SQL_VARBINARY #.$SQL_LONGVARBINARY) $SQL_C_BINARY) (#.$SQL_TINYINT $SQL_C_STINYINT) (#.$SQL_BIT $SQL_C_BIT))) @@ -650,12 +653,12 @@ as possible second argument) to the desired representation of date/time/timestam (read-from-string (get-cast-foreign-string data-ptr)))) (t (case c-type - (#.$SQL_C_DATE + ((#.$SQL_C_DATE #.$SQL_C_TYPE_DATE) (funcall *time-conversion-function* (date-to-universal-time data-ptr))) - (#.$SQL_C_TIME + ((#.$SQL_C_TIME #.$SQL_C_TYPE_TIME) (multiple-value-bind (universal-time frac) (time-to-universal-time data-ptr) (funcall *time-conversion-function* universal-time frac))) - (#.$SQL_C_TIMESTAMP + ((#.$SQL_C_TIMESTAMP #.$SQL_C_TYPE_TIMESTAMP) (multiple-value-bind (universal-time frac) (timestamp-to-universal-time data-ptr) (funcall *time-conversion-function* universal-time frac))) (#.$SQL_INTEGER @@ -705,9 +708,9 @@ as possible second argument) to the desired representation of date/time/timestam (data-ptr (case c-type ;; add more? (#.$SQL_C_SLONG (uffi:allocate-foreign-object #.$ODBC-LONG-TYPE)) - (#.$SQL_C_DATE (allocate-foreign-object 'sql-c-date)) - (#.$SQL_C_TIME (allocate-foreign-object 'sql-c-time)) - (#.$SQL_C_TIMESTAMP (allocate-foreign-object 'sql-c-timestamp)) + ((#.$SQL_C_DATE #.$SQL_C_TYPE_DATE) (allocate-foreign-object 'sql-c-date)) + ((#.$SQL_C_TIME #.$SQL_C_TYPE_TIME) (allocate-foreign-object 'sql-c-time)) + ((#.$SQL_C_TIMESTAMP #.$SQL_C_TYPE_TIMESTAMP) (allocate-foreign-object 'sql-c-timestamp)) (#.$SQL_C_FLOAT (uffi:allocate-foreign-object :float)) (#.$SQL_C_DOUBLE (uffi:allocate-foreign-object :double)) (#.$SQL_C_BIT (uffi:allocate-foreign-object :byte)) diff --git a/db-odbc/odbc-constants.lisp b/db-odbc/odbc-constants.lisp index c16e2a7..591a3af 100644 --- a/db-odbc/odbc-constants.lisp +++ b/db-odbc/odbc-constants.lisp @@ -894,6 +894,11 @@ (defconstant $SQL_TINYINT -6) (defconstant $SQL_BIT -7) +;; For ODBC3 +(defconstant $SQL_TYPE_DATE 91) +(defconstant $SQL_TYPE_TIME 92) +(defconstant $SQL_TYPE_TIMESTAMP 93) + (defconstant $SQL_INTERVAL_YEAR -80) (defconstant $SQL_INTERVAL_MONTH -81) (defconstant $SQL_INTERVAL_YEAR_TO_MONTH -82) @@ -930,6 +935,11 @@ (defconstant $SQL_C_UTINYINT (+ $SQL_TINYINT $SQL_UNSIGNED_OFFSET)) ;;UNSIGNED TINYINT (defconstant $SQL_C_BOOKMARK $SQL_C_ULONG) ;; BOOKMARK +;;; ODBC3 +(defconstant $SQL_C_TYPE_DATE $SQL_TYPE_DATE) +(defconstant $SQL_C_TYPE_TIME $SQL_TYPE_TIME) +(defconstant $SQL_C_TYPE_TIMESTAMP $SQL_TYPE_TIMESTAMP) + ;; Options for SQLDriverConnect (defconstant $SQL_DRIVER_NOPROMPT 0) (defconstant $SQL_DRIVER_COMPLETE 1) diff --git a/db-odbc/odbc-dbi.lisp b/db-odbc/odbc-dbi.lisp index 634a43e..fc8f300 100644 --- a/db-odbc/odbc-dbi.lisp +++ b/db-odbc/odbc-dbi.lisp @@ -559,9 +559,9 @@ This makes the functions db-execute-command and db-query thread safe." (#.odbc::$SQL_SMALLINT :short) ((#.odbc::$SQL_FLOAT #.odbc::$SQL_DOUBLE) #.odbc::$ODBC-LONG-TYPE) (#.odbc::$SQL_REAL #.odbc::$ODBC-LONG-TYPE) - (#.odbc::$SQL_DATE 'sql-c-date) - (#.odbc::$SQL_TIME 'sql-c-time) - (#.odbc::$SQL_TIMESTAMP 'sql-c-timestamp) + ((#.odbc::$SQL_DATE #.odbc::$SQL_TYPE_DATE) 'sql-c-date) + ((#.odbc::$SQL_TIME #.odbc::$SQL_TYPE_TIME) 'sql-c-time) + ((#.odbc::$SQL_TIMESTAMP #.odbc::$SQL_TYPE_TIMESTAMP) 'sql-c-timestamp) ;;((#.odbc::$SQL_BINARY #.odbc::$SQL_VARBINARY #.odbc::$SQL_LONGVARBINARY) odbc::$SQL_C_BINARY) ; ?? (#.odbc::$SQL_TINYINT :short) ;;(#.odbc::$SQL_BIT odbc::$SQL_C_BIT) ; ?? diff --git a/db-odbc/odbc-sql.lisp b/db-odbc/odbc-sql.lisp index e1ad0c2..9f88a9c 100644 --- a/db-odbc/odbc-sql.lisp +++ b/db-odbc/odbc-sql.lisp @@ -48,6 +48,9 @@ :password password :data-source-name dsn)))) (store-type-of-connected-database db) + ;; Ensure this database type is initialized so can check capabilities of + ;; underlying database + (initialize-database-type :database-type db-type) db) (error () ;; Init or Connect failed (error 'sql-connection-error diff --git a/sql/generic-odbc.lisp b/sql/generic-odbc.lisp index d222550..06338ae 100644 --- a/sql/generic-odbc.lisp +++ b/sql/generic-odbc.lisp @@ -67,6 +67,7 @@ query-expression :db (odbc-conn database) :result-types result-types :column-names field-names) + #+ignore (error () (error 'sql-database-data-error :database database -- 2.34.1