Only call sqlite3_expanded_sql when it exists

Only print expanded SQLite statement, when expanding function exists. This is
required to not bump the minimum required Ubuntu version, since Ubuntu 16.04
doesn't ship SQLite 3.14 or above. SQLite introduced ``sqlite3_expanded_sql`
in 3.14, Ubuntu 16.04 packages 3.11.

Disabled weak linking on MSVC, since it isn't supported.
This commit is contained in:
Zwelf 2020-09-07 19:50:19 +02:00
parent 88dc1c1a9c
commit a78e84d724

View file

@ -154,9 +154,14 @@ void CSqliteConnection::BindFloat(int Idx, float Value)
m_Done = false;
}
// TODO(2020-09-07): remove extern declaration, when all supported systems ship SQLite3 version 3.14 or above
#if defined(__GNUC__)
extern char *sqlite3_expanded_sql(sqlite3_stmt *pStmt) __attribute__((weak));
#endif
void CSqliteConnection::Print()
{
if(m_pStmt != nullptr)
if(m_pStmt != nullptr && sqlite3_expanded_sql != nullptr)
dbg_msg("sql", "SQLite statement: %s", sqlite3_expanded_sql(m_pStmt));
}