summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.cpp6
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.h7
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp2
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.h3
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp2
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.h3
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp6
-rw-r--r--src/sql/drivers/psql/qsql_psql.h9
-rw-r--r--src/sql/kernel/qsqldriver.cpp200
-rw-r--r--src/sql/kernel/qsqldriver.h17
10 files changed, 48 insertions, 207 deletions
diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp
index 1109dfd62a..0da7f05cbf 100644
--- a/src/sql/drivers/ibase/qsql_ibase.cpp
+++ b/src/sql/drivers/ibase/qsql_ibase.cpp
@@ -1749,7 +1749,7 @@ static isc_callback qEventCallback(char *result, short length, char *updated)
return 0;
}
-bool QIBaseDriver::subscribeToNotificationImplementation(const QString &name)
+bool QIBaseDriver::subscribeToNotification(const QString &name)
{
if (!isOpen()) {
qWarning("QIBaseDriver::subscribeFromNotificationImplementation: database not open.");
@@ -1798,7 +1798,7 @@ bool QIBaseDriver::subscribeToNotificationImplementation(const QString &name)
return true;
}
-bool QIBaseDriver::unsubscribeFromNotificationImplementation(const QString &name)
+bool QIBaseDriver::unsubscribeFromNotification(const QString &name)
{
if (!isOpen()) {
qWarning("QIBaseDriver::unsubscribeFromNotificationImplementation: database not open.");
@@ -1827,7 +1827,7 @@ bool QIBaseDriver::unsubscribeFromNotificationImplementation(const QString &name
return true;
}
-QStringList QIBaseDriver::subscribedToNotificationsImplementation() const
+QStringList QIBaseDriver::subscribedToNotifications() const
{
return QStringList(d->eventBuffers.keys());
}
diff --git a/src/sql/drivers/ibase/qsql_ibase.h b/src/sql/drivers/ibase/qsql_ibase.h
index cda9112d7c..2cdf91f469 100644
--- a/src/sql/drivers/ibase/qsql_ibase.h
+++ b/src/sql/drivers/ibase/qsql_ibase.h
@@ -113,10 +113,9 @@ public:
QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
-protected Q_SLOTS:
- bool subscribeToNotificationImplementation(const QString &name);
- bool unsubscribeFromNotificationImplementation(const QString &name);
- QStringList subscribedToNotificationsImplementation() const;
+ bool subscribeToNotification(const QString &name);
+ bool unsubscribeFromNotification(const QString &name);
+ QStringList subscribedToNotifications() const;
private Q_SLOTS:
void qHandleEventNotification(void* updatedResultBuffer);
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index 3048748a20..8a5e0bb34b 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -1534,7 +1534,7 @@ QString QMYSQLDriver::escapeIdentifier(const QString &identifier, IdentifierType
return res;
}
-bool QMYSQLDriver::isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const
+bool QMYSQLDriver::isIdentifierEscaped(const QString &identifier, IdentifierType type) const
{
Q_UNUSED(type);
return identifier.size() > 2
diff --git a/src/sql/drivers/mysql/qsql_mysql.h b/src/sql/drivers/mysql/qsql_mysql.h
index 01f4a52cd2..dc4adf74e1 100644
--- a/src/sql/drivers/mysql/qsql_mysql.h
+++ b/src/sql/drivers/mysql/qsql_mysql.h
@@ -124,8 +124,7 @@ public:
QVariant handle() const;
QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
-protected Q_SLOTS:
- bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const;
+ bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const;
protected:
bool beginTransaction();
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index 40cd2e6f75..4c57674930 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -2540,7 +2540,7 @@ QString QODBCDriver::escapeIdentifier(const QString &identifier, IdentifierType)
return res;
}
-bool QODBCDriver::isIdentifierEscapedImplementation(const QString &identifier, IdentifierType) const
+bool QODBCDriver::isIdentifierEscaped(const QString &identifier, IdentifierType) const
{
QChar quote = d->quoteChar();
return identifier.size() > 2
diff --git a/src/sql/drivers/odbc/qsql_odbc.h b/src/sql/drivers/odbc/qsql_odbc.h
index 0741ad4491..a89ce0f9b3 100644
--- a/src/sql/drivers/odbc/qsql_odbc.h
+++ b/src/sql/drivers/odbc/qsql_odbc.h
@@ -135,8 +135,7 @@ public:
QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
-protected Q_SLOTS:
- bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const;
+ bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const;
protected:
bool beginTransaction();
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index ec31d54f0f..edeb5d1542 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -1283,7 +1283,7 @@ QPSQLDriver::Protocol QPSQLDriver::protocol() const
return d->pro;
}
-bool QPSQLDriver::subscribeToNotificationImplementation(const QString &name)
+bool QPSQLDriver::subscribeToNotification(const QString &name)
{
if (!isOpen()) {
qWarning("QPSQLDriver::subscribeToNotificationImplementation: database not open.");
@@ -1317,7 +1317,7 @@ bool QPSQLDriver::subscribeToNotificationImplementation(const QString &name)
return true;
}
-bool QPSQLDriver::unsubscribeFromNotificationImplementation(const QString &name)
+bool QPSQLDriver::unsubscribeFromNotification(const QString &name)
{
if (!isOpen()) {
qWarning("QPSQLDriver::unsubscribeFromNotificationImplementation: database not open.");
@@ -1350,7 +1350,7 @@ bool QPSQLDriver::unsubscribeFromNotificationImplementation(const QString &name)
return true;
}
-QStringList QPSQLDriver::subscribedToNotificationsImplementation() const
+QStringList QPSQLDriver::subscribedToNotifications() const
{
return d->seid;
}
diff --git a/src/sql/drivers/psql/qsql_psql.h b/src/sql/drivers/psql/qsql_psql.h
index 94871b4c99..204a8a9105 100644
--- a/src/sql/drivers/psql/qsql_psql.h
+++ b/src/sql/drivers/psql/qsql_psql.h
@@ -134,16 +134,15 @@ public:
QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
QString formatValue(const QSqlField &field, bool trimStrings) const;
+ bool subscribeToNotification(const QString &name);
+ bool unsubscribeFromNotification(const QString &name);
+ QStringList subscribedToNotifications() const;
+
protected:
bool beginTransaction();
bool commitTransaction();
bool rollbackTransaction();
-protected Q_SLOTS:
- bool subscribeToNotificationImplementation(const QString &name);
- bool unsubscribeFromNotificationImplementation(const QString &name);
- QStringList subscribedToNotificationsImplementation() const;
-
private Q_SLOTS:
void _q_handleNotification(int);
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp
index 7e6a7f7386..28847325d9 100644
--- a/src/sql/kernel/qsqldriver.cpp
+++ b/src/sql/kernel/qsqldriver.cpp
@@ -417,22 +417,17 @@ QString QSqlDriver::escapeIdentifier(const QString &identifier, IdentifierType)
\a identifier can either be a table name or field name, dependent
on \a type.
- \warning Because of binary compatibility constraints, this function is not virtual.
- If you want to provide your own implementation in your QSqlDriver subclass,
- reimplement the isIdentifierEscapedImplementation() slot in your subclass instead.
- The isIdentifierEscapedFunction() will dynamically detect the slot and call it.
+ Reimplement this function if you want to provide your own implementation in your
+ QSqlDriver subclass,
\sa stripDelimiters(), escapeIdentifier()
*/
bool QSqlDriver::isIdentifierEscaped(const QString &identifier, IdentifierType type) const
{
- bool result;
- QMetaObject::invokeMethod(const_cast<QSqlDriver*>(this),
- "isIdentifierEscapedImplementation", Qt::DirectConnection,
- Q_RETURN_ARG(bool, result),
- Q_ARG(QString, identifier),
- Q_ARG(IdentifierType, type));
- return result;
+ Q_UNUSED(type);
+ return identifier.size() > 2
+ && identifier.startsWith(QLatin1Char('"')) //left delimited
+ && identifier.endsWith(QLatin1Char('"')); //right delimited
}
/*!
@@ -442,23 +437,22 @@ bool QSqlDriver::isIdentifierEscaped(const QString &identifier, IdentifierType t
and trailing delimiter characters, \a identifier is returned without
modification.
- \warning Because of binary compatibility constraints, this function is not virtual,
- If you want to provide your own implementation in your QSqlDriver subclass,
- reimplement the stripDelimitersImplementation() slot in your subclass instead.
- The stripDelimiters() function will dynamically detect the slot and call it.
+ Reimplement this function if you want to provide your own implementation in your
+ QSqlDriver subclass,
\since 4.5
\sa isIdentifierEscaped()
*/
QString QSqlDriver::stripDelimiters(const QString &identifier, IdentifierType type) const
{
- QString result;
- QMetaObject::invokeMethod(const_cast<QSqlDriver*>(this),
- "stripDelimitersImplementation", Qt::DirectConnection,
- Q_RETURN_ARG(QString, result),
- Q_ARG(QString, identifier),
- Q_ARG(IdentifierType, type));
- return result;
+ QString ret;
+ if (isIdentifierEscaped(identifier, type)) {
+ ret = identifier.mid(1);
+ ret.chop(1);
+ } else {
+ ret = identifier;
+ }
+ return ret;
}
/*!
@@ -744,22 +738,16 @@ QVariant QSqlDriver::handle() const
When an event notification identified by \a name is posted by the database the
notification() signal is emitted.
- \warning Because of binary compatibility constraints, this function is not virtual.
- If you want to provide event notification support in your own QSqlDriver subclass,
- reimplement the subscribeToNotificationImplementation() slot in your subclass instead.
- The subscribeToNotification() function will dynamically detect the slot and call it.
+ Reimplement this function if you want to provide event notification support in your
+ own QSqlDriver subclass,
\since 4.4
\sa unsubscribeFromNotification() subscribedToNotifications() QSqlDriver::hasFeature()
*/
bool QSqlDriver::subscribeToNotification(const QString &name)
{
- bool result;
- QMetaObject::invokeMethod(const_cast<QSqlDriver *>(this),
- "subscribeToNotificationImplementation", Qt::DirectConnection,
- Q_RETURN_ARG(bool, result),
- Q_ARG(QString, name));
- return result;
+ Q_UNUSED(name);
+ return false;
}
/*!
@@ -774,96 +762,14 @@ bool QSqlDriver::subscribeToNotification(const QString &name)
After calling \e this function the notification() signal will no longer be emitted
when an event notification identified by \a name is posted by the database.
- \warning Because of binary compatibility constraints, this function is not virtual.
- If you want to provide event notification support in your own QSqlDriver subclass,
- reimplement the unsubscribeFromNotificationImplementation() slot in your subclass instead.
- The unsubscribeFromNotification() function will dynamically detect the slot and call it.
+ Reimplement this function if you want to provide event notification support in your
+ own QSqlDriver subclass,
\since 4.4
\sa subscribeToNotification() subscribedToNotifications()
*/
bool QSqlDriver::unsubscribeFromNotification(const QString &name)
{
- bool result;
- QMetaObject::invokeMethod(const_cast<QSqlDriver *>(this),
- "unsubscribeFromNotificationImplementation", Qt::DirectConnection,
- Q_RETURN_ARG(bool, result),
- Q_ARG(QString, name));
- return result;
-}
-
-/*!
- Returns a list of the names of the event notifications that are currently subscribed to.
-
- \warning Because of binary compatibility constraints, this function is not virtual.
- If you want to provide event notification support in your own QSqlDriver subclass,
- reimplement the subscribedToNotificationsImplementation() slot in your subclass instead.
- The subscribedToNotifications() function will dynamically detect the slot and call it.
-
- \since 4.4
- \sa subscribeToNotification() unsubscribeFromNotification()
-*/
-QStringList QSqlDriver::subscribedToNotifications() const
-{
- QStringList result;
- QMetaObject::invokeMethod(const_cast<QSqlDriver *>(this),
- "subscribedToNotificationsImplementation", Qt::DirectConnection,
- Q_RETURN_ARG(QStringList, result));
- return result;
-}
-
-/*!
- This slot is called to subscribe to event notifications from the database.
- \a name identifies the event notification.
-
- If successful, return true, otherwise return false.
-
- The database must be open when this \e slot is called. When the database is closed
- by calling close() all subscribed event notifications are automatically unsubscribed.
- Note that calling open() on an already open database may implicitly cause close() to
- be called, which will cause the driver to unsubscribe from all event notifications.
-
- When an event notification identified by \a name is posted by the database the
- notification() signal is emitted.
-
- Reimplement this slot to provide your own QSqlDriver subclass with event notification
- support; because of binary compatibility constraints, the subscribeToNotification()
- function (introduced in Qt 4.4) is not virtual. Instead, subscribeToNotification()
- will dynamically detect and call \e this slot. The default implementation does nothing
- and returns false.
-
- \since 4.4
- \sa subscribeToNotification()
-*/
-bool QSqlDriver::subscribeToNotificationImplementation(const QString &name)
-{
- Q_UNUSED(name);
- return false;
-}
-
-/*!
- This slot is called to unsubscribe from event notifications from the database.
- \a name identifies the event notification.
-
- If successful, return true, otherwise return false.
-
- The database must be open when \e this slot is called. All subscribed event
- notifications are automatically unsubscribed from when the close() function is called.
-
- After calling \e this slot the notification() signal will no longer be emitted
- when an event notification identified by \a name is posted by the database.
-
- Reimplement this slot to provide your own QSqlDriver subclass with event notification
- support; because of binary compatibility constraints, the unsubscribeFromNotification()
- function (introduced in Qt 4.4) is not virtual. Instead, unsubscribeFromNotification()
- will dynamically detect and call \e this slot. The default implementation does nothing
- and returns false.
-
- \since 4.4
- \sa unsubscribeFromNotification()
-*/
-bool QSqlDriver::unsubscribeFromNotificationImplementation(const QString &name)
-{
Q_UNUSED(name);
return false;
}
@@ -871,16 +777,13 @@ bool QSqlDriver::unsubscribeFromNotificationImplementation(const QString &name)
/*!
Returns a list of the names of the event notifications that are currently subscribed to.
- Reimplement this slot to provide your own QSqlDriver subclass with event notification
- support; because of binary compatibility constraints, the subscribedToNotifications()
- function (introduced in Qt 4.4) is not virtual. Instead, subscribedToNotifications()
- will dynamically detect and call \e this slot. The default implementation simply
- returns an empty QStringList.
+ Reimplement this function if you want to provide event notification support in your
+ own QSqlDriver subclass,
\since 4.4
- \sa subscribedToNotifications()
+ \sa subscribeToNotification() unsubscribeFromNotification()
*/
-QStringList QSqlDriver::subscribedToNotificationsImplementation() const
+QStringList QSqlDriver::subscribedToNotifications() const
{
return QStringList();
}
@@ -888,57 +791,6 @@ QStringList QSqlDriver::subscribedToNotificationsImplementation() const
/*!
\since 4.6
- This slot returns whether \a identifier is escaped according to the database rules.
- \a identifier can either be a table name or field name, dependent
- on \a type.
-
- Because of binary compatibility constraints, isIdentifierEscaped() function
- (introduced in Qt 4.5) is not virtual. Instead, isIdentifierEscaped() will
- dynamically detect and call \e this slot. The default implementation
- assumes the escape/delimiter character is a double quote. Reimplement this
- slot in your own QSqlDriver if your database engine uses a different
- delimiter character.
-
- \sa isIdentifierEscaped()
- */
-bool QSqlDriver::isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const
-{
- Q_UNUSED(type);
- return identifier.size() > 2
- && identifier.startsWith(QLatin1Char('"')) //left delimited
- && identifier.endsWith(QLatin1Char('"')); //right delimited
-}
-
-/*!
- \since 4.6
-
- This slot returns \a identifier with the leading and trailing delimiters removed,
- \a identifier can either be a tablename or field name, dependent on \a type.
- If \a identifier does not have leading and trailing delimiter characters, \a
- identifier is returned without modification.
-
- Because of binary compatibility constraints, the stripDelimiters() function
- (introduced in Qt 4.5) is not virtual. Instead, stripDelimiters() will
- dynamically detect and call \e this slot. It generally unnecessary
- to reimplement this slot.
-
- \sa stripDelimiters()
- */
-QString QSqlDriver::stripDelimitersImplementation(const QString &identifier, IdentifierType type) const
-{
- QString ret;
- if (this->isIdentifierEscaped(identifier, type)) {
- ret = identifier.mid(1);
- ret.chop(1);
- } else {
- ret = identifier;
- }
- return ret;
-}
-
-/*!
- \since 4.6
-
Sets the default numerical precision policy used by queries created
by this driver to \a precisionPolicy.
diff --git a/src/sql/kernel/qsqldriver.h b/src/sql/kernel/qsqldriver.h
index 5fd74411db..ff19d660da 100644
--- a/src/sql/kernel/qsqldriver.h
+++ b/src/sql/kernel/qsqldriver.h
@@ -110,12 +110,12 @@ public:
const QString& host = QString(),
int port = -1,
const QString& connOpts = QString()) = 0;
- bool subscribeToNotification(const QString &name); // ### Qt 5: make virtual
- bool unsubscribeFromNotification(const QString &name); // ### Qt 5: make virtual
- QStringList subscribedToNotifications() const; // ### Qt 5: make virtual
+ virtual bool subscribeToNotification(const QString &name);
+ virtual bool unsubscribeFromNotification(const QString &name);
+ virtual QStringList subscribedToNotifications() const;
- bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const; // ### Qt 5: make virtual
- QString stripDelimiters(const QString &identifier, IdentifierType type) const; // ### Qt 5: make virtual
+ virtual bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const;
+ virtual QString stripDelimiters(const QString &identifier, IdentifierType type) const;
void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy);
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const;
@@ -129,13 +129,6 @@ protected:
virtual void setOpenError(bool e);
virtual void setLastError(const QSqlError& e);
-protected Q_SLOTS:
- bool subscribeToNotificationImplementation(const QString &name); // ### Qt 5: eliminate, see subscribeToNotification()
- bool unsubscribeFromNotificationImplementation(const QString &name); // ### Qt 5: eliminate, see unsubscribeFromNotification()
- QStringList subscribedToNotificationsImplementation() const; // ### Qt 5: eliminate, see subscribedNotifications()
-
- bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const; // ### Qt 5: eliminate, see isIdentifierEscaped()
- QString stripDelimitersImplementation(const QString &identifier, IdentifierType type) const; // ### Qt 5: eliminate, see stripDelimiters()
private:
Q_DISABLE_COPY(QSqlDriver)