diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-27 16:57:50 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-27 16:57:50 +0100 |
commit | 7190316de556bff8a0cf0a905d43af5a748d65ba (patch) | |
tree | 5e4f3ab8a910e36e06611d3d854e531de41d163b /src/libutil/sqlite_utils.c | |
parent | a63fed5090e182256c2f8d14597c195b9f4f6a48 (diff) | |
download | rspamd-7190316de556bff8a0cf0a905d43af5a748d65ba.tar.gz rspamd-7190316de556bff8a0cf0a905d43af5a748d65ba.zip |
Allow blob manipulation in sqlite3 statements.
Diffstat (limited to 'src/libutil/sqlite_utils.c')
-rw-r--r-- | src/libutil/sqlite_utils.c | 10 |
1 files changed, 10 insertions, 0 deletions
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; } } |