? .buildpath
? .project
? .settings
? 360854_200903051131-0500.patch
? 360854_200904041839+1100.patch
? 365996_200901291748+1100.patch
Index: includes/database/database.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/database.inc,v
retrieving revision 1.51
diff -u -r1.51 database.inc
--- includes/database/database.inc	29 Mar 2009 12:48:33 -0000	1.51
+++ includes/database/database.inc	4 Apr 2009 07:39:35 -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.12
diff -u -r1.12 schema.inc
--- includes/database/schema.inc	14 Mar 2009 20:34:17 -0000	1.12
+++ includes/database/schema.inc	4 Apr 2009 07:39:35 -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.13
diff -u -r1.13 schema.inc
--- includes/database/mysql/schema.inc	1 Apr 2009 20:00:46 -0000	1.13
+++ includes/database/mysql/schema.inc	4 Apr 2009 07:39:36 -0000
@@ -313,6 +313,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_query("SHOW INDEX FROM {$table} WHERE key_name = '$name'")->fetchField();
+  }
+  
   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.11
diff -u -r1.11 schema.inc
--- includes/database/pgsql/schema.inc	31 Mar 2009 01:42:45 -0000	1.11
+++ includes/database/pgsql/schema.inc	4 Apr 2009 07:39:36 -0000
@@ -392,6 +392,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_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '$name'")->fetchField();
+  }
+  
+  /**
    * 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	4 Apr 2009 07:39:37 -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_query("PRAGMA index_info($name)")->fetchField() != '');
+  }
+  
+  /**
    * Add an index.
    *
    * @param $ret
