function Merge::execute
Same name in this branch
- main core/lib/Drupal/Core/Database/Query/Merge.php \Drupal\Core\Database\Query\Merge::execute()
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Database/Query/Merge.php \Drupal\Core\Database\Query\Merge::execute()
- 10 core/lib/Drupal/Core/Database/Query/Merge.php \Drupal\Core\Database\Query\Merge::execute()
- 9 core/lib/Drupal/Core/Database/Query/Merge.php \Drupal\Core\Database\Query\Merge::execute()
- 8.9.x core/lib/Drupal/Core/Database/Query/Merge.php \Drupal\Core\Database\Query\Merge::execute()
File
-
core/
modules/ pgsql/ src/ Driver/ Database/ pgsql/ Merge.php, line 39
Class
- Merge
- PostgreSQL implementation of \Drupal\Core\Database\Query\Merge.
Namespace
Drupal\pgsql\Driver\Database\pgsqlCode
public function execute() {
if (!count($this->condition)) {
throw new InvalidMergeQueryException('Invalid merge query: no conditions');
}
if (!$this->isNativeMerge()) {
return parent::execute();
}
// Fetch the list of blobs and sequences used on that table.
$table_information = $this->connection
->schema()
->queryTableInformation($this->table);
// Inserting values into serial fields requires synchronizing the
// sequence afterwards, which the generic insert path takes care of.
if (!empty($table_information->serial_fields) && array_intersect($table_information->serial_fields, array_keys($this->insertFields))) {
return parent::execute();
}
try {
return $this->executeNativeMerge($table_information);
} catch (IntegrityConstraintViolationException) {
// The merge query failed. Maybe it's because a racing insert query
// beat us in inserting the same row. Retry once: the racing row will
// now be matched and updated instead.
return $this->executeNativeMerge($table_information);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.