Make statistics available in case we use db_query instead of db_execute in scripts
This commit is contained in:
@ -454,6 +454,12 @@ db_result_set_t *db_query(db_conn_t *con, const char *query)
|
||||
rs->connection = con;
|
||||
|
||||
con->db_errno = con->driver->ops.query(con, query, rs);
|
||||
|
||||
if (con->db_errno == SB_DB_ERROR_DEADLOCK)
|
||||
thread_stats[con->thread_id].deadlocks++;
|
||||
|
||||
db_update_thread_stats(con->thread_id, db_get_query_type(query));
|
||||
|
||||
if (con->db_errno != SB_DB_ERROR_NONE)
|
||||
return NULL;
|
||||
|
||||
|
||||
@ -611,7 +611,11 @@ int sb_lua_db_query(lua_State *L)
|
||||
query = luaL_checkstring(L, 1);
|
||||
rs = db_query(ctxt->con, query);
|
||||
if (rs == NULL)
|
||||
luaL_error(L, "Database query failed");
|
||||
{
|
||||
if (ctxt->con->db_errno == SB_DB_ERROR_DEADLOCK)
|
||||
lua_pushnumber(L, SB_DB_RESTART_TRANSACTION);
|
||||
lua_error(L);
|
||||
}
|
||||
|
||||
db_store_results(rs);
|
||||
db_free_results(rs);
|
||||
|
||||
Reference in New Issue
Block a user