Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-75908

MYSQL: Cannot list tables in database when using libmysql version 8

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P2: Important
    • None
    • 5.12.2
    • SQL Support
    • None
    • Windows

    Description

      QSqlDatabase::tables() returns empty list if I connect to MYSQL database using libmysql.dll client library version 8.0.16.0.

      Steps to reproduce:

      1. Execute the following SQL script in MYSQL:

      CREATE DATABASE mysql_test_db;
      USE mysql_test_db;
      
      CREATE TABLE table1
      (
          id integer AUTO_INCREMENT,
          col1 bool,
          col2 int,
          col3 text,
          PRIMARY KEY(id)
      );
      
      CREATE TABLE table2
      (
          id integer AUTO_INCREMENT,
          col1 bool,
          col2 int,
          col3 text,
          PRIMARY KEY(id)
      );
      

      2. Create console application with this code:

      #include <QCoreApplication>
      #include <QString>
      #include <QSqlDatabase>
      #include <QSqlQuery>
      #include <QSqlError>
      #include <QTextStream>
      
      int main(int argc, char *argv[])
      {
          QTextStream cout(stdout);
          QCoreApplication app(argc, argv);
          
          QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
          db.setHostName("localhost");
          db.setDatabaseName("mysql_test_db");
          db.setUserName("root");
          db.setPassword("password");
         
          if (!db.open()) {
              cout << "Open database error. " << db.lastError().text() << endl;
              return 1;
          }
      
          QStringList tables = db.tables();
          cout << "Number of tables: " << tables.count() << endl;
          for (int i=0; i<tables.count(); ++i) {
              cout << (i+1) << "." << tables[i] << endl;
          }
          return 0;
      }
      

      3. Copy libmysql.dll, libeay32.dll and ssleay32.dll to build dir.

      4. Run the application.

      For libmysql.dll 8.0.16.0 the output is:

      Number of tables: 0
      

      For libmysql.dll 6.1.6.0 the output is:

      Number of tables: 2
      1.table1
      2.table2
      

       

      Tested with:

      MYSQL Community Server 8.0.16 x64,   MYSQL Community  Server 5.5.17 x86

      Qt 5.12.2 MSVC 2015 x64

      Windows 10 x64

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            chehrlic Christian Ehrlicher
            amiart Robert Szefner
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes