Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Make sure IsAlive check isn't affected by dead transactions
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.pgadmin.org/branches/REL-1_2_0_PATCHES@3979 a7884b65-44f6-0310-8a51-81a127f17b15
  • Loading branch information
Andreas Pflug committed Feb 13, 2005
1 parent f348e95 commit bd6f65b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/db/pgConn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,24 @@ void pgConn::RegisterNoticeProcessor(PQnoticeProcessor proc, void *arg)

wxString pgConn::SystemNamespaceRestriction(const wxString &nsp)
{
return wxT("(") + nsp + wxT(" NOT LIKE 'pg\\_%' AND ") + nsp + wxT(" NOT LIKE 'information_schema')");
if (reservedNamespaces.IsEmpty())
{
reservedNamespaces = wxT("'information_schema'");
pgSet *set=ExecuteSet(
wxT("SELECT nspname FROM pg_namespace nsp\n")
wxT(" JOIN pg_proc pr ON pronamespace=nsp.oid\n")
wxT(" WHERE proname IN ('slonyversion')"));
if (set)
{
while (!set->Eof())
{
reservedNamespaces += wxT(", ") + qtString(set->GetVal(wxT("nspname")));
set->MoveNext();
}
delete set;
}
}
return wxT("(") + nsp + wxT(" NOT LIKE 'pg\\_%' AND ") + nsp + wxT(" NOT in (") + reservedNamespaces + wxT("))");
}


Expand Down Expand Up @@ -412,6 +429,12 @@ bool pgConn::IsAlive()

PGresult *qryRes = PQexec(conn, "SELECT 1;");
lastResultStatus = PQresultStatus(qryRes);
if (lastResultStatus != PGRES_TUPLES_OK)
{
PQclear(qryRes);
qryRes = PQexec(conn, "ROLLBACK TRANSACTION; SELECT 1;");
lastResultStatus = PQresultStatus(qryRes);
}
PQclear(qryRes);

// Check for errors
Expand Down

0 comments on commit bd6f65b

Please sign in to comment.