summaryrefslogtreecommitdiffstats
path: root/src/sql/drivers
diff options
context:
space:
mode:
authorBill King <bill.king@nokia.com>2009-04-29 03:42:38 (GMT)
committerBill King <bill.king@nokia.com>2009-04-29 03:45:33 (GMT)
commite378783811b2ace2379becefd1e479ce840f2850 (patch)
tree369fb21ce5716022124794cda1f2e7be9b11a4d4 /src/sql/drivers
parentbe7384d4a232fc057c7075131149f4cecd32ead2 (diff)
downloadQt-e378783811b2ace2379becefd1e479ce840f2850.zip
Qt-e378783811b2ace2379becefd1e479ce840f2850.tar.gz
Qt-e378783811b2ace2379becefd1e479ce840f2850.tar.bz2
Fixes performance degradation from precision fix in 4.5.1
Alleviates the performance hit of querying the database except when necessary, try and use XSQLVAR as much as possible, except for floating point fields. Task-number: 252426
Diffstat (limited to 'src/sql/drivers')
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp
index 0705722..9eeb41d 100644
--- a/src/sql/drivers/ibase/qsql_ibase.cpp
+++ b/src/sql/drivers/ibase/qsql_ibase.cpp
@@ -1270,27 +1270,27 @@ QSqlRecord QIBaseResult::record() const
v = d->sqlda->sqlvar[i];
QSqlField f(QString::fromLatin1(v.aliasname, v.aliasname_length).simplified(),
qIBaseTypeName2(v.sqltype, v.sqlscale < 0));
- QSqlQuery q(new QIBaseResult(d->db));
- q.setForwardOnly(true);
- q.exec(QLatin1String("select b.RDB$FIELD_PRECISION, b.RDB$FIELD_SCALE, b.RDB$FIELD_LENGTH, a.RDB$NULL_FLAG "
- "FROM RDB$RELATION_FIELDS a, RDB$FIELDS b "
- "WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE "
- "AND a.RDB$RELATION_NAME = '") + QString::fromAscii(v.relname, v.relname_length).toUpper() + QLatin1String("' "
- "AND a.RDB$FIELD_NAME = '") + QString::fromAscii(v.sqlname, v.sqlname_length).toUpper() + QLatin1String("' "));
- if(q.first()) {
- if(v.sqlscale < 0) {
- f.setLength(q.value(0).toInt());
- f.setPrecision(qAbs(q.value(1).toInt()));
- } else {
- f.setLength(q.value(2).toInt());
- f.setPrecision(0);
+ f.setLength(v.sqllen);
+ f.setPrecision(qAbs(v.sqlscale));
+ f.setRequiredStatus((v.sqltype & 1) == 0 ? QSqlField::Required : QSqlField::Optional);
+ if(v.sqlscale < 0) {
+ QSqlQuery q(new QIBaseResult(d->db));
+ q.setForwardOnly(true);
+ q.exec(QLatin1String("select b.RDB$FIELD_PRECISION, b.RDB$FIELD_SCALE, b.RDB$FIELD_LENGTH, a.RDB$NULL_FLAG "
+ "FROM RDB$RELATION_FIELDS a, RDB$FIELDS b "
+ "WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE "
+ "AND a.RDB$RELATION_NAME = '") + QString::fromAscii(v.relname, v.relname_length).toUpper() + QLatin1String("' "
+ "AND a.RDB$FIELD_NAME = '") + QString::fromAscii(v.sqlname, v.sqlname_length).toUpper() + QLatin1String("' "));
+ if(q.first()) {
+ if(v.sqlscale < 0) {
+ f.setLength(q.value(0).toInt());
+ f.setPrecision(qAbs(q.value(1).toInt()));
+ } else {
+ f.setLength(q.value(2).toInt());
+ f.setPrecision(0);
+ }
+ f.setRequiredStatus(q.value(3).toBool() ? QSqlField::Required : QSqlField::Optional);
}
- f.setRequiredStatus(q.value(3).toBool() ? QSqlField::Required : QSqlField::Optional);
- }
- else {
- f.setLength(0);
- f.setPrecision(0);
- f.setRequiredStatus(QSqlField::Unknown);
}
f.setSqlType(v.sqltype);
rec.append(f);