Skip to content

Commit

Permalink
fix missing table name (#37058)
Browse files Browse the repository at this point in the history
this was causing a crash
  • Loading branch information
3nids committed Jun 9, 2020
1 parent d1d4824 commit 0f3525d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/qgssqliteutils.cpp
Expand Up @@ -126,7 +126,9 @@ QSet<QString> QgsSqliteUtils::uniqueFields( sqlite3 *connection, const QString &
QSet<QString> uniqueFieldsResults;
char *zErrMsg = 0;
std::vector<std::string> rows;
QString sql = QgsSqlite3Mprintf( "select sql from sqlite_master where type='table' and name=%q", quotedIdentifier( tableName ).toStdString().c_str() );
QByteArray tableNameUtf8 = quotedIdentifier( tableName ).toUtf8();
QString sql = QgsSqlite3Mprintf( "select sql from sqlite_master "
"where type='table' and name=%q", tableNameUtf8.constData() );
auto cb = [ ](
void *data /* Data provided in the 4th argument of sqlite3_exec() */,
int /* The number of columns in row */,
Expand Down Expand Up @@ -172,7 +174,7 @@ QSet<QString> QgsSqliteUtils::uniqueFields( sqlite3 *connection, const QString &

// Search indexes:
sql = QgsSqlite3Mprintf( "SELECT sql FROM sqlite_master WHERE type='index' AND"
" tbl_name='%q' AND sql LIKE 'CREATE UNIQUE INDEX%%'" );
" tbl_name='%q' AND sql LIKE 'CREATE UNIQUE INDEX%%'", tableNameUtf8.constData() );
rc = sqlite3_exec( connection, sql.toUtf8(), cb, ( void * )&rows, &zErrMsg );
if ( rc != SQLITE_OK )
{
Expand Down

0 comments on commit 0f3525d

Please sign in to comment.