summaryrefslogtreecommitdiff
path: root/modules/extra/mysql.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2025-03-06 20:35:35 +0000
committerSadie Powell <sadie@witchery.services>2025-03-06 20:51:13 +0000
commit161841925da5048228aa3c3147a8bfaec078d7b0 (patch)
treeb3dcc95bc7c4da2606b2c7a1df29fa64739acfe1 /modules/extra/mysql.cpp
parente099180d8fea827915de33650af9b22fe427884d (diff)
Force the MySQL module to use UTC for connections.
This prevents conversion issues when the MySQL server is in a different timezone to the services server.
Diffstat (limited to 'modules/extra/mysql.cpp')
-rw-r--r--modules/extra/mysql.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/extra/mysql.cpp b/modules/extra/mysql.cpp
index 1f6777bcc..294ddfac0 100644
--- a/modules/extra/mysql.cpp
+++ b/modules/extra/mysql.cpp
@@ -631,6 +631,10 @@ void MySQLService::Connect()
if (!connect)
throw SQL::Exception("Unable to connect to MySQL service " + this->name + ": " + mysql_error(this->sql));
+ // We force UTC so that FromUnixtime works as expected.
+ SQL::Query tzquery("SET time_zone = '+00:00'");
+ RunQuery(tzquery);
+
if (this->socket.empty())
Log(LOG_DEBUG) << "Successfully connected to MySQL service " << this->name << " at " << this->server << ":" << this->port;
else