From 5e71132df0a1dced91b1bd169a2398e982db2c02 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 25 Jan 2016 23:40:09 +0000 Subject: [PATCH] Store int64 as strings There are no 64 bits integers in lua, so store them as strings --- src/lua/lua_sqlite3.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lua/lua_sqlite3.c b/src/lua/lua_sqlite3.c index 4442cacab..594fd6117 100644 --- a/src/lua/lua_sqlite3.c +++ b/src/lua/lua_sqlite3.c @@ -218,9 +218,11 @@ lua_sqlite3_sql (lua_State *L) static void lua_sqlite3_push_row (lua_State *L, sqlite3_stmt *stmt) { - gint nresults, i, type; const gchar *str; gsize slen; + gint64 num; + gchar numbuf[32]; + gint nresults, i, type; nresults = sqlite3_column_count (stmt); lua_createtable (L, 0, nresults); @@ -231,7 +233,12 @@ lua_sqlite3_push_row (lua_State *L, sqlite3_stmt *stmt) switch (type) { case SQLITE_INTEGER: - lua_pushnumber (L, sqlite3_column_int64 (stmt, i)); + /* XXX: we represent int64 as strings, as we can nothing else to do + * about it portably + */ + num = sqlite3_column_int64 (stmt, i); + rspamd_snprintf (numbuf, sizeof (numbuf), "%L", num); + lua_pushstring (L, numbuf); break; case SQLITE_FLOAT: lua_pushnumber (L, sqlite3_column_double (stmt, i)); -- 2.39.5