+19 Apr 2004 Kevin Rosenberg (kevin@rosenberg.net)
+ * Version 2.8.1
+ * db-odbc/odbc-sql.lisp: Add DATABASE-LIST function
+ * db-odbc/odbc-dbi.lisp: Add LIST-ALL-DATA-SOURCES function
+
19 Apr 2004 Kevin Rosenberg (kevin@rosenberg.net)
* Version 2.8.0: New API function: LIST-DATABASES
* base/utils.lisp: Fix command-output on CMUCL/SBCL
(defun %list-tables (hstmt)
(with-error-handling (:hstmt hstmt)
(SQLTables hstmt +null-ptr+ 0 +null-ptr+ 0 +null-ptr+ 0 +null-ptr+ 0)))
+
+(defun %list-data-sources (henv)
+ (let ((dsn (allocate-foreign-string (1+ $SQL_MAX_DSN_LENGTH)))
+ (desc (allocate-foreign-string 256))
+ (results nil))
+ (unwind-protect
+ (with-foreign-objects ((dsn-len :short)
+ (desc-len :short))
+ (with-error-handling (:henv henv)
+ (let ((res
+ (SQLDataSources henv $SQL_FETCH_FIRST dsn
+ (1+ $SQL_MAX_DSN_LENGTH)
+ dsn-len desc 256 desc-len)))
+ (when (or (eql res $SQL_SUCCESS)
+ (eql res $SQL_SUCCESS_WITH_INFO))
+ (push (convert-from-foreign-string dsn) results))
+
+ (do ((res (SQLDataSources henv $SQL_FETCH_NEXT dsn
+ (1+ $SQL_MAX_DSN_LENGTH)
+ dsn-len desc 256 desc-len)
+ (SQLDataSources henv $SQL_FETCH_NEXT dsn
+ (1+ $SQL_MAX_DSN_LENGTH)
+ dsn-len desc 256 desc-len)))
+ ((not (or (eql res $SQL_SUCCESS)
+ (eql res $SQL_SUCCESS_WITH_INFO))))
+ (push (convert-from-foreign-string dsn) results)))))
+ (progn
+ (free-foreign-object dsn)
+ (free-foreign-object desc)))
+ (nreverse results)))
+
#:disconnect
#:end-transaction
#:fetch-row
+ #:list-all-data-sources
#:list-all-database-tables
#:list-all-table-columns
#:loop-over-results
(declare (ignore hstmt))
(db-describe-columns db "" "" table ""))
+(defun list-all-data-sources ()
+ (let ((db (make-instance 'odbc-db)))
+ (unless (henv db) ;; has class allocation!
+ (setf (henv db) (%new-environment-handle)))
+ (%list-data-sources (henv db))))
+
(defun rr-sql (hstmt sql-statement &key db)
(declare (ignore hstmt sql-statement db))
(warn "rr-sql not implemented."))
(fDirection :short)
(*szDSN string-ptr) ; UCHAR FAR *szDSN
(cbDSNMax :short) ; SWORD cbDSNMax
- (*pcbDSN :pointer-void) ; SWORD *pcbDSN
+ (*pcbDSN (* :short)) ; SWORD *pcbDSN
(*szDescription string-ptr) ; UCHAR *szDescription
(cbDescriptionMax :short) ; SWORD cbDescriptionMax
- (*pcbDescription :pointer-void) ; SWORD *pcbDescription
+ (*pcbDescription (* :short)) ; SWORD *pcbDescription
)
:module "odbc"
:returning :short) ; RETCODE_SQL_API
#:result-rows-count
#:sql-to-c-type
#:%list-tables
+ #:%list-data-sources
)
(:documentation "This is the low-level interface ODBC."))
(warn "Not implemented."))
(defmethod database-probe (connection-spec (type (eql :odbc)))
- (warn "Not implemented."))
+ (when (find (car connection-spec) (database-list connection-spec type)
+ :test #'string-equal)
+ t))
+
+(defmethod database-list (connection-spec (type (eql :odbc)))
+ (declare (ignore connection-spec))
+ (odbc-dbi:list-all-data-sources))
#+ignore
(when (clsql-base-sys:database-type-library-loaded :odbc)
+cl-sql (2.8.1-1) unstable; urgency=low
+
+ * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org> Mon, 19 Apr 2004 03:01:34 -0600
+
cl-sql (2.8.0-1) unstable; urgency=low
* New upstream