[core] trace savepoints
This commit is contained in:
parent
7e7e9ec049
commit
432be420fd
1 changed files with 4 additions and 0 deletions
|
@ -124,13 +124,17 @@ class Database
|
|||
|
||||
public function with_savepoint(callable $callback, string $name = "sp"): mixed
|
||||
{
|
||||
global $_tracer;
|
||||
try {
|
||||
$_tracer->begin("Savepoint $name");
|
||||
$this->execute("SAVEPOINT $name");
|
||||
$ret = $callback();
|
||||
$this->execute("RELEASE SAVEPOINT $name");
|
||||
$_tracer->end();
|
||||
return $ret;
|
||||
} catch (\Exception $e) {
|
||||
$this->execute("ROLLBACK TO SAVEPOINT $name");
|
||||
$_tracer->end();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue