drop revert of the PostgreSQL driver patch (fixed in Akonadi 1.10.3)

This commit is contained in:
Dan Vrátil 2013-10-07 15:02:39 +02:00
parent 58e8365063
commit 4c6ad9a444
2 changed files with 4 additions and 121 deletions

View File

@ -1,115 +0,0 @@
From 8053ae4030b4342f73a08b9870ccd19189ae401d Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Thu, 7 Mar 2013 11:52:52 +0100
Subject: [PATCH 4/4] postgresql driver: escape backslashes only when server
requires it
Task-number: QTBUG-30076
Change-Id: I408cda941884f01484d0edfa82c91fc19cb8718c
Reviewed-by: Israel Lins Albuquerque <israelins85@yahoo.com.br>
Reviewed-by: Sergey Blagodarin
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Andras Mantia <andras@kdab.com>
(cherry picked from qtbase/e3c5351d06ce8a12f035cd0627356bc64d8c334a)
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
---
src/sql/drivers/psql/qsql_psql.cpp | 38 +++++++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index 51ddce0..c2a127c 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -120,7 +120,16 @@ inline void qPQfreemem(void *buffer)
class QPSQLDriverPrivate
{
public:
- QPSQLDriverPrivate(QPSQLDriver *qq) : q(qq), connection(0), isUtf8(false), pro(QPSQLDriver::Version6), sn(0), pendingNotifyCheck(false) {}
+ QPSQLDriverPrivate(QPSQLDriver *qq)
+ : q(qq),
+ connection(0),
+ isUtf8(false),
+ pro(QPSQLDriver::Version6),
+ sn(0),
+ pendingNotifyCheck(false),
+ hasBackslashEscape(false)
+ { }
+
QPSQLDriver *q;
PGconn *connection;
bool isUtf8;
@@ -128,6 +137,7 @@ public:
QSocketNotifier *sn;
QStringList seid;
mutable bool pendingNotifyCheck;
+ bool hasBackslashEscape;
void appendTables(QStringList &tl, QSqlQuery &t, QChar type);
PGresult * exec(const char * stmt) const;
@@ -135,6 +145,7 @@ public:
QPSQLDriver::Protocol getPSQLVersion();
bool setEncodingUtf8();
void setDatestyle();
+ void detectBackslashEscape();
};
void QPSQLDriverPrivate::appendTables(QStringList &tl, QSqlQuery &t, QChar type)
@@ -636,6 +647,23 @@ void QPSQLDriverPrivate::setDatestyle()
PQclear(result);
}
+void QPSQLDriverPrivate::detectBackslashEscape()
+{
+ // standard_conforming_strings option introduced in 8.2
+ // http://www.postgresql.org/docs/8.2/static/runtime-config-compatible.html
+ if (pro < QPSQLDriver::Version82) {
+ hasBackslashEscape = true;
+ } else {
+ hasBackslashEscape = false;
+ PGresult* result = exec(QLatin1String("SELECT '\\\\' x"));
+ int status = PQresultStatus(result);
+ if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK)
+ if (QString::fromLatin1(PQgetvalue(result, 0, 0)) == QLatin1String("\\"))
+ hasBackslashEscape = true;
+ PQclear(result);
+ }
+}
+
static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin)
{
switch (vMaj) {
@@ -742,6 +770,7 @@ QPSQLDriver::QPSQLDriver(PGconn *conn, QObject *parent)
d->connection = conn;
if (conn) {
d->pro = d->getPSQLVersion();
+ d->detectBackslashEscape();
setOpen(true);
setOpenError(false);
}
@@ -842,6 +871,7 @@ bool QPSQLDriver::open(const QString & db,
}
d->pro = d->getPSQLVersion();
+ d->detectBackslashEscape();
d->isUtf8 = d->setEncodingUtf8();
d->setDatestyle();
@@ -1228,12 +1258,10 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
}
break;
case QVariant::String:
- {
- // Escape '\' characters
r = QSqlDriver::formatValue(field, trimStrings);
- r.replace(QLatin1String("\\"), QLatin1String("\\\\"));
+ if (d->hasBackslashEscape)
+ r.replace(QLatin1String("\\"), QLatin1String("\\\\"));
break;
- }
case QVariant::Bool:
if (field.value().toBool())
r = QLatin1String("TRUE");
--
1.8.3.1

10
qt.spec
View File

@ -29,7 +29,7 @@ Summary: Qt toolkit
Name: qt
Epoch: 1
Version: 4.8.5
Release: 9%{?dist}
Release: 10%{?dist}
# See LGPL_EXCEPTIONS.txt, LICENSE.GPL3, respectively, for exception details
License: (LGPLv2 with exceptions or GPLv3 with exceptions) and ASL 2.0 and BSD and FTL and MIT
@ -142,10 +142,6 @@ Patch83: qt-4.8-poll.patch
# upstream patches
# http://codereview.qt-project.org/#change,22006
Patch100: qt-everywhere-opensource-src-4.8.1-qtgahandle.patch
# REVERT fix for https://bugreports.qt-project.org/browse/QTBUG-30076
# (hopefully just a short-term fix/hack until there's something better)
# regresses/changes postgresql driver behavior
Patch101: qt-everywhere-opensource-src-4.8.5-QTBUG-30076.patch
# backported from Qt5 (essentially)
# http://bugzilla.redhat.com/702493
# https://bugreports.qt-project.org/browse/QTBUG-5545
@ -520,7 +516,6 @@ rm -fv mkspecs/linux-g++*/qmake.conf.multilib-optflags
# upstream patches
%patch100 -p1 -b .QTgaHandler
%patch101 -p1 -R -b .QTBUG-30076
%patch102 -p1 -b .qgtkstyle_disable_gtk_theme_check
%patch103 -p1 -R -b .QTBUG-15319
%patch113 -p1 -b .QTBUG-22829
@ -1218,6 +1213,9 @@ fi
%changelog
* Mon Oct 07 2013 Daniel Vrátil <dvratil@redhat.com> 4.8.5-10
- drop revert of the PostgreSQL driver patch (fixed in Akonadi 1.10.3)
* Thu Oct 03 2013 Rex Dieter <rdieter@fedoraproject.org> 4.8.5-9
- rework %%_bindir %%_qt4_bindir links to be more qtchooser friendly