summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/doc/snippets/code/doc_src_sql-driver.qdoc2
-rw-r--r--src/sql/doc/src/sql-driver.qdoc32
-rw-r--r--src/sql/kernel/qsqldatabase.cpp6
-rw-r--r--src/sql/kernel/qsqldriver.cpp5
-rw-r--r--src/sql/kernel/qsqldriver.h3
-rw-r--r--src/sql/models/qsqlrelationaltablemodel.cpp14
-rw-r--r--src/sql/models/qsqltablemodel.cpp4
7 files changed, 43 insertions, 23 deletions
diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
index 12a39d80b2..b869b309b7 100644
--- a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
+++ b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
@@ -235,7 +235,7 @@ make sub-oci
//! [35]
QSqlDatabase: QPSQL driver not loaded
-QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
+QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QMARIADB QODBC QODBC3 QPSQL QPSQL7
Could not create database object
//! [35]
diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc
index 3a0fcfa1e7..4d6df63749 100644
--- a/src/sql/doc/src/sql-driver.qdoc
+++ b/src/sql/doc/src/sql-driver.qdoc
@@ -48,7 +48,7 @@
\header \li Driver name \li DBMS
\row \li \l{#QDB2}{QDB2} \li IBM DB2 (version 7.1 and above)
\row \li \l{#QIBASE}{QIBASE} \li Borland InterBase
- \row \li \l{#QMYSQL}{QMYSQL} \li MySQL (version 5.0 and above)
+ \row \li \l{#QMYSQL}{QMYSQL / MARIADB} \li MySQL or MariaDB (version 5.0 and above)
\row \li \l{#QOCI}{QOCI} \li Oracle Call Interface Driver
\row \li \l{#QODBC}{QODBC}
\li Open Database Connectivity (ODBC) - Microsoft SQL Server and other
@@ -123,7 +123,13 @@
\section1 Driver Specifics
\target QMYSQL
- \section2 QMYSQL for MySQL 5 and higher
+ \section2 QMYSQL for MySQL or MariaDB 5 and higher
+
+ MariaDB is a fork of MySQL intended to remain free and open-source software
+ under the GNU General Public License. MariaDB intended to maintain high
+ compatibility with MySQL, ensuring a drop-in replacement capability with
+ library binary parity and exact matching with MySQL APIs and commands.
+ Therefore the plugin for MySQL and MariaDB are combined into one Qt plugin.
\section3 QMYSQL Stored Procedure Support
@@ -158,12 +164,13 @@
\section3 How to Build the QMYSQL Plugin on Unix and \macos
- You need the MySQL header files, as well as the shared library
- \c{libmysqlclient.so}. Depending on your Linux distribution, you may
- need to install a package which is usually called "mysql-devel".
+ You need the MySQL / MariaDB header files, as well as the shared library
+ \c{libmysqlclient.so} / \c{libmariadb.so}. Depending on your Linux distribution,
+ you may need to install a package which is usually called "mysql-devel"
+ or "mariadb-devel".
- Tell \l qmake where to find the MySQL header files and shared
- libraries (here it is assumed that MySQL is installed in
+ Tell \l qmake where to find the MySQL / MariaDB header files and shared
+ libraries (here it is assumed that MySQL / MariaDB is installed in
\c{/usr/local}) and run \c{make}:
\snippet code/doc_src_sql-driver.qdoc 3
@@ -171,7 +178,8 @@
\section3 How to Build the QMYSQL Plugin on Windows
You need to get the MySQL installation files (e.g.
- \l {https://dev.mysql.com/downloads/installer/}{mysql-installer-web-community-8.0.18.0.msi}).
+ \l {https://dev.mysql.com/downloads/installer/}{mysql-installer-web-community-8.0.18.0.msi}) or
+ \l {https://downloads.mariadb.org/connector-c/3.1.5/}{mariadb-connector-c-3.1.5-win64.msi}.
Run the installer,
select custom installation and install the MySQL C Connector
which matches your Qt installation (x86 or x64).
@@ -181,6 +189,12 @@
\li \c {<MySQL dir>/lib/libmysql.dll}
\li \c {<MySQL dir>/include/mysql.h}
\endlist
+ and for MariaDB
+ \list
+ \li \c {<MariaDB dir>/lib/libmariadb.lib}
+ \li \c {<MariaDB dir>/lib/libmariadb.dll}
+ \li \c {<MariaDB dir>/include/mysql.h}
+ \endlist
Build the plugin as follows (here it is assumed that the MySQL
C Connector is installed in
@@ -191,7 +205,7 @@
If you are not using a Microsoft compiler, replace \c nmake with \c
mingw32-make in the line above.
- When you distribute your application, remember to include libmysql.dll
+ When you distribute your application, remember to include libmysql.dll / libmariadb.dll
in your installation package. It must be placed in the same folder
as the application executable. \e libmysql.dll additionally needs the
MSVC runtime libraries which can be installed with vcredist.exe
diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp
index 01726d79ef..32338c1fe2 100644
--- a/src/sql/kernel/qsqldatabase.cpp
+++ b/src/sql/kernel/qsqldatabase.cpp
@@ -84,7 +84,7 @@ Q_GLOBAL_STATIC(QConnectionDict, dbDict)
class QSqlDatabasePrivate
{
public:
- QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = 0):
+ QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = nullptr):
ref(1),
q(d),
driver(dr),
@@ -178,7 +178,7 @@ DriverDict &QSqlDatabasePrivate::driverDict()
QSqlDatabasePrivate *QSqlDatabasePrivate::shared_null()
{
static QSqlNullDriver dr;
- static QSqlDatabasePrivate n(NULL, &dr);
+ static QSqlDatabasePrivate n(nullptr, &dr);
return &n;
}
@@ -702,7 +702,7 @@ void QSqlDatabasePrivate::init(const QString &type)
qWarning("QSqlDatabase: %s driver not loaded", type.toLatin1().data());
qWarning("QSqlDatabase: available drivers: %s",
QSqlDatabase::drivers().join(QLatin1Char(' ')).toLatin1().data());
- if (QCoreApplication::instance() == 0)
+ if (QCoreApplication::instance() == nullptr)
qWarning("QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins");
driver = shared_null()->driver;
}
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp
index 7f7b81b05b..fcd3c70a04 100644
--- a/src/sql/kernel/qsqldriver.cpp
+++ b/src/sql/kernel/qsqldriver.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
static QString prepareIdentifier(const QString &identifier,
QSqlDriver::IdentifierType type, const QSqlDriver *driver)
{
- Q_ASSERT( driver != NULL );
+ Q_ASSERT( driver != nullptr );
QString ret = identifier;
if (!driver->isIdentifierEscaped(identifier, type)) {
ret = driver->escapeIdentifier(identifier, type);
@@ -110,6 +110,9 @@ QSqlDriver::~QSqlDriver()
that the driver subscribes to. \a name identifies the event notification.
\sa subscribeToNotification()
+
+ \obsolete use QSqlDriver::notification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload)
+ instead
*/
/*!
diff --git a/src/sql/kernel/qsqldriver.h b/src/sql/kernel/qsqldriver.h
index 1e03be48d3..ca9f7dc51e 100644
--- a/src/sql/kernel/qsqldriver.h
+++ b/src/sql/kernel/qsqldriver.h
@@ -135,7 +135,10 @@ public Q_SLOTS:
virtual bool cancelQuery();
Q_SIGNALS:
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_X("Use the 3-args version of notification() instead.")
void notification(const QString &name);
+#endif
void notification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload);
protected:
diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp
index 34be010474..20adec6a3b 100644
--- a/src/sql/models/qsqlrelationaltablemodel.cpp
+++ b/src/sql/models/qsqlrelationaltablemodel.cpp
@@ -137,7 +137,7 @@ class QRelatedTableModel;
struct QRelation
{
public:
- QRelation(): model(0), m_parent(0), m_dictInitialized(false) {}
+ QRelation(): model(nullptr), m_parent(nullptr), m_dictInitialized(false) {}
void init(QSqlRelationalTableModel *parent, const QSqlRelation &relation);
void populateModel();
@@ -161,7 +161,7 @@ struct QRelation
class QRelatedTableModel : public QSqlTableModel
{
public:
- QRelatedTableModel(QRelation *rel, QObject *parent = 0, QSqlDatabase db = QSqlDatabase());
+ QRelatedTableModel(QRelation *rel, QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase());
bool select() override;
private:
bool firstSelect;
@@ -174,7 +174,7 @@ private:
*/
void QRelation::init(QSqlRelationalTableModel *parent, const QSqlRelation &relation)
{
- Q_ASSERT(parent != NULL);
+ Q_ASSERT(parent != nullptr);
m_parent = parent;
rel = relation;
}
@@ -183,7 +183,7 @@ void QRelation::populateModel()
{
if (!isValid())
return;
- Q_ASSERT(m_parent != NULL);
+ Q_ASSERT(m_parent != nullptr);
if (!model) {
model = new QRelatedTableModel(this, m_parent, m_parent->database());
@@ -202,7 +202,7 @@ void QRelation::populateDictionary()
if (!isValid())
return;
- if (model == NULL)
+ if (model == nullptr)
populateModel();
QSqlRecord record;
@@ -234,13 +234,13 @@ void QRelation::clearDictionary()
void QRelation::clear()
{
delete model;
- model = 0;
+ model = nullptr;
clearDictionary();
}
bool QRelation::isValid()
{
- return (rel.isValid() && m_parent != NULL);
+ return (rel.isValid() && m_parent != nullptr);
}
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index 4bc9a8c2f8..4b29492134 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -1305,7 +1305,7 @@ Qt::ItemFlags QSqlTableModel::flags(const QModelIndex &index) const
Q_D(const QSqlTableModel);
if (index.internalPointer() || index.column() < 0 || index.column() >= d->rec.count()
|| index.row() < 0)
- return 0;
+ return { };
bool editable = true;
@@ -1369,7 +1369,7 @@ QSqlRecord QSqlTableModel::record(int row) const
// get generated flags from the cache
const QSqlTableModelPrivate::ModifiedRow mrow = d->cache.value(row);
if (mrow.op() != QSqlTableModelPrivate::None) {
- const QSqlRecord crec = mrow.rec();
+ const QSqlRecord &crec = mrow.rec();
for (int i = 0, cnt = rec.count(); i < cnt; ++i)
rec.setGenerated(i, crec.isGenerated(i));
}