Subject: Detecting no postmaster

From: PostGres <[email-masked]>
Date: Thu, 4 Nov 1993 18:14:21 +1100 (EST)

Dear gurus,

I am wondering whether there is any way to detect that
a postmaster is not running on a given host.

What I am trying to do is change from on postmaster to
another postmaster during the execution of the program.

The code is like the following :
(the name of the new host is retrieved from the db)

strcpy(PQhost, PQgetvalue(PQparray("blank"),0,0));
PQsetdb("remote");

to change postmasters and databases, then I thought I
might be able to tramsmit a bogus query and capture
the return to see if the postmaster exists.

If the postmaster on the remote machine is not running
the code terminates with :

StreamOpen: connect: errno=61
Error: Failed to connect to backend (host=tron, port=4321)
Is the postmaster running?

I would like to capture this and display something more
like :

Server on host "tron" is not responding !

Thanx for any advice that you can give,
Glen Darby.
-- 
--------------------------------------------------------
| University Of Western Sydney                         |
| Postgres Database Aministration                      |
|                                                      |
| Administrator :  Glen Darby                          |
|                                                      |
|                                                      |
| Return Mail : [email-masked]          |
========================================================

---

From: [email-masked] (Paul M. Aoki)
Date: Thu, 04 Nov 93 10:04:35 -0800

> a postmaster is not running on a given host.

look at what the routine src/libpq/fe-pqexec.c:EstablishComm does.
you could also write a half-page of code that does a connect(2) to
the well-known port..
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  [email-masked]
                |  Berkeley, CA 94720           |  ...!uunet!ucbvax!aoki