mirror of
https://github.com/SphereServer/Source
synced 2026-08-13 10:26:05 -04:00
Updated internal SQLite libs v3.30.1 to v3.53.3
This commit is contained in:
parent
4506f05c55
commit
6f02c1da16
6 changed files with 83054 additions and 35976 deletions
|
|
@ -1878,4 +1878,5 @@ Removed: 32bit architecture support
|
|||
Removed: Obsolete SHRINKMEM function (the OS already manages memory automatically, and manually forcing a reduction causes performance drops)
|
||||
|
||||
21-07-2026, Coruja
|
||||
Changed: Updated internal Zlib libs v1.2.13 to v1.3.2.
|
||||
Changed: Updated internal Zlib libs v1.2.13 to v1.3.2.
|
||||
Changed: Updated internal SQLite libs v3.30.1 to v3.53.3.
|
||||
|
|
@ -9,8 +9,7 @@ CSQLite::CSQLite()
|
|||
|
||||
CSQLite::~CSQLite()
|
||||
{
|
||||
if ( m_socket )
|
||||
Close();
|
||||
Close();
|
||||
}
|
||||
|
||||
void CSQLite::Connect(LPCTSTR pszFileName)
|
||||
|
|
@ -23,13 +22,16 @@ void CSQLite::Connect(LPCTSTR pszFileName)
|
|||
if ( m_resultCode != SQLITE_OK )
|
||||
{
|
||||
g_Log.EventError("SQLite error #%d: %s\n", m_resultCode, sqlite3_errmsg(m_socket));
|
||||
sqlite3_close(m_socket);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
void CSQLite::Close()
|
||||
{
|
||||
ADDTOCALLSTACK("CSQLite::Close");
|
||||
if ( !m_socket )
|
||||
return;
|
||||
|
||||
sqlite3_close(m_socket);
|
||||
m_socket = NULL;
|
||||
}
|
||||
|
|
@ -37,49 +39,55 @@ void CSQLite::Close()
|
|||
TablePtr CSQLite::QueryPtr(LPCTSTR pszQuery)
|
||||
{
|
||||
ADDTOCALLSTACK("CSQLite::QueryPtr");
|
||||
char **retStrings = 0;
|
||||
char *errmsg = 0;
|
||||
int iRows = 0, iCols = 0;
|
||||
|
||||
m_resultCode = sqlite3_get_table(m_socket, UTF8MBSTR(pszQuery), &retStrings, &iRows, &iCols, &errmsg);
|
||||
sqlite3_stmt *pStmt = NULL;
|
||||
m_resultCode = sqlite3_prepare_v2(m_socket, UTF8MBSTR(pszQuery), -1, &pStmt, NULL);
|
||||
if ( m_resultCode != SQLITE_OK )
|
||||
g_Log.EventError("SQLite error #%d: %s [Cmd: \"%s\"]\n", m_resultCode, errmsg, pszQuery);
|
||||
{
|
||||
g_Log.EventError("SQLite prepare error #%d: %s [Cmd: \"%s\"]\n", m_resultCode, sqlite3_errmsg(m_socket), pszQuery);
|
||||
return TablePtr(new Table());
|
||||
}
|
||||
|
||||
Table *pTable = new Table();
|
||||
int iCols = sqlite3_column_count(pStmt);
|
||||
pTable->m_iCols = iCols;
|
||||
pTable->m_iRows = iRows;
|
||||
if ( iRows > 0 )
|
||||
pTable->m_iPos = 0;
|
||||
pTable->m_strlstCols.reserve(iCols);
|
||||
|
||||
int iPos = 0;
|
||||
for ( ; iPos < iCols; ++iPos )
|
||||
for ( int i = 0; i < iCols; ++i )
|
||||
{
|
||||
pTable->m_strlstCols.push_back(stdvstring());
|
||||
|
||||
if ( retStrings[iPos] )
|
||||
ConvertUTF8ToString(retStrings[iPos], pTable->m_strlstCols.back());
|
||||
const char *pszColName = sqlite3_column_name(pStmt, i);
|
||||
if ( pszColName )
|
||||
ConvertUTF8ToString(pszColName, pTable->m_strlstCols.back());
|
||||
else
|
||||
pTable->m_strlstCols.back().push_back('\0');
|
||||
}
|
||||
|
||||
pTable->m_lstRows.resize(iRows);
|
||||
for ( int iRow = 0; iRow < iRows; ++iRow )
|
||||
while ( (m_resultCode = sqlite3_step(pStmt)) == SQLITE_ROW )
|
||||
{
|
||||
pTable->m_lstRows[iRow].reserve(iCols);
|
||||
for ( int iCol = 0; iCol < iCols; ++iCol, ++iPos )
|
||||
{
|
||||
pTable->m_lstRows[iRow].push_back(stdvstring());
|
||||
pTable->m_lstRows.push_back(std::vector<stdvstring>());
|
||||
auto &row = pTable->m_lstRows.back();
|
||||
row.reserve(iCols);
|
||||
|
||||
if ( retStrings[iPos] )
|
||||
ConvertUTF8ToString(retStrings[iPos], pTable->m_lstRows[iRow].back());
|
||||
for ( int i = 0; i < iCols; ++i )
|
||||
{
|
||||
row.push_back(stdvstring());
|
||||
const unsigned char *pszValue = sqlite3_column_text(pStmt, i);
|
||||
if ( pszValue )
|
||||
ConvertUTF8ToString(static_cast<const char *>(static_cast<const void *>(pszValue)), row.back());
|
||||
else
|
||||
pTable->m_lstRows[iRow].back().push_back('\0');
|
||||
row.back().push_back('\0');
|
||||
}
|
||||
}
|
||||
|
||||
sqlite3_free_table(retStrings);
|
||||
sqlite3_free(errmsg);
|
||||
pTable->m_iRows = static_cast<int>(pTable->m_lstRows.size());
|
||||
if ( pTable->m_iRows > 0 )
|
||||
pTable->m_iPos = 0;
|
||||
|
||||
if ( m_resultCode != SQLITE_DONE )
|
||||
g_Log.EventError("SQLite step error #%d: %s\n", m_resultCode, sqlite3_errmsg(m_socket));
|
||||
|
||||
sqlite3_finalize(pStmt);
|
||||
return TablePtr(pTable);
|
||||
}
|
||||
|
||||
|
|
@ -121,17 +129,23 @@ void CSQLite::Exec(LPCTSTR pszQuery)
|
|||
if ( !m_socket )
|
||||
return;
|
||||
|
||||
char *errmsg = 0;
|
||||
|
||||
m_resultCode = sqlite3_exec(m_socket, UTF8MBSTR(pszQuery), 0, 0, &errmsg);
|
||||
sqlite3_stmt *pStmt = NULL;
|
||||
m_resultCode = sqlite3_prepare_v2(m_socket, UTF8MBSTR(pszQuery), -1, &pStmt, NULL);
|
||||
if ( m_resultCode != SQLITE_OK )
|
||||
{
|
||||
g_Log.EventError("SQLite error #%d: %s [Cmd: \"%s\"]\n", m_resultCode, errmsg, pszQuery);
|
||||
sqlite3_free(errmsg);
|
||||
g_Log.EventError("SQLite prepare error #%d: %s [Cmd: \"%s\"]\n", m_resultCode, sqlite3_errmsg(m_socket), pszQuery);
|
||||
return;
|
||||
}
|
||||
|
||||
m_resultCode = sqlite3_step(pStmt);
|
||||
if ( (m_resultCode != SQLITE_DONE) && (m_resultCode != SQLITE_ROW) )
|
||||
g_Log.EventError("SQLite step error #%d: %s\n", m_resultCode, sqlite3_errmsg(m_socket));
|
||||
|
||||
sqlite3_finalize(pStmt);
|
||||
}
|
||||
|
||||
void CSQLite::ConvertUTF8ToString(LPTSTR pszIn, stdvstring &pszOut)
|
||||
|
||||
void CSQLite::ConvertUTF8ToString(LPCTSTR pszIn, stdvstring &pszOut)
|
||||
{
|
||||
ADDTOCALLSTACK("CSQLite::ConvertUTF8ToString");
|
||||
size_t len = strlen(pszIn) + 1;
|
||||
|
|
@ -233,13 +247,11 @@ bool CSQLite::r_Verb(CScript &s, CTextConsole *pSrc)
|
|||
switch ( index )
|
||||
{
|
||||
case LDBOV_CLOSE:
|
||||
if ( m_socket )
|
||||
Close();
|
||||
Close();
|
||||
break;
|
||||
|
||||
case LDBOV_CONNECT:
|
||||
if ( !m_socket )
|
||||
Connect(s.GetArgRaw());
|
||||
Connect(s.GetArgRaw());
|
||||
break;
|
||||
|
||||
case LDBOV_EXECUTE:
|
||||
|
|
@ -306,6 +318,12 @@ TablePtr::TablePtr(Table *pTable)
|
|||
m_pTable = pTable;
|
||||
}
|
||||
|
||||
TablePtr::TablePtr(TablePtr &&pTable)
|
||||
{
|
||||
m_pTable = pTable.m_pTable;
|
||||
pTable.m_pTable = NULL;
|
||||
}
|
||||
|
||||
TablePtr::~TablePtr()
|
||||
{
|
||||
if ( m_pTable )
|
||||
|
|
@ -344,6 +362,13 @@ UTF8MBSTR::~UTF8MBSTR()
|
|||
size_t UTF8MBSTR::ConvertStringToUTF8(LPCTSTR pszIn, char *&pszOut)
|
||||
{
|
||||
ADDTOCALLSTACK("UTF8MBSTR::ConvertStringToUTF8");
|
||||
if ( !pszIn )
|
||||
{
|
||||
pszOut = new char[1];
|
||||
pszOut[0] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t len = strlen(pszIn);
|
||||
wchar_t *wChar = new wchar_t[len + 1];
|
||||
wChar[0] = '\0';
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
void ConvertUTF8ToString(LPTSTR pszIn, stdvstring &pszOut);
|
||||
void ConvertUTF8ToString(LPCTSTR pszIn, stdvstring &pszOut);
|
||||
};
|
||||
|
||||
class Table
|
||||
|
|
@ -82,10 +82,14 @@ class TablePtr
|
|||
public:
|
||||
TablePtr();
|
||||
TablePtr(Table *pTable);
|
||||
TablePtr(TablePtr &&pTable);
|
||||
virtual ~TablePtr();
|
||||
|
||||
public:
|
||||
Table *m_pTable;
|
||||
|
||||
private:
|
||||
TablePtr &operator=(const TablePtr &other);
|
||||
};
|
||||
|
||||
// Class for converting TCHAR to multi-byte UTF-8 and vice versa
|
||||
|
|
@ -105,6 +109,9 @@ private:
|
|||
|
||||
public:
|
||||
operator char *();
|
||||
|
||||
private:
|
||||
UTF8MBSTR &operator=(const UTF8MBSTR &other);
|
||||
};
|
||||
|
||||
#endif // _INC_SQLITE_H
|
||||
|
|
|
|||
113707
src/common/sqlite/sqlite3.c
113707
src/common/sqlite/sqlite3.c
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -113,12 +113,12 @@ BEGIN
|
|||
LTEXT "Version", IDC_ABOUT_VERSION, 10, 8, 200, 8
|
||||
CTEXT "Website", IDC_ABOUT_WEBSITE, 220, 8, 90, 8
|
||||
LTEXT "Compiler", IDC_ABOUT_COMPILER, 10, 16, 200, 8
|
||||
LTEXT "Copyright (C) 1997-2023 SphereServer development team", 3, 10, 24, 200, 8
|
||||
LTEXT "Copyright (C) 1997-2026 SphereServer development team", 3, 10, 24, 200, 8
|
||||
CTEXT "___________________________________________________________________________", 4, 0, 32, 320, 8
|
||||
LTEXT "This software makes use of:", 5, 10, 46, 100, 8
|
||||
LTEXT "libev library (v4.33)\nCopyright (C) 2007-2020 Marc Alexander Lehmann", 6, 15, 62, 290, 16
|
||||
LTEXT "MySQL Connector/C (v6.1.11)\nGeneral Public License (GPL) 2000-2017 Oracle", 7, 15, 86, 290, 16
|
||||
LTEXT "SQLite library (v3.30.1)\nGeneral Public License (GPL) 2000-2019", 8, 15, 110, 290, 16
|
||||
LTEXT "SQLite library (v3.53.3)\nGeneral Public License (GPL) 2000-2026", 8, 15, 110, 290, 16
|
||||
LTEXT "Twofish encryption library (v1.0)\nCopyright (C) 1998 Bruce Schneier, Doug Whiting, John Kelsey, Chris Hall, David Wagner", 9, 15, 134, 290, 16
|
||||
LTEXT "zlib data compression library (v1.3.2)\nCopyright (C) 1995-2026 Jean-loup Gailly, Mark Adler", 10, 15, 158, 290, 16
|
||||
END
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue