> Sure. I did not say it was "incorrect"...
> But it is *different* from most if not all other errors, because it
> requires a different item...
It just depends on the use of the script (about which I didn't know the
details). If the only purpose is to determine if I can run queries then the
simple test will do. If the purpose is to determine whether or not to
start/restart the db server then my "script" is not complete.
> > Still, I
> >think it's safer to look for the existence of expected results that the
> >absence of specific error messages.
>
> I don't know what is "safer" about it... :-)
> It seems to be more like a question of taste...
Not taste - just the voice of experience from one who has been burned. Suppose
your db is on a remote machine and someone screws up DNS so the host doesn't
resolve or the db admin has made an error in updating pg_hba.conf or a
network cable is unplugged or a routing table is damaged. You can even have
something as silly as psql being deleted or not in the path. None of these
cases will yield the string "ERROR" so a script that looks for the absence of
"ERROR" will say everything is OK.
I've given up trying to dream up/test for every possible error - there are too
many and once I think I've thought of them all I "discover" another. :)
Checking for a known expected result will definitely let you know if the db is
or is not available (note, not available != down - just not available to the
testing program - again it depends on the purpose of your script).
Cheers,
Steve