New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"service" syntax support: "jdbc:postgresql://?service=my-service" (pg_service.conf and .pgpass) #2278
Comments
We'd welcome a PR. Now I will say we are in the middle of trying to release 43.0.0 so it may be a while before it gets committed. |
@davecramer - I can not find a way to create new branch. Do I miss permissions for that? |
@MarekUniq you need to clone the repo locally and then create a local branch. Then you push your branch to your cloned branch. That will create a PR |
@davecramer - I think I miss some steps I have a clone:
I have branch:
I did commits. Using "idea", branch push command gives the following error:
|
@MarekUniq Yes, my mistake. You need to fork it... then you can do whatever you want on your fork. Cheers. |
@davecramer - thank you. I managed to open PR. I did not find a way how to fill in "Linked issues" on PR page but maybe it requires higher rights (or skills) :) |
fixes #2282 works :) |
…2282) * pg_service.conf and .pgpass support (jdbc:postgresql://?service=my-service) (#2260)(#2278) * system-stubs-jupiter (junit5) dependency added (#2260)(#2278) * test: pg_service.conf and .pgpass support (jdbc:postgresql://?service=my-service)(#2260)(#2278) * docs: pg_service.conf and .pgpass support (jdbc:postgresql://?service=my-service) (#2260)(#2278) * test: non-ascii comments removed (#2260)(#2278)
closed with #2347 |
Introduction
psql (libpq) supports ini-style service file. pgjdbc does not support servcie.
psql (libpq) supports .pgpass file. pgjdbc does not support .pgpass.
Goal
Add pg_service.conf and .pgpass support to pgjdbc.
pgjdbc should behave as close as possible to libpq.
References
https://www.postgresql.org/docs/current/libpq-pgservice.html
https://www.postgresql.org/docs/current/libpq-envars.html
https://www.postgresql.org/docs/current/libpq-pgpass.html
pg_service.conf
Following JDBC URL syntaxes are valid
Properties are overridden in the following order
are overridden by
are overridden by
are overridden by
are overridden by
are overridden by
Example
"pg_service.conf" resource is selected using the following order
java command line property: -Dorg.postgresql.pgservicefile=<my-file1>
if <my-file1> is specified then it is used (even if it does not exist)
otherwise continue
(psql message: psql: error: service file "my-file1" not found)
environemnt varaible: ${PGSERVICEFILE}=<my-file2>
if <my-file2> is specified then it is used (even if it does not exist)
(psql message: psql: error: service file "my-file2" not found)
hard-coded path for windows: System.getenv("APPDATA")\postgresql\pg_service.conf
hard-coded path for "other os": System.getProperty("user.home")/.pg_service.conf
if <this-file> exist and is readable then use it
(psql message: <no any message>)
otherwise continue
environemnt varaible ${PGSYSCONFDIR}=<my-dir4>
if "<my-dir4>" is specified then file is used: "<my-dir4>/pg_service.conf"
if <this-file> exist and is readable then use it
(psql message: <no any message>)
otherwise continue
If definition for service is not found: Error is reported
(psql: error: definition of service "my-service" not found)
.pgpass
Password is overridden in the following order
is overridden by
is overridden by
is overridden by
".pgpass" resource is selected using the following order
java command line property: -Dorg.postgresql.pgpassfile=<my-file1>
if <my-file1> is specified then it is used. No error, even if file does not exist.
otherwise continue
environemnt varaible: ${PGPASSFILE}=<my-file2>
if <my-file2> is specified then it is used. No error, even if file does not exist.
otherwise continue
hard-coded path for windows: System.getenv("APPDATA")\postgresql\pgpass.conf
hard-coded path for "other os": System.getProperty("user.home")/.pgpass
if <this-file> exist and is readable then use it
otherwise continue
If matching line for password is not found?
No error is reported, password property remains unset.
".pgpass" file format is the following (colon-separated)
Colon (:) and backslash (\) chars for "hostname", "database" and "username" can be optionally escaped with backslash (\).
Colon (:) and backslash (\) chars for "password" must be escaped using backslash (\).
Instead of value, a star (*) can be specified which means any value. For example:
Based on examples above, multiple lines can match. First matching line is selected.
The text was updated successfully, but these errors were encountered: