Set correct size of name column in SQL table

This commit is contained in:
furo 2024-02-02 23:36:23 +01:00
parent 686cb5f1a7
commit 5378fdc20b
2 changed files with 10 additions and 5 deletions

View file

@ -1,7 +1,5 @@
#include "connection.h"
#include <engine/shared/protocol.h>
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());
}

View file

@ -3,8 +3,15 @@
#include "connection_pool.h"
#include <engine/shared/protocol.h>
#include <memory>
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