diff options
author | Janne Anttila <janne.anttila@digia.com> | 2009-09-02 08:14:33 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2009-09-02 08:14:33 (GMT) |
commit | c0358c891d91b7fe78f439eefc706d87099e2634 (patch) | |
tree | dccd4560a111972ed1317b711d028420dded071a /src/sql/drivers/mysql/qsql_mysql.cpp | |
parent | 584129c518719df51bc4812cc30773ab81e3f3cd (diff) | |
parent | 0b5a81dd9aa153f6cd3a3929ee7ed82ca48f45a5 (diff) | |
download | Qt-c0358c891d91b7fe78f439eefc706d87099e2634.zip Qt-c0358c891d91b7fe78f439eefc706d87099e2634.tar.gz Qt-c0358c891d91b7fe78f439eefc706d87099e2634.tar.bz2 |
Merge branch '4.6' of git@scm.dev.troll.no:qt/qt into 4.6
Diffstat (limited to 'src/sql/drivers/mysql/qsql_mysql.cpp')
-rw-r--r-- | src/sql/drivers/mysql/qsql_mysql.cpp | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index fa79460..b29e742 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -1310,23 +1310,38 @@ QSqlResult *QMYSQLDriver::createResult() const QStringList QMYSQLDriver::tables(QSql::TableType type) const { QStringList tl; - if (!isOpen()) - return tl; - if (!(type & QSql::Tables)) - return tl; - - MYSQL_RES* tableRes = mysql_list_tables(d->mysql, NULL); - MYSQL_ROW row; - int i = 0; - while (tableRes) { - mysql_data_seek(tableRes, i); - row = mysql_fetch_row(tableRes); - if (!row) - break; - tl.append(toUnicode(d->tc, row[0])); - i++; + if( mysql_get_server_version(d->mysql) < 50000) + { + if (!isOpen()) + return tl; + if (!(type & QSql::Tables)) + return tl; + + MYSQL_RES* tableRes = mysql_list_tables(d->mysql, NULL); + MYSQL_ROW row; + int i = 0; + while (tableRes) { + mysql_data_seek(tableRes, i); + row = mysql_fetch_row(tableRes); + if (!row) + break; + tl.append(toUnicode(d->tc, row[0])); + i++; + } + mysql_free_result(tableRes); + } else { + QSqlQuery q(createResult()); + if(type & QSql::Tables) { + q.exec(QLatin1String("select table_name from information_schema.tables where table_type = 'BASE TABLE'")); + while(q.next()) + tl.append(q.value(0).toString()); + } + if(type & QSql::Views) { + q.exec(QLatin1String("select table_name from information_schema.tables where table_type = 'VIEW'")); + while(q.next()) + tl.append(q.value(0).toString()); + } } - mysql_free_result(tableRes); return tl; } |