Skip to content

Conversation

@ikalnytskyi
Copy link
Owner

The 'setup-postgres' action used to set libpq environment variables [1] with connection parameters so the PostgreSQL client applications [2], such as 'psql' or 'createuser', won't require any configuration before using.

Unfortunately these libpq environment variables are also used by all libpq clients including database drivers such as 'psycopg'. While this may sound good, it may as well lead to undesired behaviour and unobvious issues when connection parameters are automatically pulled from environment but most not.

Nevertheless, the need to easy usage of the client applications [2] is indisputable because providing a bunch of connection parameters all the time is tedious. Therefore this patch pushes requires connection parameters to the connection service file [3], so the client applications can pull the data on-demand. E.g:

$ psql service=superuser -c "SELECT 1;"
$ PGSERVICE=superuser createuser myuser

[1] https://www.postgresql.org/docs/15/libpq-envars.html
[2] https://www.postgresql.org/docs/15/reference-client.html
[3] https://www.postgresql.org/docs/15/libpq-pgservice.html

@ikalnytskyi ikalnytskyi force-pushed the pgservice branch 5 times, most recently from 72f4f9b to c4d2d9f Compare January 4, 2023 00:24
The 'setup-postgres' action used to set libpq environment variables [1]
with connection parameters so the PostgreSQL client applications [2],
such as 'psql' or 'createuser', won't require any configuration before
using.

Unfortunately these libpq environment variables are also used by all
libpq clients including database drivers such as 'psycopg'. While this
may sound good, it may as well lead to undesired behaviour and unobvious
issues when connection parameters are automatically pulled from
environment but most not.

Nevertheless, the need to easy usage of the client applications [2] is
indisputable because providing a bunch of connection parameters all the
time is tedious. Therefore this patch pushes requires connection
parameters to the connection service file [3], so the client
applications can pull the data on-demand. E.g:

    $ psql service=superuser -c "SELECT 1;"
    $ PGSERVICE=superuser createuser myuser

[1] https://www.postgresql.org/docs/15/libpq-envars.html
[2] https://www.postgresql.org/docs/15/reference-client.html
[3] https://www.postgresql.org/docs/15/libpq-pgservice.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants