Skip to content
Permalink
Browse files

fix missing table name (#37058)

this was causing a crash
  • Loading branch information
3nids committed Jun 9, 2020
1 parent d1d4824 commit 0f3525d882bcb80b418c5e162ae3913915124e15
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/core/qgssqliteutils.cpp
@@ -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 */,
@@ -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 )
{

0 comments on commit 0f3525d

Please sign in to comment.
You can’t perform that action at this time.