? .buildpath
? .project
? .settings
? 360854_200903051131-0500.patch
? 365996_200901291748+1100.patch
Index: includes/database/database.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/database.inc,v
retrieving revision 1.50
diff -u -r1.50 database.inc
--- includes/database/database.inc	25 Jan 2009 12:19:31 -0000	1.50
+++ includes/database/database.inc	5 Mar 2009 16:37:03 -0000
@@ -2063,6 +2063,18 @@
 }
 
 /**
+ * Check if an index exists.
+ *
+ * @param $name
+ *   Index name.
+ * @return
+ *   TRUE if the given index exists, otherwise FALSE.
+ */
+function db_index_exists($name) {
+  return Database::getConnection()->schema()->indexExists($name);
+}
+
+/**
  * Check if a table exists.
  */
 function db_table_exists($table) {
Index: includes/database/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/schema.inc,v
retrieving revision 1.11
diff -u -r1.11 schema.inc
--- includes/database/schema.inc	24 Feb 2009 16:34:46 -0000	1.11
+++ includes/database/schema.inc	5 Mar 2009 16:37:03 -0000
@@ -313,7 +313,19 @@
    *   The field to be altered.
    */
   abstract public function fieldSetNoDefault(&$ret, $table, $field);
-
+  
+  /**
+   * Checks if an index exists.
+   * 
+   * @param $table
+   *   Name of the table.
+   * @param $name
+   *   Name of the index.
+   * @return
+   *   Index name if the table exists. Otherwise FALSE.
+   */
+  abstract public function indexExists($table, $name);
+  
   /**
    * Add a primary key.
    *
Index: includes/database/mysql/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/mysql/schema.inc,v
retrieving revision 1.11
diff -u -r1.11 schema.inc
--- includes/database/mysql/schema.inc	26 Jan 2009 14:08:41 -0000	1.11
+++ includes/database/mysql/schema.inc	5 Mar 2009 16:37:03 -0000
@@ -292,6 +292,20 @@
     $ret[] = update_sql('ALTER TABLE {' . $table . '} ALTER COLUMN ' . $field . ' DROP DEFAULT');
   }
 
+  /**
+   * Checks if an index exists.
+   * 
+   * @param $table
+   *   Name of the table.
+   * @param $name
+   *   Name of the index.
+   * @return
+   *   TRUE if the table exists. Otherwise FALSE.
+   */
+  public function indexExists($table, $name) {
+    return db_result(db_query("SHOW INDEX FROM {$table} WHERE key_name = '$name'"));
+  }
+  
   public function addPrimaryKey(&$ret, $table, $fields) {
     $ret[] = update_sql('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')');
   }
Index: includes/database/pgsql/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/pgsql/schema.inc,v
retrieving revision 1.8
diff -u -r1.8 schema.inc
--- includes/database/pgsql/schema.inc	24 Feb 2009 16:34:46 -0000	1.8
+++ includes/database/pgsql/schema.inc	5 Mar 2009 16:37:03 -0000
@@ -376,6 +376,20 @@
   }
 
   /**
+   * Checks if an index exists.
+   * 
+   * @param $table
+   *   Name of the table.
+   * @param $name
+   *   Name of the index.
+   * @return
+   *   TRUE if the table exists. Otherwise FALSE.
+   */
+  public function indexExists($table, $name) {
+    return db_result(db_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '$name'"));
+  }
+  
+  /**
    * Add a primary key.
    *
    * @param $ret
Index: includes/database/sqlite/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/sqlite/schema.inc,v
retrieving revision 1.2
diff -u -r1.2 schema.inc
--- includes/database/sqlite/schema.inc	23 Nov 2008 21:01:03 -0000	1.2
+++ includes/database/sqlite/schema.inc	5 Mar 2009 16:37:03 -0000
@@ -414,6 +414,20 @@
   }
 
   /**
+   * Checks if an index exists.
+   * 
+   * @param $table
+   *   Name of the table.
+   * @param $name
+   *   Name of the index.
+   * @return
+   *   Index name if the table exists. Otherwise FALSE.
+   */
+  public function indexExists($table, $name) {
+    return (db_result(db_query("PRAGMA index_info($name)")) != '');
+  }
+  
+  /**
    * Add an index.
    *
    * @param $ret
