From 5378fdc20b2acde7ed2dbd7a2f00b26ccc6d4194 Mon Sep 17 00:00:00 2001 From: furo Date: Fri, 2 Feb 2024 23:36:23 +0100 Subject: [PATCH] Set correct size of name column in SQL table --- src/engine/server/databases/connection.cpp | 8 +++----- src/engine/server/databases/connection.h | 7 +++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/engine/server/databases/connection.cpp b/src/engine/server/databases/connection.cpp index ac124baa4..58dd5778e 100644 --- a/src/engine/server/databases/connection.cpp +++ b/src/engine/server/databases/connection.cpp @@ -1,7 +1,5 @@ #include "connection.h" -#include - IDbConnection::IDbConnection(const char *pPrefix) { str_copy(m_aPrefix, pPrefix); @@ -30,7 +28,7 @@ void IDbConnection::FormatCreateRace(char *aBuf, unsigned int BufferSize, bool B " PRIMARY KEY (Map, Name, Time, Timestamp, Server)" ")", GetPrefix(), Backup ? "_backup" : "", - BinaryCollate(), MAX_NAME_LENGTH, BinaryCollate()); + BinaryCollate(), MAX_NAME_LENGTH_SQL, BinaryCollate()); } void IDbConnection::FormatCreateTeamrace(char *aBuf, unsigned int BufferSize, const char *pIdType, bool Backup) const @@ -47,7 +45,7 @@ void IDbConnection::FormatCreateTeamrace(char *aBuf, unsigned int BufferSize, co " PRIMARY KEY (ID, Name)" ")", GetPrefix(), Backup ? "_backup" : "", - BinaryCollate(), MAX_NAME_LENGTH, BinaryCollate(), pIdType); + BinaryCollate(), MAX_NAME_LENGTH_SQL, BinaryCollate(), pIdType); } void IDbConnection::FormatCreateMaps(char *aBuf, unsigned int BufferSize) const @@ -90,5 +88,5 @@ void IDbConnection::FormatCreatePoints(char *aBuf, unsigned int BufferSize) cons " Points INT DEFAULT 0, " " PRIMARY KEY (Name)" ")", - GetPrefix(), MAX_NAME_LENGTH, BinaryCollate()); + GetPrefix(), MAX_NAME_LENGTH_SQL, BinaryCollate()); } diff --git a/src/engine/server/databases/connection.h b/src/engine/server/databases/connection.h index a2da8e0da..03ac5be42 100644 --- a/src/engine/server/databases/connection.h +++ b/src/engine/server/databases/connection.h @@ -3,8 +3,15 @@ #include "connection_pool.h" +#include #include +enum +{ + // MAX_NAME_LENGTH includes the size with \0, which is not necessary in SQL + MAX_NAME_LENGTH_SQL = MAX_NAME_LENGTH - 1, +}; + class IConsole; // can hold one PreparedStatement with Results