Skip to content

Commit

Permalink
Adding support for PostgreSQL 10+.
Browse files Browse the repository at this point in the history
From PostgreSQL 10, there won't be any minor version, only major
version. Hence - we need to change the logic for version match to
support two digit version, instead of earlier three digit version.
  • Loading branch information
moreparesh authored and asheshv committed Oct 27, 2017
1 parent 761d54e commit f371902
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 42 deletions.
24 changes: 6 additions & 18 deletions App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,27 +188,15 @@ bool App::WorksWithDB()
if (tmpversion == wxEmptyString)
return true;

if (tmpversion.EndsWith(wxT("+")))
{
// Apps may specify 8.3+ to denote they require server version 8.3 or above.
long appMajor = 0, appMinor = 0;

tmpversion = tmpversion.RemoveLast();
tmpversion.BeforeFirst('.').ToLong(&appMajor);

if (m_server->majorVer > appMajor)
return true;

long appMajor = 0, appMinor = 0;
tmpversion.BeforeFirst('.').ToLong(&appMajor);
if (appMajor < 10)
tmpversion.AfterFirst('.').ToLong(&appMinor);

if (m_server->majorVer == appMajor && m_server->minorVer >= appMinor)
return true;
}
if (tmpversion.EndsWith(wxT("+")))
return (m_server->majorVer > appMajor || (m_server->majorVer == appMajor && m_server->minorVer >= appMinor));
else
{
if (tmpversion == wxString::Format(wxT("%d.%d"), m_server->majorVer, m_server->minorVer))
return true;
}
return (m_server->majorVer == appMajor && m_server->minorVer == appMinor);

return false;
}
Expand Down
47 changes: 23 additions & 24 deletions IntroductionPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,29 +204,25 @@ bool IntroductionPage::FindPgServers()

pgRegKey *instKey = pgRegKey::OpenRegKey(HKEY_LOCAL_MACHINE, keyName, pgRegKey::PGREG_READ, wowMode);

data->majorVer = 0;
data->minorVer = 0;

if (instKey != NULL)
{
if (instKey->HasValue(wxT("Version")))
{
instKey->QueryValue(wxT("Version"), data->serverVersion);
data->serverVersion.BeforeFirst('.').ToLong(&data->majorVer);
data->serverVersion.AfterFirst('.').ToLong(&data->minorVer);
}
else
{
data->majorVer = 0;
data->minorVer = 0;

if (data->majorVer < 10)
data->serverVersion.AfterFirst('.').ToLong(&data->minorVer);
}

if (instKey->HasValue(wxT("Base Directory")))
instKey->QueryValue(wxT("Base Directory"), data->installationPath);

delete instKey;
}
else
{
data->majorVer = 0;
data->minorVer = 0;
}
}

// Build the user description
Expand Down Expand Up @@ -280,7 +276,11 @@ bool IntroductionPage::FindPgServers()
// Server version
data->serverVersion = version;
data->serverVersion.BeforeFirst('.').ToLong(&data->majorVer);
data->serverVersion.AfterFirst('.').ToLong(&data->minorVer);

if (data->majorVer < 10)
data->serverVersion.AfterFirst('.').ToLong(&data->minorVer);
else
data->minorVer = 0;

// And the rest of the data
data->description = cnf->Read(version + wxT("/Description"), _("Unknown server"));
Expand Down Expand Up @@ -401,29 +401,25 @@ bool IntroductionPage::FindEdbServers()

pgRegKey *instKey = pgRegKey::OpenRegKey(HKEY_LOCAL_MACHINE, keyName, pgRegKey::PGREG_READ, wowMode);

data->majorVer = 0;
data->minorVer = 0;

if (instKey != NULL)
{
if (instKey->HasValue(wxT("Version")))
{
instKey->QueryValue(wxT("Version"), data->serverVersion);
data->serverVersion.BeforeFirst('.').ToLong(&data->majorVer);
data->serverVersion.AfterFirst('.').ToLong(&data->minorVer);
}
else
{
data->majorVer = 0;
data->minorVer = 0;

if (data->majorVer < 10)
data->serverVersion.AfterFirst('.').ToLong(&data->minorVer);
}

if (instKey->HasValue(wxT("Base Directory")))
instKey->QueryValue(wxT("Base Directory"), data->installationPath);

delete instKey;
}
else
{
data->majorVer = 0;
data->minorVer = 0;
}
}

// Build the user description
Expand Down Expand Up @@ -475,9 +471,12 @@ bool IntroductionPage::FindEdbServers()
data->platform = STACKBUILDER_PLATFORM;

// Server version
data->majorVer = 0;
data->minorVer = 0;
data->serverVersion = version;
data->serverVersion.BeforeFirst('.').ToLong(&data->majorVer);
data->serverVersion.AfterFirst('.').ToLong(&data->minorVer);
if ( data->majorVer < 10 )
data->serverVersion.AfterFirst('.').ToLong(&data->minorVer);

// And the rest of the data
data->description = cnf->Read(version + wxT("/Description"), _("Unknown server"));
Expand Down

0 comments on commit f371902

Please sign in to comment.