From: Kevin M. Rosenberg Date: Thu, 22 Apr 2004 02:51:18 +0000 (+0000) Subject: r9125: work around myodbc bug X-Git-Tag: v3.8.6~592 X-Git-Url: http://git.kpe.io/?p=clsql.git;a=commitdiff_plain;h=db5e98459718c42c3ba6aba2b45b61c26837c991 r9125: work around myodbc bug --- diff --git a/db-odbc/odbc-api.lisp b/db-odbc/odbc-api.lisp index b9223d6..166285d 100644 --- a/db-odbc/odbc-api.lisp +++ b/db-odbc/odbc-api.lisp @@ -952,7 +952,7 @@ as possible second argument) to the desired representation of date/time/timestam hstmt +null-ptr+ 0 +null-ptr+ 0 - table-cs (length table) ;;$SQL_NTS + table-cs $SQL_NTS (if unique $SQL_INDEX_UNIQUE $SQL_INDEX_ALL) (if ensure $SQL_ENSURE $SQL_QUICK))))) diff --git a/db-odbc/odbc-sql.lisp b/db-odbc/odbc-sql.lisp index 825b743..d4e4b80 100644 --- a/db-odbc/odbc-sql.lisp +++ b/db-odbc/odbc-sql.lisp @@ -318,6 +318,23 @@ (defmethod database-list-table-indexes (table (database odbc-database) &key (owner nil)) (declare (ignore owner)) + (if (eq :mysql (database-odbc-db-type database)) + (mysql-workaround-bug-list-table-indexes table database) + (odbc-list-table-indexes table database))) + +(defun mysql-workaround-bug-list-table-indexes (table database) + ;; MyODBC 3.52 does not properly return results from SQLStatistics + (do ((results nil) + (rows (database-query + (format nil "SHOW INDEX FROM ~A" (string-upcase table)) + database nil) + (cdr rows))) + ((null rows) (nreverse results)) + (let ((col (nth 2 (car rows)))) + (unless (find col results :test #'string-equal) + (push col results))))) + +(defun odbc-list-table-indexes (table database) (multiple-value-bind (rows col-names) (odbc-dbi:list-table-indexes (string-downcase table) diff --git a/debian/control b/debian/control index a51a752..b4e12fe 100644 --- a/debian/control +++ b/debian/control @@ -44,7 +44,7 @@ Description: CLSQL database backend, MySQL Package: cl-sql-aodbc Architecture: all -Depends: cl-sql-base (>= ${Source-Version}) +Depends: cl-sql-base (>= ${Source-Version}), cl-sql-mysql, cl-sql-postgresql Provides: cl-sql-backend Suggests: acl-pro-installer Description: CLSQL database backend, AODBC @@ -54,7 +54,7 @@ Description: CLSQL database backend, AODBC Package: cl-sql-odbc Architecture: all -Depends: cl-sql-base (>= ${Source-Version}),unixodbc-dev +Depends: cl-sql-base (>= ${Source-Version}), unixodbc-dev, cl-sql-mysql, cl-sql-postgresql Provides: cl-sql-backend Suggests: acl-pro-installer Description: CLSQL database backend, ODBC diff --git a/sql/table.lisp b/sql/table.lisp index d51960e..b9a5ef1 100644 --- a/sql/table.lisp +++ b/sql/table.lisp @@ -174,7 +174,8 @@ specification of a table to drop the index from." (unless (index-exists-p index-name :database database) (return-from drop-index))) (:error t)) - (unless (db-type-use-column-on-drop-index? (database-underlying-type database)) + (unless (db-type-use-column-on-drop-index? + (database-underlying-type database)) (setq on nil)) (execute-command (format nil "DROP INDEX ~A~A" index-name (if (null on) ""