Permalink
Browse files

Issue #21571: fail more elegantly with unsupported PostgreSQL versions

  • Loading branch information...
dpocock committed Sep 28, 2013
1 parent fb60fb8 commit 7892bbe30bf345b7f7d4de24afed3b342c7751b0
Showing with 44 additions and 0 deletions.
  1. +44 −0 common/login2.cpp
View
@@ -335,6 +335,50 @@ void login2::sLogin()
break; // break instead of for-loop condition to preserve methodidx
}
// Check that it is a supported PostgreSQL version
if (db.isOpen())
{
XSqlQuery checkVersion(QString("select (regexp_matches(setting, '^(\\d+.\\d+).\\d+'))[1] as version from pg_settings where name = 'server_version'"));
bool goodVersion = false;
// FIXME:
// - should store the range in some constants
// - when version numbers use extra digits (e.g v10.1), must use a
// version comparison algorithm
if(checkVersion.first())
{
if(!(checkVersion.value("version").toString() < "8.4" ||
checkVersion.value("version").toString() > "9.1"))
{
goodVersion = true;
}
}
if(!goodVersion)
{
if (_splash)
_splash->hide();
setCursor(QCursor(Qt::ArrowCursor));
QMessageBox::critical(this, tr("Cannot Connect to xTuple ERP Server"),
tr("<p>Sorry, can't connect to the specified xTuple ERP server. "
"<p>The server version %1 is not supported."
"<p>The minimum supported version is %2 and maximum is %3.")
.arg(checkVersion.value("version").toString())
.arg("8.4").arg("9.1"));
db.close();
if (!_captive)
{
_username->setText("");
_username->setFocus();
}
else
_password->setFocus();
_password->setText("");
return;
}
}
// if connected using OpenMFG enhanced auth, remangle the password
if (db.isOpen() && (methodidx == 2 || methodidx == 5))
XSqlQuery chgpass(QString("ALTER USER \"%1\" WITH PASSWORD '%2'")

0 comments on commit 7892bbe

Please sign in to comment.