Skip to content

Commit 509427a

Browse files
committed
sql test
1 parent 1230711 commit 509427a

24 files changed

Lines changed: 404 additions & 512 deletions

File tree

cev_eris.dme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "code\__DEFINES\craft.dm"
3131
#include "code\__DEFINES\cyborg_traits.dm"
3232
#include "code\__DEFINES\damage_organs.dm"
33+
#include "code\__DEFINES\database.dm"
3334
#include "code\__DEFINES\economy.dm"
3435
#include "code\__DEFINES\error_handler.dm"
3536
#include "code\__DEFINES\flags.dm"
@@ -226,6 +227,7 @@
226227
#include "code\controllers\subsystems\chemistry.dm"
227228
#include "code\controllers\subsystems\chunks.dm"
228229
#include "code\controllers\subsystems\craft.dm"
230+
#include "code\controllers\subsystems\database.dm"
229231
#include "code\controllers\subsystems\dcs.dm"
230232
#include "code\controllers\subsystems\economy.dm"
231233
#include "code\controllers\subsystems\evac.dm"
@@ -527,7 +529,6 @@
527529
#include "code\defines\obj.dm"
528530
#include "code\defines\procs\announce.dm"
529531
#include "code\defines\procs\AStar.dm"
530-
#include "code\defines\procs\dbcore.dm"
531532
#include "code\defines\procs\hud.dm"
532533
#include "code\defines\procs\radio.dm"
533534
#include "code\defines\procs\sd_Alert.dm"
@@ -1425,6 +1426,7 @@
14251426
#include "code\modules\admin\verbs\possess.dm"
14261427
#include "code\modules\admin\verbs\pray.dm"
14271428
#include "code\modules\admin\verbs\randomverbs.dm"
1429+
#include "code\modules\admin\verbs\reestablish_db_connection.dm"
14281430
#include "code\modules\admin\verbs\ticklag.dm"
14291431
#include "code\modules\admin\verbs\tripAI.dm"
14301432
#include "code\modules\admin\verbs\SDQL_2\SDQL_2.dm"

code/__DEFINES/subsystems-priority.dm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ var/list/bitflags = list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096
1616
#define SS_PRIORITY_TICKER 200 // Gameticker processing.
1717
#define FIRE_PRIORITY_TGUI 110
1818
#define FIRE_PRIORITY_EXPLOSIONS 105 // Explosions!
19-
#define FIRE_PRIORITY_THROWING 106 // Throwing! after explosions since they influence throw direction
19+
#define FIRE_PRIORITY_DATABASE 104
20+
#define FIRE_PRIORITY_THROWING 103 // Throwing! after explosions since they influence throw direction
2021
#define SS_PRIORITY_HUMAN 101 // Human Life().
2122
#define SS_PRIORITY_MOB 100 // Non-human Mob Life().
2223
#define SS_PRIORITY_CHAT 100 // Chat subsystem.

code/__DEFINES/subsystems.dm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11

2+
//! ## DB defines
3+
/**
4+
* DB schema version
5+
*
6+
* Update this whenever the db schema changes
7+
*/
8+
#define DB_SCHEMA_VERSION 1
9+
10+
211
//! ## Timing subsystem
312
/**
413
* Don't run if there is an identical unique timer active
@@ -88,6 +97,7 @@
8897
// The numbers just define the ordering, they are meaningless otherwise.
8998

9099
#define INIT_ORDER_GARBAGE 99
100+
#define INIT_ORDER_DBCORE 98
91101
#define INIT_ORDER_EXPLOSIONS 97
92102
#define INIT_ORDER_STATPANELS 96
93103
#define INIT_ORDER_MAPPING 15

code/__HELPERS/text.dm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
* SQL sanitization
1414
*/
1515

16-
// Run all strings to be used in an SQL query through this proc first to properly escape out injection attempts.
17-
/proc/sanitizeSQL(var/t as text)
18-
var/sqltext = dbcon.Quote(t);
19-
return copytext(sqltext, 2, length(sqltext));//Quote() adds quotes around input, we already do that
16+
/proc/format_table_name(table as text)
17+
return sql_tableprefix + table
2018

2119
/*
2220
* Text sanitization

code/controllers/configuration.dm

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,13 +807,25 @@ GLOBAL_LIST_EMPTY(storyteller_cache)
807807
if ("address")
808808
sqladdress = value
809809
if ("port")
810-
sqlport = value
810+
sqlport = text2num(value)
811811
if ("database")
812812
sqldb = value
813813
if ("login")
814814
sqllogin = value
815815
if ("password")
816816
sqlpass = value
817+
if ("sql_tableprefix")
818+
sql_tableprefix = value
819+
if ("async_query_timeout")
820+
sql_async_query_timeout = text2num(value)
821+
if ("blocking_query_timeout")
822+
sql_blocking_query_timeout = text2num(value)
823+
if ("pooling_min_sql_connections")
824+
sql_pooling_min_sql_connections = text2num(value)
825+
if ("pooling_max_sql_connections")
826+
sql_pooling_max_sql_connections = text2num(value)
827+
if ("max_concurrent_queries")
828+
sql_max_concurrent_queries = text2num(value)
817829
else
818830
log_misc("Unknown setting in configuration: '[name]'")
819831

code/datums/topic/admin.dm

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,24 @@
13531353
else
13541354
error_viewer.showTo(usr, null, input["viewruntime_linear"])
13551355

1356+
/datum/admin_topic/slowquery
1357+
keyword = "slowquery"
1358+
require_perms = list(R_ADMIN)
1359+
1360+
/datum/admin_topic/viewruntime/Run(list/input)
1361+
if(!check_rights(R_ADMIN))
1362+
return
1363+
1364+
var/data = list("key" = usr.key)
1365+
var/answer = input["slowquery"]
1366+
if(answer == "yes")
1367+
if(alert(usr, "Did you just press any admin buttons?", "Query server hang report", list("Yes", "No")) == "Yes")
1368+
var/response = input(usr,"What were you just doing?","Query server hang report") as null|text
1369+
if(response)
1370+
data["response"] = response
1371+
log_misc("SQL: server hang - [json_encode(data)]")
1372+
else if(answer == "no")
1373+
log_misc("SQL: no server hang - [json_encode(data)]")
13561374

13571375
/datum/admin_topic/admincaster
13581376
keyword = "admincaster"

code/defines/procs/dbcore.dm

Lines changed: 0 additions & 235 deletions
This file was deleted.

0 commit comments

Comments
 (0)