ddnet/src/engine/shared
bors[bot] b06bea7c04
Merge #2465
2465: Sqlite3 support and prepared statements r=heinrich5991 a=Zwelf

This PR changes the abstraction layer of the score backend to thin abstractions over the MySQL and SQLite3 library. It executes all Queries in one worker thread making it easier to use the ddnet thread pool. This doesn't change much, because each the mysql-connection was locked with `m_SqlLock` beforehand, serializing writes and reads respectively.

Behavior change (even though I tried to minimize them):

* `sv_use_sql` is used to determine if mysql server should be added
* `sv_sql_failure_file` is replaced by `sv_sqlite_file`
* `sv_sqlite_file` is either used as a backup server when `sv_use_sql` is enabled or as the primary read+write server when `sv_use_sql` is disabled
* `/load` now escapes the like-string

Since I am not good at designing config file commands, I would appreciate feedback on this part.

WIP:
* [x] rewrite SQL statements to work in both MySQL and SQLite (preferable just ANSI-SQL)
  * [x] create tables (`COLLATE BINARY` and encoding info)
  * [x] store rank (UPSERT for points)
  * [x] load birthday (different function in sqlite for time handling)
  * [x] `/mapinfo` (`convert(? using utf8mb4) COLLATE utf8mb4_general_ci`)
  * [x] `/map` (`convert(? using utf8mb4) COLLATE utf8mb4_general_ci`)
  * [x] store teamrank (`GROUP_CONCAT`)
  * [x] `/teamrank` (`GROUP_CONCAT`)
  * [x] ~`/top5team` (`GROUP_CONCAT`)~ doesn't contain GROUP_CONCAT
  * [x] `/times` (`UNIX_TIMESTAMP`)
  * [x] `/load` without any arguments (`UNIX_TIMESTAMP`)
* [x] all commits compiling, making future bisect easier
* [x] write a sqlite_to_mysql script
* [x] write an old_file_server to sqlite script
* [x] gracefully shutdown DbPool

