From 222939cb48dc16b5f4b0ce028e044f78324adf71 Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 17 Oct 2015 23:13:00 +0200 Subject: [PATCH] Add sql_query_statement_timeout helper function like sql_query_timeout --- database/db_utils.anubis | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/database/db_utils.anubis b/database/db_utils.anubis index 5a4ffd3..84dd16c 100644 --- a/database/db_utils.anubis +++ b/database/db_utils.anubis @@ -14,6 +14,8 @@ read data_base/db_tools.anubis read data_base/sqlite.anubis transmit calexium_lib/database/db_types.anubis +transmit calexium_lib/database/db_utils.anubis + read calexium_lib/net_services_protocols/logger_service.anubis public define Int one_year_seconds = 365 * 86400. // amount of seconds during 1 year @@ -138,7 +140,7 @@ public define SQLite3QueryResult ) = //we try with 30 sec of timeout with t0 = unow, - if sql_query_timeout(db, sql_query, initial_bindings, 60, 100) is + if sql_query_timeout(db, sql_query, initial_bindings, 120, 100) is { error(sql_error) then logError("DB", db_error(sql_error,msg) /*+ " executing [" + sql_query + "]"*/); //println(" executing [" + sql_query + "]"); @@ -159,6 +161,32 @@ public define SQLite3QueryResult String msg //message to be shown if an error occure ) = sql_query_timeout(db, sql_query, [], msg). + +public define SQLite3Row + sql_query_statement_timeout + ( + SQLite3Stmt sql_command_stmt, //sql query itself + List(SQLite3Bind) initial_bindings, + String msg //message to be shown if an error occure + ) = + //we try with 60 sec of timeout with + with t0 = unow, + if sql_query_statement_timeout(sql_command_stmt, initial_bindings, 120, 100, msg) is + { + error(sql_error) then logError("DB", db_error(sql_error,msg) /*+ " executing [" + sql_query + "]"*/); + //println(" executing [" + sql_query + "]"); + __logQueries(t0, "stmt", msg); + __logLongQueries(t0, "stmt", msg); + error(sql_error), + no_more_row then + __logQueries(t0, "stmt", msg); + __logLongQueries(t0, "stmt", msg); + no_more_row + row(data) then + __logQueries(t0, "stmt", msg); + __logLongQueries(t0, "stmt", msg); + row(data) + }. // -- Extractors HELPERS --------------- @@ -197,8 +225,8 @@ public define List(String) public define List(Int) db_get_integer_list ( - One -> SQLite3Row table_cursor, - List(Int) so_far + One -> SQLite3Row table_cursor, + List(Int) so_far ) = if table_cursor(unique) is { @@ -209,7 +237,6 @@ public define List(Int) db_get_integer_list(table_cursor, [s . so_far]) }. - public define List(Int) db_get_integer_list ( -- libgit2 0.21.4