Use PG_VERSION if PG_MAJORVERSION is not defined
When only PG_VERSION was available for getting the client driver version for PostgreSQL it meant that it would not detect the client version and subsequently would not set the connection up correctly as a result. This fixes the blob test already in tst_qsqlquery. Change-Id: Ie2176a43b6be9c0e835498fca5aea129f0cc8fc6 Reviewed-by: Mark Brand <mabrand@mabrand.nl>bb10
parent
40474ceb11
commit
bc71836fc4
|
|
@ -695,25 +695,30 @@ QPSQLDriver::Protocol QPSQLDriverPrivate::getPSQLVersion()
|
|||
int vMaj = rx.cap(1).toInt();
|
||||
int vMin = rx.cap(2).toInt();
|
||||
serverVersion = qMakePSQLVersion(vMaj, vMin);
|
||||
#ifdef PG_MAJORVERSION
|
||||
if (rx.indexIn(QLatin1String(PG_MAJORVERSION)) != -1) {
|
||||
#if defined(PG_MAJORVERSION)
|
||||
if (rx.indexIn(QLatin1String(PG_MAJORVERSION)) != -1)
|
||||
#elif defined(PG_VERSION)
|
||||
if (rx.indexIn(QLatin1String(PG_VERSION)) != -1)
|
||||
#else
|
||||
if (0)
|
||||
#endif
|
||||
{
|
||||
vMaj = rx.cap(1).toInt();
|
||||
vMin = rx.cap(2).toInt();
|
||||
}
|
||||
QPSQLDriver::Protocol clientVersion = qMakePSQLVersion(vMaj, vMin);
|
||||
QPSQLDriver::Protocol clientVersion = qMakePSQLVersion(vMaj, vMin);
|
||||
|
||||
if (serverVersion >= QPSQLDriver::Version9 && clientVersion < QPSQLDriver::Version9) {
|
||||
//Client version before QPSQLDriver::Version9 only supports escape mode for bytea type,
|
||||
//but bytea format is set to hex by default in PSQL 9 and above. So need to force the
|
||||
//server use the old escape mode when connects to the new server with old client library.
|
||||
result = exec("SET bytea_output=escape; ");
|
||||
status = PQresultStatus(result);
|
||||
} else if (serverVersion == QPSQLDriver::VersionUnknown) {
|
||||
serverVersion = clientVersion;
|
||||
if (serverVersion != QPSQLDriver::VersionUnknown)
|
||||
qWarning("The server version of this PostgreSQL is unknown, falling back to the client version.");
|
||||
if (serverVersion >= QPSQLDriver::Version9 && clientVersion < QPSQLDriver::Version9) {
|
||||
//Client version before QPSQLDriver::Version9 only supports escape mode for bytea type,
|
||||
//but bytea format is set to hex by default in PSQL 9 and above. So need to force the
|
||||
//server use the old escape mode when connects to the new server with old client library.
|
||||
result = exec("SET bytea_output=escape; ");
|
||||
status = PQresultStatus(result);
|
||||
} else if (serverVersion == QPSQLDriver::VersionUnknown) {
|
||||
serverVersion = clientVersion;
|
||||
if (serverVersion != QPSQLDriver::VersionUnknown)
|
||||
qWarning("The server version of this PostgreSQL is unknown, falling back to the client version.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
PQclear(result);
|
||||
|
|
|
|||
Loading…
Reference in New Issue