X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-odbc%2Fodbc-sql.lisp;h=2fad84805755c8c3b029d553b899f8d677812978;hb=db9892632e6eb7869aea7a94c16b523a82de1501;hp=1d392729efc490c2c5f7482a60de765cc5c8e87b;hpb=d0f147d0e7d942b379bd7cd472f26b00c33916bc;p=clsql.git diff --git a/db-odbc/odbc-sql.lisp b/db-odbc/odbc-sql.lisp index 1d39272..2fad848 100644 --- a/db-odbc/odbc-sql.lisp +++ b/db-odbc/odbc-sql.lisp @@ -52,6 +52,7 @@ db) (clsql-error (e) (error e)) + #+ignore (error () ;; Init or Connect failed (error 'clsql-connect-error :database-type database-type @@ -103,6 +104,7 @@ (odbc-dbi:sql sql-expression :db (database-odbc-conn database)) (clsql-error (e) (error e)) + #+ignore (error () (error 'clsql-sql-error :database database @@ -132,6 +134,7 @@ (length column-names) nil ;; not able to return number of rows with odbc )) + #+ignore (error () (error 'clsql-sql-error :database database @@ -195,11 +198,14 @@ &key (owner nil)) (declare (ignore owner)) (multiple-value-bind (rows col-names) - (odbc-dbi:list-all-database-tables :db (database-odbc-conn database)) - (let ((pos (position "TABLE_NAME" col-names :test #'string-equal))) - (when pos - (loop for row in rows - collect (nth pos row)))))) + (odbc-dbi:list-all-database-tables :db (database-odbc-conn database)) + (declare (ignore col-names)) + ;; TABLE_SCHEM is hard-coded in second column by ODBC Driver Manager + ;; TABLE_NAME in third column, TABLE_TYPE in fourth column + (loop for row in rows + when (and (not (string-equal "information_schema" (nth 1 row))) + (string-equal "TABLE" (nth 3 row))) + collect (nth 2 row)))) (defmethod database-list-attributes ((table string) (database odbc-database) &key (owner nil)) @@ -268,8 +274,29 @@ (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)) + +(defmethod database-list-indexes ((database odbc-database) + &key (owner nil)) + (let ((result '())) + (dolist (table (database-list-tables database :owner owner) result) + (append (database-list-table-indexes table database :owner owner) + result)))) + +(defmethod database-list-table-indexes (table (database odbc-database) + &key (owner nil)) + (multiple-value-bind (rows col-names) + (odbc-dbi:list-table-indexes table :db (database-odbc-conn database)) + (declare (ignore col-names)) + ;; INDEX_NAME is hard-coded in sixth position by ODBC driver + (loop for row in rows collect (nth 5 row)))) -#+ignore +#+ignore (when (clsql-base-sys:database-type-library-loaded :odbc) (clsql-base-sys:initialize-database-type :database-type :odbc))