From 73d111a820dd164be7e78fe8c66c04acff263b79 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sat, 30 Sep 2006 15:19:56 +0000 Subject: [PATCH] Add some checks to detect if one table exists before creating or dropping it. Part of MDL-6614 --- lib/ddllib.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/ddllib.php b/lib/ddllib.php index 5ae8dedfcc..075a03683d 100644 --- a/lib/ddllib.php +++ b/lib/ddllib.php @@ -478,6 +478,12 @@ function create_table($table, $continue=true, $feedback=true) { return false; } +/// Check table doesn't exist + if (table_exists($table)) { + debugging('Table ' . $table->getName() . ' exists. Skipping its creation', DEBUG_DEVELOPER); + return true; //Table exists, nothing to do + } + if(!$sqlarr = $table->getCreateTableSQL($CFG->dbtype, $CFG->prefix, false)) { return true; //Empty array = nothing to do = no error } @@ -506,6 +512,12 @@ function drop_table($table, $continue=true, $feedback=true) { return false; } +/// Check table exists + if (!table_exists($table)) { + debugging('Table ' . $table->getName() . ' don not exist. Skipping its deletion', DEBUG_DEVELOPER); + return true; //Table don't exist, nothing to do + } + if(!$sqlarr = $table->getDropTableSQL($CFG->dbtype, $CFG->prefix, false)) { return true; //Empty array = nothing to do = no error } @@ -813,7 +825,7 @@ function drop_index($table, $index, $continue=true, $feedback=true) { /// Check index exists if (!index_exists($table, $index)) { - debugging('Index ' . $index->getName() . ' do not exists. Skipping its deletion', DEBUG_DEVELOPER); + debugging('Index ' . $index->getName() . ' do not exist. Skipping its deletion', DEBUG_DEVELOPER); return true; //Index doesn't exist, nothing to do } -- 2.39.5