diff options
Diffstat (limited to 'src/plugins/sqldrivers')
-rw-r--r-- | src/plugins/sqldrivers/configure.json | 2 | ||||
-rw-r--r-- | src/plugins/sqldrivers/ibase/qsql_ibase.cpp | 9 | ||||
-rw-r--r-- | src/plugins/sqldrivers/mysql/main.cpp | 4 | ||||
-rw-r--r-- | src/plugins/sqldrivers/mysql/mysql.json | 2 | ||||
-rw-r--r-- | src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 272 | ||||
-rw-r--r-- | src/plugins/sqldrivers/mysql/qsql_mysql_p.h | 4 | ||||
-rw-r--r-- | src/plugins/sqldrivers/odbc/qsql_odbc.cpp | 6 | ||||
-rw-r--r-- | src/plugins/sqldrivers/psql/qsql_psql.cpp | 5 | ||||
-rw-r--r-- | src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 7 | ||||
-rw-r--r-- | src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h | 4 | ||||
-rw-r--r-- | src/plugins/sqldrivers/tds/qsql_tds_p.h | 4 |
11 files changed, 117 insertions, 202 deletions
diff --git a/src/plugins/sqldrivers/configure.json b/src/plugins/sqldrivers/configure.json index cd20eef1df..28ccbeadcd 100644 --- a/src/plugins/sqldrivers/configure.json +++ b/src/plugins/sqldrivers/configure.json @@ -72,7 +72,9 @@ { "type": "mysqlConfig", "query": "--libs_r", "cleanlibs": false }, { "type": "mysqlConfig", "query": "--libs", "cleanlibs": false }, { "libs": "-lmysqlclient_r", "condition": "!config.win32" }, + { "libs": "-llibmariadb", "condition": "config.win32" }, { "libs": "-llibmysql", "condition": "config.win32" }, + { "libs": "-lmariadb", "condition": "!config.win32" }, { "libs": "-lmysqlclient", "condition": "!config.win32" } ] }, diff --git a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp index 3368c74373..ffbc56829b 100644 --- a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp +++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp @@ -730,7 +730,7 @@ static char* createArrayBuffer(char *buffer, const QList<QVariant> &list, if (curDim != dim) { for(i = 0; i < list.size(); ++i) { - if (list.at(i).type() != QVariant::List) { // dimensions mismatch + if (list.at(i).userType() != QVariant::List) { // dimensions mismatch error = QLatin1String("Array dimensons mismatch. Fieldname: %1"); return 0; } @@ -1162,7 +1162,7 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx) // null value QVariant v; v.convert(qIBaseTypeName2(d->sqlda->sqlvar[i].sqltype, d->sqlda->sqlvar[i].sqlscale < 0)); - if(v.type() == QVariant::Double) { + if (v.userType() == QVariant::Double) { switch(numericalPrecisionPolicy()) { case QSql::LowPrecisionInt32: v.convert(QVariant::Int); @@ -1914,7 +1914,12 @@ void QIBaseDriver::qHandleEventNotification(void *updatedResultBuffer) if (counts[0]) { if (eBuffer->subscriptionState == QIBaseEventBuffer::Subscribed) { +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit notification(i.key()); +QT_WARNING_POP +#endif emit notification(i.key(), QSqlDriver::UnknownSource, QVariant()); } else if (eBuffer->subscriptionState == QIBaseEventBuffer::Starting) diff --git a/src/plugins/sqldrivers/mysql/main.cpp b/src/plugins/sqldrivers/mysql/main.cpp index d8d70483ef..4c6753097f 100644 --- a/src/plugins/sqldrivers/mysql/main.cpp +++ b/src/plugins/sqldrivers/mysql/main.cpp @@ -61,7 +61,9 @@ QMYSQLDriverPlugin::QMYSQLDriverPlugin() QSqlDriver* QMYSQLDriverPlugin::create(const QString &name) { - if (name == QLatin1String("QMYSQL") || name == QLatin1String("QMYSQL3")) { + if (name == QLatin1String("QMYSQL") || + name == QLatin1String("QMYSQL3") || + name == QLatin1String("QMARIADB")) { QMYSQLDriver* driver = new QMYSQLDriver(); return driver; } diff --git a/src/plugins/sqldrivers/mysql/mysql.json b/src/plugins/sqldrivers/mysql/mysql.json index 0caaadb7ce..89f5e65fb9 100644 --- a/src/plugins/sqldrivers/mysql/mysql.json +++ b/src/plugins/sqldrivers/mysql/mysql.json @@ -1,3 +1,3 @@ { - "Keys": [ "QMYSQL3", "QMYSQL" ] + "Keys": [ "QMYSQL3", "QMYSQL", "QMARIADB" ] } diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index febbe58506..90a810d516 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -65,16 +65,7 @@ Q_DECLARE_METATYPE(MYSQL_RES*) Q_DECLARE_METATYPE(MYSQL*) - -#if MYSQL_VERSION_ID >= 40108 Q_DECLARE_METATYPE(MYSQL_STMT*) -#endif - -#if MYSQL_VERSION_ID >= 40100 -# define Q_CLIENT_MULTI_STATEMENTS CLIENT_MULTI_STATEMENTS -#else -# define Q_CLIENT_MULTI_STATEMENTS 0 -#endif // MySQL above version 8 removed my_bool typedef while MariaDB kept it, // by redefining it we can regain source compatibility. @@ -199,10 +190,8 @@ protected: bool nextResult() override; void detachFromResultSet() override; -#if MYSQL_VERSION_ID >= 40108 bool prepare(const QString &stmt) override; bool exec() override; -#endif }; class QMYSQLResultPrivate: public QSqlResultPrivate @@ -217,9 +206,7 @@ public: result(0), rowsAffected(0), hasBlobs(false) -#if MYSQL_VERSION_ID >= 40108 , stmt(0), meta(0), inBinds(0), outBinds(0) -#endif , preparedQuery(false) { } @@ -236,24 +223,22 @@ public: { QMyField() : outField(0), nullIndicator(false), bufLength(0ul), - myField(0), type(QVariant::Invalid) + myField(0), type(QMetaType::UnknownType) {} char *outField; my_bool nullIndicator; ulong bufLength; MYSQL_FIELD *myField; - QVariant::Type type; + QMetaType::Type type; }; QVector<QMyField> fields; -#if MYSQL_VERSION_ID >= 40108 MYSQL_STMT* stmt; MYSQL_RES* meta; MYSQL_BIND *inBinds; MYSQL_BIND *outBinds; -#endif bool preparedQuery; }; @@ -261,11 +246,9 @@ public: #if QT_CONFIG(textcodec) static QTextCodec* codec(MYSQL* mysql) { -#if MYSQL_VERSION_ID >= 32321 QTextCodec* heuristicCodec = QTextCodec::codecForName(mysql_character_set_name(mysql)); if (heuristicCodec) return heuristicCodec; -#endif return QTextCodec::codecForLocale(); } #endif // textcodec @@ -280,25 +263,25 @@ static QSqlError qMakeError(const QString& err, QSqlError::ErrorType type, } -static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags) +static QMetaType::Type qDecodeMYSQLType(int mysqltype, uint flags) { - QVariant::Type type; + QMetaType::Type type; switch (mysqltype) { case FIELD_TYPE_TINY : - type = static_cast<QVariant::Type>((flags & UNSIGNED_FLAG) ? QMetaType::UChar : QMetaType::Char); + type = (flags & UNSIGNED_FLAG) ? QMetaType::UChar : QMetaType::Char; break; case FIELD_TYPE_SHORT : - type = static_cast<QVariant::Type>((flags & UNSIGNED_FLAG) ? QMetaType::UShort : QMetaType::Short); + type = (flags & UNSIGNED_FLAG) ? QMetaType::UShort : QMetaType::Short; break; case FIELD_TYPE_LONG : case FIELD_TYPE_INT24 : - type = (flags & UNSIGNED_FLAG) ? QVariant::UInt : QVariant::Int; + type = (flags & UNSIGNED_FLAG) ? QMetaType::UInt : QMetaType::Int; break; case FIELD_TYPE_YEAR : - type = QVariant::Int; + type = QMetaType::Int; break; case FIELD_TYPE_LONGLONG : - type = (flags & UNSIGNED_FLAG) ? QVariant::ULongLong : QVariant::LongLong; + type = (flags & UNSIGNED_FLAG) ? QMetaType::ULongLong : QMetaType::LongLong; break; case FIELD_TYPE_FLOAT : case FIELD_TYPE_DOUBLE : @@ -306,19 +289,19 @@ static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags) #if defined(FIELD_TYPE_NEWDECIMAL) case FIELD_TYPE_NEWDECIMAL: #endif - type = QVariant::Double; + type = QMetaType::Double; break; case FIELD_TYPE_DATE : - type = QVariant::Date; + type = QMetaType::QDate; break; case FIELD_TYPE_TIME : // A time field can be within the range '-838:59:59' to '838:59:59' so // use QString instead of QTime since QTime is limited to 24 hour clock - type = QVariant::String; + type = QMetaType::QString; break; case FIELD_TYPE_DATETIME : case FIELD_TYPE_TIMESTAMP : - type = QVariant::DateTime; + type = QMetaType::QDateTime; break; case FIELD_TYPE_STRING : case FIELD_TYPE_VAR_STRING : @@ -326,12 +309,12 @@ static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags) case FIELD_TYPE_TINY_BLOB : case FIELD_TYPE_MEDIUM_BLOB : case FIELD_TYPE_LONG_BLOB : - type = (flags & BINARY_FLAG) ? QVariant::ByteArray : QVariant::String; + type = (flags & BINARY_FLAG) ? QMetaType::QByteArray : QMetaType::QString; break; default: case FIELD_TYPE_ENUM : case FIELD_TYPE_SET : - type = QVariant::String; + type = QMetaType::QString; break; } return type; @@ -340,7 +323,7 @@ static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags) static QSqlField qToField(MYSQL_FIELD *field, QTextCodec *tc) { QSqlField f(toUnicode(tc, field->name), - qDecodeMYSQLType(int(field->type), field->flags), + QVariant::Type(qDecodeMYSQLType(int(field->type), field->flags)), toUnicode(tc, field->table)); f.setRequired(IS_NOT_NULL(field->flags)); f.setLength(field->length); @@ -350,8 +333,6 @@ static QSqlField qToField(MYSQL_FIELD *field, QTextCodec *tc) return f; } -#if MYSQL_VERSION_ID >= 40108 - static QSqlError qMakeStmtError(const QString& err, QSqlError::ErrorType type, MYSQL_STMT* stmt) { @@ -445,7 +426,6 @@ bool QMYSQLResultPrivate::bindInValues() } return true; } -#endif QMYSQLResult::QMYSQLResult(const QMYSQLDriver* db) : QSqlResult(*new QMYSQLResultPrivate(this, db)) @@ -460,11 +440,9 @@ QMYSQLResult::~QMYSQLResult() QVariant QMYSQLResult::handle() const { Q_D(const QMYSQLResult); -#if MYSQL_VERSION_ID >= 40108 if(d->preparedQuery) return d->meta ? QVariant::fromValue(d->meta) : QVariant::fromValue(d->stmt); else -#endif return QVariant::fromValue(d->result); } @@ -476,15 +454,12 @@ void QMYSQLResult::cleanup() // must iterate trough leftover result sets from multi-selects or stored procedures // if this isn't done subsequent queries will fail with "Commands out of sync" -#if MYSQL_VERSION_ID >= 40100 while (driver() && d->drv_d_func()->mysql && mysql_next_result(d->drv_d_func()->mysql) == 0) { MYSQL_RES *res = mysql_store_result(d->drv_d_func()->mysql); if (res) mysql_free_result(res); } -#endif -#if MYSQL_VERSION_ID >= 40108 if (d->stmt) { if (mysql_stmt_close(d->stmt)) qWarning("QMYSQLResult::cleanup: unable to free statement handle"); @@ -509,7 +484,6 @@ void QMYSQLResult::cleanup() delete[] d->inBinds; d->inBinds = 0; } -#endif d->hasBlobs = false; d->fields.clear(); @@ -536,7 +510,6 @@ bool QMYSQLResult::fetch(int i) if (at() == i) return true; if (d->preparedQuery) { -#if MYSQL_VERSION_ID >= 40108 mysql_stmt_data_seek(d->stmt, i); int nRC = mysql_stmt_fetch(d->stmt); @@ -550,9 +523,6 @@ bool QMYSQLResult::fetch(int i) "Unable to fetch data"), QSqlError::StatementError, d->stmt)); return false; } -#else - return false; -#endif } else { mysql_data_seek(d->result, i); d->row = mysql_fetch_row(d->result); @@ -570,7 +540,6 @@ bool QMYSQLResult::fetchNext() if (!driver()) return false; if (d->preparedQuery) { -#if MYSQL_VERSION_ID >= 40108 int nRC = mysql_stmt_fetch(d->stmt); if (nRC) { #ifdef MYSQL_DATA_TRUNCATED @@ -582,9 +551,6 @@ bool QMYSQLResult::fetchNext() "Unable to fetch data"), QSqlError::StatementError, d->stmt)); return false; } -#else - return false; -#endif } else { d->row = mysql_fetch_row(d->result); if (!d->row) @@ -607,11 +573,7 @@ bool QMYSQLResult::fetchLast() my_ulonglong numRows; if (d->preparedQuery) { -#if MYSQL_VERSION_ID >= 40108 numRows = mysql_stmt_num_rows(d->stmt); -#else - numRows = 0; -#endif } else { numRows = mysql_num_rows(d->result); } @@ -648,7 +610,7 @@ QVariant QMYSQLResult::data(int field) QString val; if (d->preparedQuery) { if (f.nullIndicator) - return QVariant(f.type); + return QVariant(QVariant::Type(f.type)); if (qIsInteger(f.type)) { QVariant variant(f.type, f.outField); @@ -660,34 +622,34 @@ QVariant QMYSQLResult::data(int field) return variant; } - if (f.type != QVariant::ByteArray) + if (f.type != QMetaType::QByteArray) val = toUnicode(d->drv_d_func()->tc, f.outField, f.bufLength); } else { if (d->row[field] == NULL) { // NULL value - return QVariant(f.type); + return QVariant(QVariant::Type(f.type)); } fieldLength = mysql_fetch_lengths(d->result)[field]; - if (f.type != QVariant::ByteArray) + if (f.type != QMetaType::QByteArray) val = toUnicode(d->drv_d_func()->tc, d->row[field], fieldLength); } switch (static_cast<int>(f.type)) { - case QVariant::LongLong: + case QMetaType::LongLong: return QVariant(val.toLongLong()); - case QVariant::ULongLong: + case QMetaType::ULongLong: return QVariant(val.toULongLong()); case QMetaType::Char: case QMetaType::Short: - case QVariant::Int: + case QMetaType::Int: return QVariant(val.toInt()); case QMetaType::UChar: case QMetaType::UShort: - case QVariant::UInt: + case QMetaType::UInt: return QVariant(val.toUInt()); - case QVariant::Double: { + case QMetaType::Double: { QVariant v; bool ok=false; double dbl = val.toDouble(&ok); @@ -711,13 +673,13 @@ QVariant QMYSQLResult::data(int field) return v; return QVariant(); } - case QVariant::Date: + case QMetaType::QDate: return qDateFromString(val); - case QVariant::Time: + case QMetaType::QTime: return qTimeFromString(val); - case QVariant::DateTime: + case QMetaType::QDateTime: return qDateTimeFromString(val); - case QVariant::ByteArray: { + case QMetaType::QByteArray: { QByteArray ba; if (d->preparedQuery) { @@ -727,7 +689,7 @@ QVariant QMYSQLResult::data(int field) } return QVariant(ba); } - case QVariant::String: + case QMetaType::QString: default: return QVariant(val); } @@ -788,11 +750,7 @@ int QMYSQLResult::size() Q_D(const QMYSQLResult); if (driver() && isSelect()) if (d->preparedQuery) -#if MYSQL_VERSION_ID >= 40108 return mysql_stmt_num_rows(d->stmt); -#else - return -1; -#endif else return int(mysql_num_rows(d->result)); else @@ -821,11 +779,9 @@ QVariant QMYSQLResult::lastInsertId() const return QVariant(); if (d->preparedQuery) { -#if MYSQL_VERSION_ID >= 40108 quint64 id = mysql_stmt_insert_id(d->stmt); if (id) return QVariant(id); -#endif } else { quint64 id = mysql_insert_id(d->drv_d_func()->mysql); if (id) @@ -842,11 +798,7 @@ QSqlRecord QMYSQLResult::record() const if (!isActive() || !isSelect() || !driver()) return info; -#if MYSQL_VERSION_ID >= 40108 res = d->preparedQuery ? d->meta : d->result; -#else - res = d->result; -#endif if (!mysql_errno(d->drv_d_func()->mysql)) { mysql_field_seek(res, 0); @@ -865,7 +817,7 @@ bool QMYSQLResult::nextResult() Q_D(QMYSQLResult); if (!driver()) return false; -#if MYSQL_VERSION_ID >= 40100 + setAt(-1); setActive(false); @@ -908,9 +860,6 @@ bool QMYSQLResult::nextResult() setActive(true); return true; -#else - return false; -#endif } void QMYSQLResult::virtual_hook(int id, void *data) @@ -918,24 +867,21 @@ void QMYSQLResult::virtual_hook(int id, void *data) QSqlResult::virtual_hook(id, data); } - -#if MYSQL_VERSION_ID >= 40108 - -static MYSQL_TIME *toMySqlDate(QDate date, QTime time, QVariant::Type type) +static MYSQL_TIME *toMySqlDate(QDate date, QTime time, int type) { - Q_ASSERT(type == QVariant::Time || type == QVariant::Date - || type == QVariant::DateTime); + Q_ASSERT(type == QMetaType::QTime || type == QMetaType::QDate + || type == QMetaType::QDateTime); MYSQL_TIME *myTime = new MYSQL_TIME; memset(myTime, 0, sizeof(MYSQL_TIME)); - if (type == QVariant::Time || type == QVariant::DateTime) { + if (type == QMetaType::QTime || type == QMetaType::QDateTime) { myTime->hour = time.hour(); myTime->minute = time.minute(); myTime->second = time.second(); myTime->second_part = time.msec() * 1000; } - if (type == QVariant::Date || type == QVariant::DateTime) { + if (type == QMetaType::QDate || type == QMetaType::QDateTime) { myTime->year = date.year(); myTime->month = date.month(); myTime->day = date.day(); @@ -949,7 +895,7 @@ bool QMYSQLResult::prepare(const QString& query) Q_D(QMYSQLResult); if (!driver()) return false; -#if MYSQL_VERSION_ID >= 40108 + cleanup(); if (!d->drv_d_func()->preparedQuerysEnabled) return QSqlResult::prepare(query); @@ -983,9 +929,6 @@ bool QMYSQLResult::prepare(const QString& query) setSelect(d->bindInValues()); d->preparedQuery = true; return true; -#else - return false; -#endif } bool QMYSQLResult::exec() @@ -1028,30 +971,30 @@ bool QMYSQLResult::exec() currBind->length = 0; currBind->is_unsigned = 0; - switch (val.type()) { - case QVariant::ByteArray: + switch (val.userType()) { + case QMetaType::QByteArray: currBind->buffer_type = MYSQL_TYPE_BLOB; currBind->buffer = const_cast<char *>(val.toByteArray().constData()); currBind->buffer_length = val.toByteArray().size(); break; - case QVariant::Time: - case QVariant::Date: - case QVariant::DateTime: { - MYSQL_TIME *myTime = toMySqlDate(val.toDate(), val.toTime(), val.type()); + case QMetaType::QTime: + case QMetaType::QDate: + case QMetaType::QDateTime: { + MYSQL_TIME *myTime = toMySqlDate(val.toDate(), val.toTime(), val.userType()); timeVector.append(myTime); currBind->buffer = myTime; - switch(val.type()) { - case QVariant::Time: + switch (val.userType()) { + case QMetaType::QTime: currBind->buffer_type = MYSQL_TYPE_TIME; myTime->time_type = MYSQL_TIMESTAMP_TIME; break; - case QVariant::Date: + case QMetaType::QDate: currBind->buffer_type = MYSQL_TYPE_DATE; myTime->time_type = MYSQL_TIMESTAMP_DATE; break; - case QVariant::DateTime: + case QMetaType::QDateTime: currBind->buffer_type = MYSQL_TYPE_DATETIME; myTime->time_type = MYSQL_TIMESTAMP_DATETIME; break; @@ -1061,32 +1004,32 @@ bool QMYSQLResult::exec() currBind->buffer_length = sizeof(MYSQL_TIME); currBind->length = 0; break; } - case QVariant::UInt: - case QVariant::Int: + case QMetaType::UInt: + case QMetaType::Int: currBind->buffer_type = MYSQL_TYPE_LONG; currBind->buffer = data; currBind->buffer_length = sizeof(int); - currBind->is_unsigned = (val.type() != QVariant::Int); + currBind->is_unsigned = (val.userType() != QMetaType::Int); break; - case QVariant::Bool: + case QMetaType::Bool: currBind->buffer_type = MYSQL_TYPE_TINY; currBind->buffer = data; currBind->buffer_length = sizeof(bool); currBind->is_unsigned = false; break; - case QVariant::Double: + case QMetaType::Double: currBind->buffer_type = MYSQL_TYPE_DOUBLE; currBind->buffer = data; currBind->buffer_length = sizeof(double); break; - case QVariant::LongLong: - case QVariant::ULongLong: + case QMetaType::LongLong: + case QMetaType::ULongLong: currBind->buffer_type = MYSQL_TYPE_LONGLONG; currBind->buffer = data; currBind->buffer_length = sizeof(qint64); - currBind->is_unsigned = (val.type() == QVariant::ULongLong); + currBind->is_unsigned = (val.userType() == QMetaType::ULongLong); break; - case QVariant::String: + case QMetaType::QString: default: { QByteArray ba = fromUnicode(d->drv_d_func()->tc, val.toString()); stringVector.append(ba); @@ -1155,7 +1098,7 @@ bool QMYSQLResult::exec() setActive(true); return true; } -#endif + ///////////////////////////////////////////////////////// static int qMySqlConnectionCount = 0; @@ -1164,18 +1107,16 @@ static bool qMySqlInitHandledByUser = false; static void qLibraryInit() { #ifndef Q_NO_MYSQL_EMBEDDED -# if MYSQL_VERSION_ID >= 40000 if (qMySqlInitHandledByUser || qMySqlConnectionCount > 1) return; -# if (MYSQL_VERSION_ID >= 40110 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50003 +# if MYSQL_VERSION_ID >= 50003 if (mysql_library_init(0, 0, 0)) { # else if (mysql_server_init(0, 0, 0)) { # endif qWarning("QMYSQLDriver::qServerInit: unable to start server."); } -# endif // MYSQL_VERSION_ID #endif // Q_NO_MYSQL_EMBEDDED #if defined(MARIADB_BASE_VERSION) || defined(MARIADB_VERSION_ID) @@ -1187,12 +1128,10 @@ static void qLibraryEnd() { #if !defined(MARIADB_BASE_VERSION) && !defined(MARIADB_VERSION_ID) # if !defined(Q_NO_MYSQL_EMBEDDED) -# if MYSQL_VERSION_ID > 40000 -# if (MYSQL_VERSION_ID >= 40110 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50003 - mysql_library_end(); -# else - mysql_server_end(); -# endif +# if MYSQL_VERSION_ID >= 50003 + mysql_library_end(); +# else + mysql_server_end(); # endif # endif #endif @@ -1271,17 +1210,9 @@ bool QMYSQLDriver::hasFeature(DriverFeature f) const return true; case PreparedQueries: case PositionalPlaceholders: -#if MYSQL_VERSION_ID >= 40108 return d->preparedQuerysEnabled; -#else - return false; -#endif case MultipleResultSets: -#if MYSQL_VERSION_ID >= 40100 return true; -#else - return false; -#endif } return false; } @@ -1322,7 +1253,7 @@ bool QMYSQLDriver::open(const QString& db, we have to enable CLIEN_MULTI_STATEMENTS here, otherwise _any_ stored procedure call will fail. */ - unsigned int optionFlags = Q_CLIENT_MULTI_STATEMENTS; + unsigned int optionFlags = CLIENT_MULTI_STATEMENTS; const QStringList opts(connOpts.split(QLatin1Char(';'), QString::SkipEmptyParts)); QString unixSocket; QString sslCert; @@ -1330,12 +1261,10 @@ bool QMYSQLDriver::open(const QString& db, QString sslKey; QString sslCAPath; QString sslCipher; -#if MYSQL_VERSION_ID >= 50000 my_bool reconnect=false; uint connectTimeout = 0; uint readTimeout = 0; uint writeTimeout = 0; -#endif // extract the real options from the string for (int i = 0; i < opts.count(); ++i) { @@ -1346,18 +1275,15 @@ bool QMYSQLDriver::open(const QString& db, QString opt = tmp.left(idx).simplified(); if (opt == QLatin1String("UNIX_SOCKET")) unixSocket = val; -#if MYSQL_VERSION_ID >= 50000 else if (opt == QLatin1String("MYSQL_OPT_RECONNECT")) { if (val == QLatin1String("TRUE") || val == QLatin1String("1") || val.isEmpty()) reconnect = true; - } else if (opt == QLatin1String("MYSQL_OPT_CONNECT_TIMEOUT")) { + } else if (opt == QLatin1String("MYSQL_OPT_CONNECT_TIMEOUT")) connectTimeout = val.toInt(); - } else if (opt == QLatin1String("MYSQL_OPT_READ_TIMEOUT")) { + else if (opt == QLatin1String("MYSQL_OPT_READ_TIMEOUT")) readTimeout = val.toInt(); - } else if (opt == QLatin1String("MYSQL_OPT_WRITE_TIMEOUT")) { + else if (opt == QLatin1String("MYSQL_OPT_WRITE_TIMEOUT")) writeTimeout = val.toInt(); - } -#endif else if (opt == QLatin1String("SSL_KEY")) sslKey = val; else if (opt == QLatin1String("SSL_CERT")) @@ -1442,7 +1368,7 @@ bool QMYSQLDriver::open(const QString& db, return false; } -#if (MYSQL_VERSION_ID >= 40113 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50007 +#if MYSQL_VERSION_ID >= 50007 if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) { // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters) mysql_set_character_set(d->mysql, "utf8mb4"); @@ -1457,20 +1383,15 @@ bool QMYSQLDriver::open(const QString& db, d->tc = codec(d->mysql); #endif } -#endif +#endif // MYSQL_VERSION_ID >= 50007 -#if MYSQL_VERSION_ID >= 40108 d->preparedQuerysEnabled = mysql_get_client_version() >= 40108 && mysql_get_server_version(d->mysql) >= 40100; -#else - d->preparedQuerysEnabled = false; -#endif #if QT_CONFIG(thread) mysql_thread_init(); #endif - setOpen(true); setOpenError(false); return true; @@ -1499,46 +1420,21 @@ QStringList QMYSQLDriver::tables(QSql::TableType type) const { Q_D(const QMYSQLDriver); QStringList tl; -#if MYSQL_VERSION_ID >= 40100 - if( mysql_get_server_version(d->mysql) < 50000) - { -#endif - 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); -#if MYSQL_VERSION_ID >= 40100 - } else { - QSqlQuery q(createResult()); - if(type & QSql::Tables) { - QString sql = QLatin1String("select table_name from information_schema.tables where table_schema = '") + QLatin1String(d->mysql->db) + QLatin1String("' and table_type = 'BASE TABLE'"); - q.exec(sql); + QSqlQuery q(createResult()); + if (type & QSql::Tables) { + QString sql = QLatin1String("select table_name from information_schema.tables where table_schema = '") + QLatin1String(d->mysql->db) + QLatin1String("' and table_type = 'BASE TABLE'"); + q.exec(sql); - while(q.next()) - tl.append(q.value(0).toString()); - } - if(type & QSql::Views) { - QString sql = QLatin1String("select table_name from information_schema.tables where table_schema = '") + QLatin1String(d->mysql->db) + QLatin1String("' and table_type = 'VIEW'"); - q.exec(sql); + while (q.next()) + tl.append(q.value(0).toString()); + } + if (type & QSql::Views) { + QString sql = QLatin1String("select table_name from information_schema.tables where table_schema = '") + QLatin1String(d->mysql->db) + QLatin1String("' and table_type = 'VIEW'"); + q.exec(sql); - while(q.next()) - tl.append(q.value(0).toString()); - } + while (q.next()) + tl.append(q.value(0).toString()); } -#endif return tl; } @@ -1652,16 +1548,16 @@ QString QMYSQLDriver::formatValue(const QSqlField &field, bool trimStrings) cons if (field.isNull()) { r = QStringLiteral("NULL"); } else { - switch(field.type()) { - case QVariant::Double: + switch (+field.type()) { + case QMetaType::Double: r = QString::number(field.value().toDouble(), 'g', field.precision()); break; - case QVariant::String: + case QMetaType::QString: // Escape '\' characters r = QSqlDriver::formatValue(field, trimStrings); r.replace(QLatin1String("\\"), QLatin1String("\\\\")); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: if (isOpen()) { const QByteArray ba = field.value().toByteArray(); // buffer has to be at least length*2+1 bytes diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql_p.h b/src/plugins/sqldrivers/mysql/qsql_mysql_p.h index 48b04fb1f5..9ccc8f4e4f 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql_p.h +++ b/src/plugins/sqldrivers/mysql/qsql_mysql_p.h @@ -75,8 +75,8 @@ class Q_EXPORT_SQLDRIVER_MYSQL QMYSQLDriver : public QSqlDriver Q_DECLARE_PRIVATE(QMYSQLDriver) Q_OBJECT public: - explicit QMYSQLDriver(QObject *parent=0); - explicit QMYSQLDriver(MYSQL *con, QObject * parent=0); + explicit QMYSQLDriver(QObject *parent=nullptr); + explicit QMYSQLDriver(MYSQL *con, QObject * parent=nullptr); ~QMYSQLDriver(); bool hasFeature(DriverFeature f) const override; bool open(const QString & db, diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp index 7709b13cd1..33bad23e3b 100644 --- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp +++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp @@ -1422,7 +1422,7 @@ bool QODBCResult::exec() SQLLEN *ind = &indicators[i]; if (val.isNull()) *ind = SQL_NULL_DATA; - switch (val.type()) { + switch (val.userType()) { case QVariant::Date: { QByteArray &ba = tmpStorage[i]; ba.resize(sizeof(DATE_STRUCT)); @@ -1694,7 +1694,7 @@ bool QODBCResult::exec() return true; for (i = 0; i < values.count(); ++i) { - switch (values.at(i).type()) { + switch (values.at(i).userType()) { case QVariant::Date: { DATE_STRUCT ds = *((DATE_STRUCT *)const_cast<char *>(tmpStorage.at(i).constData())); values[i] = QVariant(QDate(ds.year, ds.month, ds.day)); @@ -1735,7 +1735,7 @@ bool QODBCResult::exec() break; } } if (indicators[i] == SQL_NULL_DATA) - values[i] = QVariant(values[i].type()); + values[i] = QVariant(QVariant::Type(values[i].userType())); } return true; } diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index e0f82eee73..d735d29fc7 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1684,7 +1684,12 @@ void QPSQLDriver::_q_handleNotification(int) if (notify->extra) payload = d->isUtf8 ? QString::fromUtf8(notify->extra) : QString::fromLatin1(notify->extra); #endif +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit notification(name); +QT_WARNING_POP +#endif QSqlDriver::NotificationSource source = (notify->be_pid == PQbackendPID(d->connection)) ? QSqlDriver::SelfSource : QSqlDriver::OtherSource; emit notification(name, source, payload); } diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index 001bd673fc..551d762434 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -505,7 +505,7 @@ bool QSQLiteResult::exec() if (value.isNull()) { res = sqlite3_bind_null(d->stmt, i + 1); } else { - switch (value.type()) { + switch (value.userType()) { case QVariant::ByteArray: { const QByteArray *ba = static_cast<const QByteArray*>(value.constData()); res = sqlite3_bind_blob(d->stmt, i + 1, ba->constData(), @@ -1044,7 +1044,12 @@ void QSQLiteDriver::handleNotification(const QString &tableName, qint64 rowid) { Q_D(const QSQLiteDriver); if (d->notificationid.contains(tableName)) { +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit notification(tableName); +QT_WARNING_POP +#endif emit notification(tableName, QSqlDriver::UnknownSource, QVariant(rowid)); } } diff --git a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h index 48c64536f1..57db0a4d47 100644 --- a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h +++ b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h @@ -76,8 +76,8 @@ class Q_EXPORT_SQLDRIVER_SQLITE2 QSQLite2Driver : public QSqlDriver Q_DECLARE_PRIVATE(QSQLite2Driver) Q_OBJECT public: - explicit QSQLite2Driver(QObject *parent = 0); - explicit QSQLite2Driver(sqlite *connection, QObject *parent = 0); + explicit QSQLite2Driver(QObject *parent = nullptr); + explicit QSQLite2Driver(sqlite *connection, QObject *parent = nullptr); ~QSQLite2Driver(); bool hasFeature(DriverFeature f) const override; bool open(const QString &db, diff --git a/src/plugins/sqldrivers/tds/qsql_tds_p.h b/src/plugins/sqldrivers/tds/qsql_tds_p.h index 948e3c7024..b72fababbb 100644 --- a/src/plugins/sqldrivers/tds/qsql_tds_p.h +++ b/src/plugins/sqldrivers/tds/qsql_tds_p.h @@ -85,8 +85,8 @@ class Q_EXPORT_SQLDRIVER_TDS QTDSDriver : public QSqlDriver Q_OBJECT friend class QTDSResultPrivate; public: - explicit QTDSDriver(QObject* parent = 0); - QTDSDriver(LOGINREC* rec, const QString& host, const QString &db, QObject* parent = 0); + explicit QTDSDriver(QObject* parent = nullptr); + QTDSDriver(LOGINREC* rec, const QString& host, const QString &db, QObject* parent = nullptr); ~QTDSDriver(); bool hasFeature(DriverFeature f) const override; bool open(const QString &db, |