r9125: work around myodbc bug
authorKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 22 Apr 2004 02:51:18 +0000 (02:51 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 22 Apr 2004 02:51:18 +0000 (02:51 +0000)
db-odbc/odbc-api.lisp
db-odbc/odbc-sql.lisp
debian/control
sql/table.lisp

index b9223d68fb7d44cdb35e3c6380f5e3abeaf17c05..166285d05568587db78ddc9e271d37acecda067c 100644 (file)
@@ -952,7 +952,7 @@ as possible second argument) to the desired representation of date/time/timestam
        hstmt
        +null-ptr+ 0
        +null-ptr+ 0
        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)))))
 
        (if unique $SQL_INDEX_UNIQUE $SQL_INDEX_ALL)
        (if ensure $SQL_ENSURE $SQL_QUICK)))))
 
index 825b7430aec134225b28acd4244c8f59c78f6f91..d4e4b80cc865b2f438212b11f1165868a4c7ee60 100644 (file)
 (defmethod database-list-table-indexes (table (database odbc-database)
                                        &key (owner nil))
   (declare (ignore owner))
 (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)
   (multiple-value-bind (rows col-names)
       (odbc-dbi:list-table-indexes 
        (string-downcase table)
index a51a7524be6c81cdd3c2d5ac945bd5fc4052dde4..b4e12fe05d949986bab9d3b8a7f75af451914982 100644 (file)
@@ -44,7 +44,7 @@ Description: CLSQL database backend, MySQL
 
 Package: cl-sql-aodbc
 Architecture: all
 
 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
 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
 
 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
 Provides: cl-sql-backend
 Suggests: acl-pro-installer
 Description: CLSQL database backend, ODBC
index d51960e3e06f617536bd167693d4ea9b3c5e4707..b9a5ef1bd1534d9215e441123549c63d9d299ef0 100644 (file)
@@ -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 (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) ""
       (setq on nil))
     (execute-command (format nil "DROP INDEX ~A~A" index-name
                              (if (null on) ""