X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=sql%2Ffddl.lisp;h=3b5b1bd195b6a7e66a5d0c6626e909452c6565f6;hp=c8d4d1f7b988556929cfd56e892ae86d3ce0e394;hb=ed3fc2379a78875cf80cdb4d000c0bfdf8806fe7;hpb=cb683851a0af33e88b7c4995435dc0cf226f6cba diff --git a/sql/fddl.lisp b/sql/fddl.lisp index c8d4d1f..3b5b1bd 100644 --- a/sql/fddl.lisp +++ b/sql/fddl.lisp @@ -79,7 +79,8 @@ supports transactions." (execute-command stmt :database database))) (defun drop-table (name &key (if-does-not-exist :error) - (database *default-database*)) + (database *default-database*) + (owner nil)) "Drops the table called NAME from DATABASE which defaults to *DEFAULT-DATABASE*. If the table does not exist and IF-DOES-NOT-EXIST is :ignore then DROP-TABLE returns nil whereas @@ -87,7 +88,8 @@ an error is signalled if IF-DOES-NOT-EXIST is :error." (let ((table-name (database-identifier name database))) (ecase if-does-not-exist (:ignore - (unless (table-exists-p table-name :database database) + (unless (table-exists-p table-name :database database + :owner owner) (return-from drop-table nil))) (:error t)) @@ -214,14 +216,14 @@ 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)) - (setq on nil)) - (execute-command (format nil "DROP INDEX ~A~A" index-name - (if (null on) "" - (concatenate 'string " ON " - (database-identifier on database)))) - :database database))) + (let* ((db-type (database-underlying-type database)) + (index-identifier (cond ((db-type-use-fully-qualified-column-on-drop-index? db-type) + (format nil "~A.~A" (database-identifier on database) index-name)) + ((db-type-use-column-on-drop-index? db-type) + (format nil "~A ON ~A" index-name (database-identifier on database))) + (t index-name)))) + (execute-command (format nil "DROP INDEX ~A" index-identifier) + :database database)))) (defun list-indexes (&key (owner nil) (database *default-database*) (on nil)) "Returns a list of strings representing index names in DATABASE