function chado_index_exists

2.x tripal_core.chado_schema.api.inc chado_index_exists($table, $name)
3.x tripal_chado.schema.api.inc chado_index_exists($table, $name)

A Chado-aware replacement for the db_index_exists() function.

Parameters

$table: The table to be altered.

$name: The name of the index.

1 call to chado_index_exists()
tripal_phylogeny_install in legacy/tripal_phylogeny/tripal_phylogeny.install
Implements hook_install().

File

tripal_chado/api/tripal_chado.schema.api.inc, line 200
Provides an application programming interface (API) for describing Chado tables.

Code

function chado_index_exists($table, $name) {
  global $databases;

  $indexname = $table . '_' . $name . '_idx';

  $default_db = $databases['default']['default']['database'];

  $sql = "
    SELECT 1 as exists
    FROM pg_indexes
    WHERE indexname = :indexname
  ";

  $result = db_query($sql, array(':indexname' => $indexname));
  $exists = $result->fetchObject();
  return $exists->exists;
}