[geary/wip/misc-cleanup: 4/4] Add Db.Statement.get_expanded_sql
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/misc-cleanup: 4/4] Add Db.Statement.get_expanded_sql
- Date: Tue, 6 Aug 2019 11:43:00 +0000 (UTC)
commit 230127237aabe8cea2a9f4e9c9797426f6b63e6f
Author: Michael Gratton <mike vee net>
Date: Tue Aug 6 21:39:18 2019 +1000
Add Db.Statement.get_expanded_sql
Useful for debugging.
src/engine/db/db-statement.vala | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/src/engine/db/db-statement.vala b/src/engine/db/db-statement.vala
index 8c0fe8b5..b351e277 100644
--- a/src/engine/db/db-statement.vala
+++ b/src/engine/db/db-statement.vala
@@ -4,6 +4,9 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
+private extern string? sqlite3_expanded_sql(Sqlite.Statement stmt);
+
+
public class Geary.Db.Statement : Geary.Db.Context {
public string sql {
@@ -38,6 +41,15 @@ public class Geary.Db.Statement : Geary.Db.Context {
throw_on_error("Statement.ctor", connection.db.prepare_v2(sql, -1, out stmt, null), sql);
}
+ /** Returns SQL for the statement with bound parameters expanded. */
+ public string? get_expanded_sql() {
+ // Replace all this with `Sqlite.Statement.expanded_sql` is
+ // readily available. See:
+ // https://gitlab.gnome.org/GNOME/vala/merge_requests/74
+ string* sqlite = sqlite3_expanded_sql(this.stmt);
+ string? sql = sqlite;
+ Sqlite.Memory.free((void*) sqlite);
+ return sql;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]