summaryrefslogtreecommitdiffstats
path: root/commands.c
diff options
context:
space:
mode:
authorMark Wong <markwkm@gmail.com>2007-09-21 17:16:51 -0700
committerMark Wong <markwkm@gmail.com>2007-09-21 17:16:51 -0700
commit37b02356e7f88ac2b7bd2f03e6d8912467c49676 (patch)
treed25395b32165009dd452199043a0486dae55ebb3 /commands.c
parentb836d596e5c9e21441f7689a2000270567ccdfe0 (diff)
Made changes so that the ptop will run without seg faulting if the
database isn't running or if the database stops while ptop is running. The system summary info will still update but there will not be any processes displayed. Tried to get a message to display that the no database connection was made. That can hopefully be fixed in a later version.
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/commands.c b/commands.c
index 9e29a4c..ff53e04 100644
--- a/commands.c
+++ b/commands.c
@@ -31,6 +31,7 @@
#include "version.h"
#include "machine.h"
#include "help.h"
+#include "pg.h"
extern int errno;
@@ -521,7 +522,7 @@ show_current_query(char *conninfo, int procpid)
display_pager(info);
/* Get the currently running query. */
- pgconn = PQconnectdb(conninfo);
+ pgconn = connect_to_db(conninfo);
pgresult = PQexec(pgconn, sql);
rows = PQntuples(pgresult);
for (i = 0; i < rows; i++) {
@@ -555,7 +556,7 @@ show_locks(char *conninfo, int procpid)
display_pager(info);
/* Get the locks helf by the process. */
- pgconn = PQconnectdb(conninfo);
+ pgconn = connect_to_db(conninfo);
pgresult = PQexec(pgconn, sql);
rows = PQntuples(pgresult);