From e6857b7ebccc6d7fbd5c77acbd3b0f33132bc068 Mon Sep 17 00:00:00 2001 From: Marcel Krems Date: Tue, 17 Jun 2014 12:40:31 +0200 Subject: Updated QSql{Query,Result}::bindValue doc to reflect the current state. Since 5.0 it is possible to use one call to bindValue to bind values to multiple placeholders with the same name. Task-number: QTBUG-23360 Change-Id: Ic838150d25dd07bca7bc9e5d91ab3362a73833d6 Reviewed-by: Matt Newell Reviewed-by: Mark Brand --- src/sql/kernel/qsqlquery.cpp | 6 ------ src/sql/kernel/qsqlresult.cpp | 6 ------ 2 files changed, 12 deletions(-) (limited to 'src/sql') diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp index 6b13eb02ed..b98e2baf1e 100644 --- a/src/sql/kernel/qsqlquery.cpp +++ b/src/sql/kernel/qsqlquery.cpp @@ -1063,12 +1063,6 @@ bool QSqlQuery::execBatch(BatchExecutionMode mode) To bind a NULL value, use a null QVariant; for example, use \c {QVariant(QVariant::String)} if you are binding a string. - Values cannot be bound to multiple locations in the query, eg: - \code - INSERT INTO testtable (id, name, samename) VALUES (:id, :name, :name) - \endcode - Binding to name will bind to the first :name, but not the second. - \sa addBindValue(), prepare(), exec(), boundValue(), boundValues() */ void QSqlQuery::bindValue(const QString& placeholder, const QVariant& val, diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index 09b8f8d889..f933e6eeb1 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -704,12 +704,6 @@ void QSqlResult::bindValue(int index, const QVariant& val, QSql::ParamType param Binds the value \a val of parameter type \a paramType to the \a placeholder name in the current record (row). - Values cannot be bound to multiple locations in the query, eg: - \code - INSERT INTO testtable (id, name, samename) VALUES (:id, :name, :name) - \endcode - Binding to name will bind to the first :name, but not the second. - \note Binding an undefined placeholder will result in undefined behavior. \sa QSqlQuery::bindValue() -- cgit v1.2.3 From 507fff201bcafc1c28397e7008d8fbfe4c6ffb38 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 25 Aug 2014 13:53:44 +0200 Subject: qsql ibase: fix memory corruption due to LONG being 4 bytes in firebird. As fb_types.h says, Firebird requires (S)LONG to be 32 bit, and it defines SLONG to int. This leads to sqllen being 4, so qsql_ibase.cpp allocates 4 bytes... and was writing 8 bytes into it. Fixed by checking sqllen, the same way QIBaseResult::gotoNext does. Change-Id: Ie8680d32f98c354dfc8430b8efbfe95450556956 Reviewed-by: Mark Brand --- src/sql/drivers/ibase/qsql_ibase.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/sql') diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index cc26bfe7e8..c751fea825 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -1030,11 +1030,15 @@ bool QIBaseResult::exec() *((qint64*)d->inda->sqlvar[para].sqldata) = val.toLongLong(); break; case SQL_LONG: - if (d->inda->sqlvar[para].sqlscale < 0) - *((long*)d->inda->sqlvar[para].sqldata) = - (long)floor(0.5 + val.toDouble() * pow(10.0, d->inda->sqlvar[para].sqlscale * -1)); - else - *((long*)d->inda->sqlvar[para].sqldata) = (long)val.toLongLong(); + if (d->inda->sqlvar[para].sqllen == 4) { + if (d->inda->sqlvar[para].sqlscale < 0) + *((qint32*)d->inda->sqlvar[para].sqldata) = + (qint32)floor(0.5 + val.toDouble() * pow(10.0, d->inda->sqlvar[para].sqlscale * -1)); + else + *((qint32*)d->inda->sqlvar[para].sqldata) = (qint32)val.toInt(); + } else { + *((qint64*)d->inda->sqlvar[para].sqldata) = val.toLongLong(); + } break; case SQL_SHORT: if (d->inda->sqlvar[para].sqlscale < 0) -- cgit v1.2.3