From 7190316de556bff8a0cf0a905d43af5a748d65ba Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 27 Jul 2015 16:57:50 +0100 Subject: Allow blob manipulation in sqlite3 statements. --- src/libutil/sqlite_utils.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libutil/sqlite_utils.c') diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c index dddb08703..bf4e5073d 100644 --- a/src/libutil/sqlite_utils.c +++ b/src/libutil/sqlite_utils.c @@ -74,6 +74,7 @@ rspamd_sqlite3_run_prstmt (sqlite3 *db, GArray *stmts, sqlite3_stmt *stmt; gint i, rowid, nargs, j; gint64 len; + gpointer p; struct rspamd_sqlite3_prstmt *nst; const char *argtypes; @@ -105,6 +106,7 @@ rspamd_sqlite3_run_prstmt (sqlite3 *db, GArray *stmts, nargs = 1; break; case 'V': + case 'B': for (j = 0; j < nargs; j ++, rowid ++) { len = va_arg (ap, gint64); @@ -156,6 +158,14 @@ rspamd_sqlite3_run_prstmt (sqlite3 *db, GArray *stmts, case 'L': *va_arg (ap, gint64*) = sqlite3_last_insert_rowid (db); break; + case 'B': + len = sqlite3_column_bytes (stmt, i); + g_assert (len >= 0); + p = g_malloc (len); + memcpy (p, sqlite3_column_blob (stmt, i), len); + *va_arg (ap, gint64*) = len; + *va_arg (ap, gpointer*) = p; + break; } } -- cgit v1.2.3