MDL-20625 new delegated transaction support in DML

This commit is contained in:
Petr Skoda
2009-11-07 08:52:56 +00:00
parent 88d39d6992
commit d5a8d9aa71
25 changed files with 797 additions and 449 deletions
+12 -21
View File
@@ -1122,54 +1122,45 @@ class pgsql_native_moodle_database extends moodle_database {
/// transactions
/**
* on DBs that support it, switch to transaction mode and begin a transaction
* you'll need to ensure you call commit_sql() or your changes *will* be lost.
*
* this is _very_ useful for massive updates
* Driver specific start of real database transaction,
* this can not be used directly in code.
* @return void
*/
public function begin_sql() {
if (!parent::begin_sql()) {
return false;
}
protected function begin_transaction() {
$sql = "BEGIN ISOLATION LEVEL READ COMMITTED";
$this->query_start($sql, NULL, SQL_QUERY_AUX);
$result = pg_query($this->pgsql, $sql);
$this->query_end($result);
pg_free_result($result);
return true;
}
/**
* on DBs that support it, commit the transaction
* Driver specific commit of real database transaction,
* this can not be used directly in code.
* @return void
*/
public function commit_sql() {
if (!parent::commit_sql()) {
return false;
}
protected function commit_transaction() {
$sql = "COMMIT";
$this->query_start($sql, NULL, SQL_QUERY_AUX);
$result = pg_query($this->pgsql, $sql);
$this->query_end($result);
pg_free_result($result);
return true;
}
/**
* on DBs that support it, rollback the transaction
* Driver specific abort of real database transaction,
* this can not be used directly in code.
* @return void
*/
public function rollback_sql() {
if (!parent::rollback_sql()) {
return false;
}
protected function rollback_transaction() {
$sql = "ROLLBACK";
$this->query_start($sql, NULL, SQL_QUERY_AUX);
$result = pg_query($this->pgsql, $sql);
$this->query_end($result);
pg_free_result($result);
return true;
}
/**