Merge pull request #2763 from yogstation13/upstream-merge-40611

[MIRROR] [Adventurous testmerging only] make all (except one) DB operations async
This commit is contained in:
Ling
2018-10-01 10:57:38 +02:00
committed by GitHub

View File

@@ -121,11 +121,11 @@ SUBSYSTEM_DEF(dbcore)
if(!Connect()) if(!Connect())
return return
var/datum/DBQuery/query_round_initialize = SSdbcore.NewQuery("INSERT INTO [format_table_name("round")] (initialize_datetime, server_ip, server_port) VALUES (Now(), INET_ATON(IF('[world.internet_address]' LIKE '', '0', '[world.internet_address]')), '[world.port]')") var/datum/DBQuery/query_round_initialize = SSdbcore.NewQuery("INSERT INTO [format_table_name("round")] (initialize_datetime, server_ip, server_port) VALUES (Now(), INET_ATON(IF('[world.internet_address]' LIKE '', '0', '[world.internet_address]')), '[world.port]')")
query_round_initialize.Execute() query_round_initialize.Execute(async = FALSE)
qdel(query_round_initialize) qdel(query_round_initialize)
var/datum/DBQuery/query_round_last_id = SSdbcore.NewQuery("SELECT LAST_INSERT_ID()") var/datum/DBQuery/query_round_last_id = SSdbcore.NewQuery("SELECT LAST_INSERT_ID()")
query_round_last_id.Execute() query_round_last_id.Execute(async = FALSE)
if(query_round_last_id.NextRow()) if(query_round_last_id.NextRow(async = FALSE))
GLOB.round_id = query_round_last_id.item[1] GLOB.round_id = query_round_last_id.item[1]
qdel(query_round_last_id) qdel(query_round_last_id)
@@ -283,12 +283,12 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
last_activity = activity last_activity = activity
last_activity_time = world.time last_activity_time = world.time
/datum/DBQuery/proc/warn_execute(async = FALSE) /datum/DBQuery/proc/warn_execute(async = TRUE)
. = Execute(async) . = Execute(async)
if(!.) if(!.)
to_chat(usr, "<span class='danger'>A SQL error occurred during this operation, check the server logs.</span>") to_chat(usr, "<span class='danger'>A SQL error occurred during this operation, check the server logs.</span>")
/datum/DBQuery/proc/Execute(async = FALSE, log_error = TRUE) /datum/DBQuery/proc/Execute(async = TRUE, log_error = TRUE)
Activity("Execute") Activity("Execute")
if(in_progress) if(in_progress)
CRASH("Attempted to start a new query while waiting on the old one") CRASH("Attempted to start a new query while waiting on the old one")
@@ -325,7 +325,7 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
/datum/DBQuery/proc/slow_query_check() /datum/DBQuery/proc/slow_query_check()
message_admins("HEY! A database query timed out. Did the server just hang? <a href='?_src_=holder;[HrefToken()];slowquery=yes'>\[YES\]</a>|<a href='?_src_=holder;[HrefToken()];slowquery=no'>\[NO\]</a>") message_admins("HEY! A database query timed out. Did the server just hang? <a href='?_src_=holder;[HrefToken()];slowquery=yes'>\[YES\]</a>|<a href='?_src_=holder;[HrefToken()];slowquery=no'>\[NO\]</a>")
/datum/DBQuery/proc/NextRow(async) /datum/DBQuery/proc/NextRow(async = TRUE)
Activity("NextRow") Activity("NextRow")
UNTIL(!in_progress) UNTIL(!in_progress)
if(!skip_next_is_complete) if(!skip_next_is_complete)
@@ -361,5 +361,5 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
//strip sensitive stuff //strip sensitive stuff
if(findtext(message, ": CreateConnection(")) if(findtext(message, ": CreateConnection("))
message = "CreateConnection CENSORED" message = "CreateConnection CENSORED"
log_sql("BSQL_DEBUG: [message]") log_sql("BSQL_DEBUG: [message]")