[core] trace savepoints

This commit is contained in:
Shish 2024-01-09 22:47:22 +00:00
parent 7e7e9ec049
commit 432be420fd

View file

@ -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;
} }
} }