Commit 222939cb48dc16b5f4b0ce028e044f78324adf71
1 parent
452bc79b
Add sql_query_statement_timeout helper function like sql_query_timeout
Showing
1 changed file
with
31 additions
and
4 deletions
Show diff stats
database/db_utils.anubis
| ... | ... | @@ -14,6 +14,8 @@ read data_base/db_tools.anubis |
| 14 | 14 | read data_base/sqlite.anubis |
| 15 | 15 | |
| 16 | 16 | transmit calexium_lib/database/db_types.anubis |
| 17 | +transmit calexium_lib/database/db_utils.anubis | |
| 18 | + | |
| 17 | 19 | read calexium_lib/net_services_protocols/logger_service.anubis |
| 18 | 20 | |
| 19 | 21 | public define Int one_year_seconds = 365 * 86400. // amount of seconds during 1 year |
| ... | ... | @@ -138,7 +140,7 @@ public define SQLite3QueryResult |
| 138 | 140 | ) = |
| 139 | 141 | //we try with 30 sec of timeout |
| 140 | 142 | with t0 = unow, |
| 141 | - if sql_query_timeout(db, sql_query, initial_bindings, 60, 100) is | |
| 143 | + if sql_query_timeout(db, sql_query, initial_bindings, 120, 100) is | |
| 142 | 144 | { |
| 143 | 145 | error(sql_error) then logError("DB", db_error(sql_error,msg) /*+ " executing [" + sql_query + "]"*/); |
| 144 | 146 | //println(" executing [" + sql_query + "]"); |
| ... | ... | @@ -159,6 +161,32 @@ public define SQLite3QueryResult |
| 159 | 161 | String msg //message to be shown if an error occure |
| 160 | 162 | ) = |
| 161 | 163 | sql_query_timeout(db, sql_query, [], msg). |
| 164 | + | |
| 165 | +public define SQLite3Row | |
| 166 | + sql_query_statement_timeout | |
| 167 | + ( | |
| 168 | + SQLite3Stmt sql_command_stmt, //sql query itself | |
| 169 | + List(SQLite3Bind) initial_bindings, | |
| 170 | + String msg //message to be shown if an error occure | |
| 171 | + ) = | |
| 172 | + //we try with 60 sec of timeout with | |
| 173 | + with t0 = unow, | |
| 174 | + if sql_query_statement_timeout(sql_command_stmt, initial_bindings, 120, 100, msg) is | |
| 175 | + { | |
| 176 | + error(sql_error) then logError("DB", db_error(sql_error,msg) /*+ " executing [" + sql_query + "]"*/); | |
| 177 | + //println(" executing [" + sql_query + "]"); | |
| 178 | + __logQueries(t0, "stmt", msg); | |
| 179 | + __logLongQueries(t0, "stmt", msg); | |
| 180 | + error(sql_error), | |
| 181 | + no_more_row then | |
| 182 | + __logQueries(t0, "stmt", msg); | |
| 183 | + __logLongQueries(t0, "stmt", msg); | |
| 184 | + no_more_row | |
| 185 | + row(data) then | |
| 186 | + __logQueries(t0, "stmt", msg); | |
| 187 | + __logLongQueries(t0, "stmt", msg); | |
| 188 | + row(data) | |
| 189 | + }. | |
| 162 | 190 | |
| 163 | 191 | // -- Extractors HELPERS --------------- |
| 164 | 192 | |
| ... | ... | @@ -197,8 +225,8 @@ public define List(String) |
| 197 | 225 | public define List(Int) |
| 198 | 226 | db_get_integer_list |
| 199 | 227 | ( |
| 200 | - One -> SQLite3Row table_cursor, | |
| 201 | - List(Int) so_far | |
| 228 | + One -> SQLite3Row table_cursor, | |
| 229 | + List(Int) so_far | |
| 202 | 230 | ) = |
| 203 | 231 | if table_cursor(unique) is |
| 204 | 232 | { |
| ... | ... | @@ -209,7 +237,6 @@ public define List(Int) |
| 209 | 237 | db_get_integer_list(table_cursor, [s . so_far]) |
| 210 | 238 | }. |
| 211 | 239 | |
| 212 | - | |
| 213 | 240 | public define List(Int) |
| 214 | 241 | db_get_integer_list |
| 215 | 242 | ( | ... | ... |