Tom Lane wrote:
Rob Jaeger <yogi...@gmail.com> writes:
Is there a command or reliable method of finding the location of the
PostgreSQL bin path?
pg_config --bindir
Although I think not all packagers install this in the base package,
which might limit its usefulness.
I'm not sure which question Rob meant to ask here:
1) Where can I find the PostgreSQL in my PATH right now? The best I
think you can do here is to try the above pg_config bit first, then if
it doesn't work try guess based on "which postmaster".
2) Given a running server, what PostgreSQL binary was used to start it?
You can get some info about a running server using this query (which
just suggests what SHOW can give you):
select name,setting from pg_settings where category='File Locations';
But there's no binary location listed there. You can dig it out of ps
using something like this:
ps -C postgres -o cmd 2>&1 | grep "/postgres" | cut -d" " -f1
(Tested on Linux)
You'll need to test on all the UNIX-ish OSes you want to support though,
getting ps calls to work perfectly everywhere is harder than it should be.
Only the pg_config technique will be easy to use from Windows I think,
but at least there you shouldn't have as many concerns about what
subsets of the package are installed--I don't think it's sliced up
nearly as fine as you can make the RPM or deb installs for example, such
that you can easily have a server running but not pg_config. I could be
wrong about that though.
--
Greg Smith 2ndQuadrant Baltimore, MD
PostgreSQL Training, Services and Support
g...@2ndquadrant.com www.2ndQuadrant.com