summaryrefslogtreecommitdiffstats
path: root/src/sql/drivers/psql
diff options
context:
space:
mode:
authorBill King <bill.king@nokia.com>2009-07-08 22:41:01 (GMT)
committerBill King <bill.king@nokia.com>2009-07-08 22:41:01 (GMT)
commit7b980974b14d246f60d824bab4e069ac8cc2da29 (patch)
tree68f0d1667760a0e7e27d57fc76c0434dc028502c /src/sql/drivers/psql
parentcfacb284593008094136905a2497843a4bbac639 (diff)
parent48f049d6fbddd60d99fb6ebc15fd5b52a3b515ec (diff)
downloadQt-7b980974b14d246f60d824bab4e069ac8cc2da29.zip
Qt-7b980974b14d246f60d824bab4e069ac8cc2da29.tar.gz
Qt-7b980974b14d246f60d824bab4e069ac8cc2da29.tar.bz2
Merge commit 'origin/4.5'
Conflicts: src/sql/drivers/ibase/qsql_ibase.cpp tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp tests/auto/qsqldatabase/tst_databases.h tests/auto/qsqldatabase/tst_qsqldatabase.cpp translations/qt_ru.ts
Diffstat (limited to 'src/sql/drivers/psql')
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index 0c92013..bd93a9a 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -54,11 +54,25 @@
#include <qstringlist.h>
#include <qmutex.h>
+
#include <libpq-fe.h>
#include <pg_config.h>
#include <stdlib.h>
+#if defined(_MSC_VER)
+#include <float.h>
+#define isnan(x) _isnan(x)
+int isinf(double x)
+{
+ if(_fpclass(x) == _FPCLASS_NINF)
+ return -1;
+ else if(_fpclass(x) == _FPCLASS_PINF)
+ return 1;
+ else return 0;
+}
+#else
#include <math.h>
+#endif
// workaround for postgres defining their OIDs in a private header file
#define QBOOLOID 16
@@ -1161,6 +1175,21 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
qPQfreemem(data);
break;
}
+ case QVariant::Double: {
+ double val = field.value().toDouble();
+ if (isnan(val))
+ r = QLatin1String("'NaN'");
+ else {
+ int res = isinf(val);
+ if (res == 1)
+ r = QLatin1String("'Infinity'");
+ else if (res == -1)
+ r = QLatin1String("'-Infinity'");
+ else
+ r = QSqlDriver::formatValue(field, trimStrings);
+ }
+ break;
+ }
default:
r = QSqlDriver::formatValue(field, trimStrings);
break;
@@ -1265,15 +1294,15 @@ QStringList QPSQLDriver::subscribedToNotificationsImplementation() const
void QPSQLDriver::_q_handleNotification(int)
{
PQconsumeInput(d->connection);
- PGnotify *notify = PQnotifies(d->connection);
- if (notify) {
- QString name(QLatin1String(notify->relname));
+ PGnotify *notify = 0;
+ while((notify = PQnotifies(d->connection)) != 0) {
+ QString name(QLatin1String(notify->relname));
if (d->seid.contains(name))
emit notification(name);
else
qWarning("QPSQLDriver: received notification for '%s' which isn't subscribed to.",
- qPrintable(name));
+ qPrintable(name));
qPQfreemem(notify);
}