QSqlError: Set error code for psql-driver.

Task-number: QTBUG-142
Change-Id: I4a68da595b7c8869188225958eaa88f789d4c3bf
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This commit is contained in:
Marcel Krems 2013-02-12 05:13:21 +01:00 committed by The Qt Project
parent 106316198d
commit 14170bbf09

View File

@ -224,11 +224,12 @@ static QSqlError qMakeError(const QString& err, QSqlError::ErrorType type,
{
const char *s = PQerrorMessage(p->connection);
QString msg = p->isUtf8 ? QString::fromUtf8(s) : QString::fromLocal8Bit(s);
QString errorCode;
if (result) {
const char *sCode = PQresultErrorField(result, PG_DIAG_SQLSTATE);
msg += QString::fromLatin1("(%1)").arg(QString::fromLatin1(sCode));
errorCode = QString::fromLatin1(PQresultErrorField(result, PG_DIAG_SQLSTATE));
msg += QString::fromLatin1("(%1)").arg(errorCode);
}
return QSqlError(QLatin1String("QPSQL: ") + err, msg, type);
return QSqlError(QLatin1String("QPSQL: ") + err, msg, type, errorCode);
}
bool QPSQLResultPrivate::processResults()