--- pgadmin3/pgadmin/db/pgConn.cpp 2011-04-12 19:26:25.000000000 +0200 +++ changes/pgConn.cpp 2011-04-12 16:51:10.000000000 +0200 @@ -705,6 +705,36 @@ } +////////////////////////////////////////////////////////////////////////// +// Execute SQL with optional result set +////////////////////////////////////////////////////////////////////////// + +PGresult * pgConn::ExecuteOptionalResult(const wxString &sql, bool reportError) +{ + PGresult *qryRes = 0; + + if (GetStatus() != PGCONN_OK) + return qryRes; + + // Execute the query and get the status. + + + wxLogSql(wxT("Void query (%s:%d): %s"), this->GetHost().c_str(), this->GetPort(), sql.c_str()); + qryRes = PQexec(conn, sql.mb_str(*conv)); + lastResultStatus = PQresultStatus(qryRes); + SetLastResultError(qryRes); + + // Check for errors + if (lastResultStatus != PGRES_COMMAND_OK && lastResultStatus != PGRES_COPY_IN && lastResultStatus != PGRES_COPY_OUT) + { + LogError(!reportError); + PQclear(qryRes); + qryRes = 0; + } + + return qryRes; +} + wxString pgConn::ExecuteScalar(const wxString &sql) {