[geary/mjog/921-db-locked: 5/7] Geary.Db.DatabaseConnection: Add SQL debug logging when txns fail
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/921-db-locked: 5/7] Geary.Db.DatabaseConnection: Add SQL debug logging when txns fail
- Date: Sat, 5 Sep 2020 04:26:16 +0000 (UTC)
commit dcad419b0394250eb5769498da2b8e13c8167123
Author: Michael Gratton <mike vee net>
Date: Fri Sep 4 00:39:30 2020 +1000
Geary.Db.DatabaseConnection: Add SQL debug logging when txns fail
This isn't a good place to do it, but neither GLib's error model not the
engine's database model makes it possible to getting access to
transaction state otherwise at the moment.
src/engine/db/db-database-connection.vala | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/src/engine/db/db-database-connection.vala b/src/engine/db/db-database-connection.vala
index a4114ad96..4e7ceb788 100644
--- a/src/engine/db/db-database-connection.vala
+++ b/src/engine/db/db-database-connection.vala
@@ -191,8 +191,16 @@ public class Geary.Db.DatabaseConnection : Context, Connection {
// perform the transaction
outcome = cb(txn_cx, cancellable);
} catch (GLib.Error err) {
- if (!(err is GLib.IOError.CANCELLED))
+ if (!(err is GLib.IOError.CANCELLED)) {
debug("Connection.exec_transaction: transaction threw error: %s", err.message);
+ // XXX txn logs really should be passed up with the
+ // error, or made available after the transaction, but
+ // neither GLib's error model nor Db's model allows
+ // that
+ foreach (var statement in txn_cx.transaction_log) {
+ debug(" - %s", statement);
+ }
+ }
caught_err = err;
}
@@ -205,6 +213,15 @@ public class Geary.Db.DatabaseConnection : Context, Connection {
} catch (GLib.Error err) {
debug("Connection.exec_transaction: Unable to %s transaction: %s", outcome.to_string(),
err.message);
+ if (caught_err == null) {
+ // XXX as per above, txn logs really should be passed up
+ // with the error, or made available after the
+ // transaction, but neither GLib's error model nor Db's
+ // model allows that
+ foreach (var statement in txn_cx.transaction_log) {
+ debug(" - %s", statement);
+ }
+ }
}
if (caught_err != null) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]