From 920dfb2f443042777ea9547ff7a8beef56e90d92 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 17 Jul 2024 19:59:59 +0200 Subject: SQL/MySQL: honor schema when retrieving table record Honor the schema when retrieving the table record - otherwise we might end up getting the data for the wrong table (same tablename but wrong schema). Pick-to: 6.8 Fixes: QTBUG-127129 Task-number: QTBUG-122723 Change-Id: Ia3e9293dbdc77da760dd4d0702104048187fad5f Reviewed-by: Axel Spoerl --- src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/sqldrivers/mysql/qsql_mysql.cpp') diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index 71b406c1a2d..6b1a1c28f14 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -1508,7 +1508,8 @@ QSqlRecord QMYSQLDriver::record(const QString &tablename) const return r; // no binding of WHERE possible with MySQL // escaping on WHERE clause does not work, so use mysql_real_escape_string() - stmt = "SELECT column_name, column_default FROM information_schema.columns WHERE table_name = '%1'"_L1; + stmt = "SELECT column_name, column_default FROM information_schema.columns WHERE table_schema = '"_L1 + + d->dbName + "' AND table_name = '%1'"_L1; const auto baTableName = tablename.toUtf8(); QVarLengthArray tableNameQuoted(baTableName.size() * 2 + 1); #if defined(MARIADB_VERSION_ID) -- cgit v1.2.3