diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-02 14:13:26 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-02 14:13:26 +0100 |
commit | 06edc0f42e6d3b92d06b04a96848152bc680c3ba (patch) | |
tree | 5d5228213de80d80e83675ec15150f358ce4ab5a /lib/Plugins/SQLite3.cpp | |
parent | c52972c8a37e125b8f6ba7470ae1d1fab3896c2b (diff) | |
download | abrt-06edc0f42e6d3b92d06b04a96848152bc680c3ba.tar.gz abrt-06edc0f42e6d3b92d06b04a96848152bc680c3ba.tar.xz abrt-06edc0f42e6d3b92d06b04a96848152bc680c3ba.zip |
save reporters' results to abrt_vNN_reportresult table too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Plugins/SQLite3.cpp')
-rw-r--r-- | lib/Plugins/SQLite3.cpp | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index b2be21a9..5819b98c 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -147,7 +147,7 @@ static void get_table(vector_database_rows_t& pTable, sqlite3_free_table(table); } -static void execute_sql(sqlite3 *db, const char *fmt, ...) +static int execute_sql(sqlite3 *db, const char *fmt, ...) { va_list p; va_start(p, fmt); @@ -163,8 +163,11 @@ static void execute_sql(sqlite3 *db, const char *fmt, ...) sqlite3_free(err); throw CABRTException(EXCEP_PLUGIN, errstr.c_str()); } - VERB2 log("%d rows affected by SQL:%s", sqlite3_changes(db), sql); + int affected = sqlite3_changes(db); + VERB2 log("%d rows affected by SQL:%s", affected, sql); free(sql); + + return affected; } static bool exists_uuid_uid(sqlite3 *db, const char *pUUID, const char *pUID) @@ -481,9 +484,6 @@ void CSQLite3::DeleteRows_by_dir(const char *dump_dir) void CSQLite3::SetReported(const char *pUUID, const char *pUID, const char *pMessage) { -// string escaped_msg = sql_escape(pMessage); -//#define pMessage pMessage_must_not_be_used_below - if (!is_string_safe(pUUID) || !is_string_safe(pUID) || !is_string_safe(pMessage) @@ -528,6 +528,37 @@ void CSQLite3::SetReported(const char *pUUID, const char *pUID, const char *pMes } } +void CSQLite3::SetReportedPerReporter(const char *pUUID, + const char *pUID, + const char *reporter, + const char *pMessage) +{ + if (!is_string_safe(pUUID) + || !is_string_safe(pUID) + || !is_string_safe(reporter) + || !is_string_safe(pMessage) + ) { + return; + } + + int affected_rows = execute_sql(m_pDB, + "UPDATE "ABRT_REPRESULT_TABLE + " SET "COL_MESSAGE"='%s'" + " WHERE "COL_UUID"='%s' AND "COL_UID"='%s' AND "COL_REPORTER"='%s'", + pMessage, + pUUID, pUID, reporter + ); + if (!affected_rows) + { + execute_sql(m_pDB, + "INSERT INTO "ABRT_REPRESULT_TABLE + " ("COL_UUID","COL_UID","COL_REPORTER","COL_MESSAGE")" + " VALUES ('%s','%s','%s','%s');", + pUUID, pUID, reporter, pMessage + ); + } +} + vector_database_rows_t CSQLite3::GetUIDData(const char *pUID) { vector_database_rows_t table; |