7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 19:59:18 +00:00

DbLib: Prevent uncaught exception creating statement

Defer telling the statement about the connection until the
try block, because otherwise it can connect immediately and
potentially throw an exception if the connection fails.
This commit is contained in:
Jon Evans 2024-05-06 16:59:49 -04:00
parent 6482a322da
commit ddd7c35586

View File

@ -390,15 +390,14 @@ bool DATABASE_CONNECTION::SelectOne( const std::string& aTable,
columnsFor( tableName ),
m_quoteChar, tableName, m_quoteChar,
m_quoteChar, columnName, m_quoteChar );
nanodbc::statement statement( *m_conn );
nanodbc::string query = fromUTF8( queryStr );
PROF_TIMER timer;
nanodbc::statement statement;
try
{
statement.prepare( query );
statement.prepare( *m_conn, query );
statement.bind( 0, aWhere.second.c_str() );
}
catch( nanodbc::database_error& e )