Co-authored-by: Zwelf <zwelf@strct.cc>
2020-08-09 23:30:08 +00:00
..
compression.cpp Implement changes suggested by -Wuseless-cast 2019-04-11 19:54:43 +02:00
compression.h Made int packing functions safe 2017-09-17 02:36:50 +02:00
config.cpp Only write non-defaulted config values to settings_ddnet.cfg 2020-07-09 12:40:35 +02:00
config.h use pid in file names of temporary files 2020-02-12 23:14:30 +01:00
config_variables.h Apply suggestions from code review 2020-08-03 12:58:52 +02:00
console.cpp Fix color toggles 2020-06-27 15:12:53 +03:00
console.h Remove ugly hack 2020-06-19 21:42:19 +03:00
csv.cpp Add a simple CSV writer for Python's "excel" csv dialect 2020-06-23 09:11:59 +02:00
csv.h Add a simple CSV writer for Python's "excel" csv dialect 2020-06-23 09:11:59 +02:00
datafile.cpp map_convert_07: use regular paths 2019-12-08 23:14:56 +01:00
datafile.h map_convert_07: use regular paths 2019-12-08 23:14:56 +01:00
demo.cpp Fix some naming conventions in videorecorder 2020-06-23 08:00:03 +02:00
demo.h Fix demo recording with broken maps 2020-02-19 15:38:58 +03:00
econ.cpp Highlight in console 2014-12-20 13:37:11 +01:00
econ.h Highlight in console 2014-12-20 13:37:11 +01:00
engine.cpp Use two threads for the server thread pool 2018-10-07 12:47:32 +02:00
fifo.cpp Nicer way of handling Mac fifo rewinding (just don't use high level file streams) 2016-05-05 23:32:55 +02:00
fifo.h Nicer way of handling Mac fifo rewinding (just don't use high level file streams) 2016-05-05 23:32:55 +02:00
filecollection.cpp Fix FileCollection to remove the oldest file (fixes #605) 2019-01-11 11:39:05 +01:00
filecollection.h Fix FileCollection to remove the oldest file (fixes #605) 2019-01-11 11:39:05 +01:00
ghost.cpp Fixed several issues with the ghost (thanks to Learath2) 2017-10-28 14:23:24 +02:00
ghost.h Fixed several issues with the ghost (thanks to Learath2) 2017-10-28 14:23:24 +02:00
global_uuid_manager.cpp Move teehistorian UUIDs into engine 2018-01-11 16:01:13 +01:00
huffman.cpp Fix whitespaces a bit 2015-07-09 02:12:35 +02:00
huffman.h added "Whitespace and line Endings cleanup" by GreYFoX 2011-04-13 20:37:12 +02:00
jobs.cpp More error checking in system.c (fixes #1317) 2019-03-19 23:16:29 +01:00
jobs.h Implement changes suggested by -Wuseless-cast 2019-04-11 19:54:43 +02:00
json.cpp Use str_comp instead of strcmp 2020-06-22 14:47:49 +02:00
json.h Move DDNet-custom json code out of external directory (fixes #2022) 2020-01-01 20:07:04 +01:00
kernel.cpp Merge branch 'master' into leak_fix 2017-07-31 20:42:32 +02:00
linereader.cpp fixed possible CRLF line ending problem in the linereader 2011-01-20 21:17:11 +01:00
linereader.h Multiline broadcasts 2014-04-19 00:40:21 +02:00
map.cpp Use more secure hash function for map downloads 2018-06-24 17:04:50 +02:00
masterserver.cpp Fix lookup job being zeroed in CMasterServer::Load 2017-11-24 02:13:34 +01:00
memheap.cpp Remove mem_alloc and mem_free, use standard C functions instead 2018-04-09 11:56:39 +02:00
memheap.h added "Whitespace and line Endings cleanup" by GreYFoX 2011-04-13 20:37:12 +02:00
message.h Updated copyrights 2010-11-20 21:26:06 +01:00
netban.cpp Don't suggest to downgrade, clean up versioning (fixes #1440) 2019-03-03 20:31:23 +01:00
netban.h Don't suggest to downgrade, clean up versioning (fixes #1440) 2019-03-03 20:31:23 +01:00
network.cpp Serverinfo and Register support for 0.7 2020-06-19 20:28:55 +03:00
network.h Disable timeout for 0.7 clients 2020-06-20 19:52:23 +03:00
network_client.cpp Fix recvmmsg again... 2020-06-19 20:28:55 +03:00
network_conn.cpp Disable timeout for 0.7 clients 2020-06-20 19:52:23 +03:00
network_console.cpp Begin work on 0.7 support 2020-06-19 20:27:15 +03:00
network_console_conn.cpp General whitespace and tab cleanup 2011-08-11 10:59:14 +02:00
network_server.cpp Disable timeout for 0.7 clients 2020-06-20 19:52:23 +03:00
packer.cpp Generate the 0.7 protocol 2020-06-19 20:27:15 +03:00
packer.h Generate the 0.7 protocol 2020-06-19 20:27:15 +03:00
protocol.h Set skill level for Sixup (fixes #2334) 2020-06-23 22:47:29 +02:00
protocol_ex.cpp Fix ITIS, IDONTKNOW not being system messages 2020-05-16 00:41:03 +02:00
protocol_ex.h Remove all checking for the gametype in the game 2019-06-14 00:28:59 +02:00
protocol_ex_msgs.h Send DDNet version early in the connection process 2020-05-22 17:58:41 +02:00
ringbuffer.cpp Fix typo 2018-07-10 17:29:02 +08:00
ringbuffer.h Get rid of all Clang warnings 2015-04-18 22:29:28 +02:00
serverbrowser.cpp Fix blockZ and infectionZ 2019-07-24 06:52:32 +02:00
snapshot.cpp Send extended snap objects as is to Sixup 2020-08-04 20:10:49 +03:00
snapshot.h Begin work on 0.7 support 2020-06-19 20:27:15 +03:00
storage.cpp fps for videos configurable and videos are stored at a proper location 2019-09-30 20:48:47 +08:00
teehistorian_ex.cpp Move teehistorian UUIDs into engine 2018-01-11 16:01:13 +01:00
teehistorian_ex.h Fix all the header guards and adjust the script a little 2018-07-06 16:11:38 +02:00
teehistorian_ex_chunks.h Log save/load in teehistorian 2020-06-26 00:01:12 +02:00
uuid_manager.cpp Add uuid parsing 2020-08-03 12:58:52 +02:00
uuid_manager.h Add uuid parsing 2020-08-03 12:58:52 +02:00
video.cpp fps for videos configurable and videos are stored at a proper location 2019-09-30 20:48:47 +08:00
video.h Fix some naming conventions in videorecorder 2020-06-23 08:00:03 +02:00
websockets.cpp Update websockets implementation (fixes #1022) 2018-02-14 12:30:14 +01:00
websockets.h Fix all the header guards and adjust the script a little 2018-07-06 16:11:38 +02:00