[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
|
public function with_savepoint(callable $callback, string $name = "sp"): mixed
|
||||||
{
|
{
|
||||||
|
global $_tracer;
|
||||||
try {
|
try {
|
||||||
|
$_tracer->begin("Savepoint $name");
|
||||||
$this->execute("SAVEPOINT $name");
|
$this->execute("SAVEPOINT $name");
|
||||||
$ret = $callback();
|
$ret = $callback();
|
||||||
$this->execute("RELEASE SAVEPOINT $name");
|
$this->execute("RELEASE SAVEPOINT $name");
|
||||||
|
$_tracer->end();
|
||||||
return $ret;
|
return $ret;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->execute("ROLLBACK TO SAVEPOINT $name");
|
$this->execute("ROLLBACK TO SAVEPOINT $name");
|
||||||
|
$_tracer->end();
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue