Thread: [ADMIN] Using hba_file parameter and relative path
In going through some parameter file cleanup and re-factoring, I've been using the hba_file parameter to specify a non-standard file location. I tried using a relative location, thinking it would be relative to $PGDATA but in actuality it is relative to the pwd of my bash session that starts the database.
For example, if I'm in /tmp when I run "pg_ctl start", it will look for the hba_file value under /tmp. If I change to $PGDATA/pg_log, it will look under there.
Obviously I can change to an absolute path and not worry about it, but I'm curious if this is the intended behavior. Why would we want that hba_file value to be relative to something as volatile as pwd?
FWIW this is Postgres 9.6.5 on CentOS 7.3.
Don.
In going through some parameter file cleanup and re-factoring, I've been using the hba_file parameter to specify a non-standard file location. I tried using a relative location, thinking it would be relative to $PGDATA but in actuality it is relative to the pwd of my bash session that starts the database.For example, if I'm in /tmp when I run "pg_ctl start", it will look for the hba_file value under /tmp. If I change to $PGDATA/pg_log, it will look under there.Obviously I can change to an absolute path and not worry about it, but I'm curious if this is the intended behavior.
Its the documented behavior.
"When setting any of these parameters, a relative path will be interpreted with respect to the directory in which postgres is started."
Why would we want that hba_file value to be relative to something as volatile as pwd?
Why do you want it under PGDATA but not in the root directory thereof?
Since there is no "config_directory" option the current behavior at least allows the user to substitute "pwd" for "config_directory" and then set "data_directory" separately. Seems like reasonable flexibility to cater to the Debian-esque file system layout while leaving the typical core use case to just set pwd == "data_directory" and drop everything in there.
In any case if you are going to use relative paths then "pwd" should be a considered part of the architecture and not something that is considered "volatile". That seems to be how most programs behave and I don't see much advantage for PostgreSQL to be different in this regard.
David J.
On Thu, Sep 28, 2017 at 2:15 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:
Its the documented behavior."When setting any of these parameters, a relative path will be interpreted with respect to the directory in which postgres is started."Why would we want that hba_file value to be relative to something as volatile as pwd?Why do you want it under PGDATA but not in the root directory thereof?
For the sake of grouping and source control, I put my configs into a subdirectory of PGDATA. I wanted to keep them separate from the other files and directories in PGDATA.
Thanks for pointing out the documentation reference, I missed that in my own search.
In any case if you are going to use relative paths then "pwd" should be a considered part of the architecture and not something that is considered "volatile". That seems to be how most programs behave and I don't see much advantage for PostgreSQL to be different in this regard.
Obviously just my opinion, but I do consider it "volatile" in the sense that I could be (and usually am) anywhere on the host system when calling the startup. Perhaps I'm the outlier though since I'm relatively new to the Postgres game.
Anyway, since this is working as documented, I now know to use the absolute path to avoid the issue.
Cheers,