Is there a way to find the PostgreSQL installation directory (bin) via query?
Thanks.
Is there a way to find the PostgreSQL installation directory (bin) via query?
Thanks.
I don't think there is a way to get the path of the Postgres executable.
The only thing that can be retrieved from the system catalogs is the location of the data directory.
SELECT *
FROM pg_settings
WHERE name = 'data_directory'
This can only be executed by the superuser though.
I would simply create a table and save the info you want in it as part of your installation procedure.
Building on Jakob's answer, this is how I did it using psql:
psql -t -c '\o | xargs -I {} realpath /proc/{}/exe | xargs dirname' -c 'select pg_backend_pid()' -c 'select pg_sleep(1)'