function Schema::introspectIndexSchema
Same name in this branch
- 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php \Drupal\Core\Database\Driver\sqlite\Schema::introspectIndexSchema()
- 8.9.x core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema::introspectIndexSchema()
- 8.9.x core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::introspectIndexSchema()
Same name in other branches
- 9 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::introspectIndexSchema()
- 9 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::introspectIndexSchema()
- 9 core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::introspectIndexSchema()
- 9 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::introspectIndexSchema()
- 10 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::introspectIndexSchema()
- 10 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::introspectIndexSchema()
- 10 core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::introspectIndexSchema()
- 10 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::introspectIndexSchema()
- 11.x core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::introspectIndexSchema()
- 11.x core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::introspectIndexSchema()
- 11.x core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::introspectIndexSchema()
- 11.x core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::introspectIndexSchema()
Overrides Schema::introspectIndexSchema
File
-
core/
lib/ Drupal/ Core/ Database/ Driver/ pgsql/ Schema.php, line 890
Class
- Schema
- PostgreSQL implementation of \Drupal\Core\Database\Schema.
Namespace
Drupal\Core\Database\Driver\pgsqlCode
protected function introspectIndexSchema($table) {
if (!$this->tableExists($table)) {
throw new SchemaObjectDoesNotExistException("The table {$table} doesn't exist.");
}
$index_schema = [
'primary key' => [],
'unique keys' => [],
'indexes' => [],
];
$result = $this->connection
->query("SELECT i.relname AS index_name, a.attname AS column_name FROM pg_class t, pg_class i, pg_index ix, pg_attribute a WHERE t.oid = ix.indrelid AND i.oid = ix.indexrelid AND a.attrelid = t.oid AND a.attnum = ANY(ix.indkey) AND t.relkind = 'r' AND t.relname = :table_name ORDER BY index_name ASC, column_name ASC", [
':table_name' => $this->connection
->prefixTables('{' . $table . '}'),
])
->fetchAll();
foreach ($result as $row) {
if (preg_match('/_pkey$/', $row->index_name)) {
$index_schema['primary key'][] = $row->column_name;
}
elseif (preg_match('/_key$/', $row->index_name)) {
$index_schema['unique keys'][$row->index_name][] = $row->column_name;
}
elseif (preg_match('/_idx$/', $row->index_name)) {
$index_schema['indexes'][$row->index_name][] = $row->column_name;
}
}
return $index_schema;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.