summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2017-11-15 15:34:11 (GMT)
committerNathaniel Catchpole2017-11-15 15:34:11 (GMT)
commitf73e805702e947bda2e3a71b2f78518096c05154 (patch)
tree132e44f94ab144b15897d23466b2d4c7c210c521
parent2d859f2c01294717ab9c9774741109bfd15ab202 (diff)
Issue #2850684 by daffie, RoSk0: Default Database Schema::fieldExists() is slow for PostgreSQL
-rw-r--r--core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
index 9e5e1d9..26f4e3e 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
@@ -631,6 +631,15 @@ EOD;
/**
* {@inheritdoc}
*/
+ public function fieldExists($table, $column) {
+ $prefixInfo = $this->getPrefixInfo($table);
+
+ return (bool) $this->connection->query("SELECT 1 FROM pg_attribute WHERE attrelid = :key::regclass AND attname = :column AND NOT attisdropped AND attnum > 0", array(':key' => $prefixInfo['schema'] . '.' . $prefixInfo['table'], ':column' => $column))->fetchField();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function indexExists($table, $name) {
// Details http://www.postgresql.org/docs/9.1/interactive/view-pg-indexes.html
$index_name = $this->ensureIdentifiersLength($table, $name, 'idx');