diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php index e38196a..4611a94 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php @@ -107,7 +107,8 @@ public static function open(array &$connection_options = array()) { public function startTransaction($name = '') { // Pop off and/or commit any transactions that are on the stack before // attempting to create and return a new Transaction object. Menu router - // rebuild is the only case in core that creates a new transaction. + // rebuild is the only case in core that creates a new transaction + // explicitly. if (!empty($this->transactionLayers)) { foreach ($this->transactionLayers as $savepoint_name) { $this->popTransaction($savepoint_name); @@ -291,20 +292,35 @@ public function nextId($existing = 0) { } /** - * Add a new savepoint to mimic InnoDB. + * Add a new savepoint with an unique name. + * + * The main use for this method is to mimic InnoDB functionality, which + * provides an inherent savepoint before any query in a transaction. + * + * @param $savepoint_name + * A string representing the savepoint name. By default, "mimic_innodb" is + * used. + * + * @see Drupal\Core\Database\Connection::pushTransaction(). */ - public function addSavepoint() { + public function addSavepoint($savepoint_name = 'mimic_innodb') { if ($this->inTransaction()) { - $this->pushTransaction('mimic_innodb'); + $this->pushTransaction($savepoint_name); } } /** - * Release the mimic InnoDB savepoint. + * Release a savepoint by name. + * + * @param $savepoint_name + * A string representing the savepoint name. By default, "mimic_innodb" is + * used. + * + * @see Drupal\Core\Database\Connection::popTransaction(). */ - public function releaseSavepoint() { + public function releaseSavepoint($savepoint_name = 'mimic_innodb') { if ($this->inTransaction()) { - $this->popTransaction('mimic_innodb'); + $this->popTransaction($savepoint_name); } } }