Skip to content
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

Store db connection parameters in a their own class #2129

Merged
merged 2 commits into from
Feb 2, 2024

Conversation

joto
Copy link
Collaborator

@joto joto commented Feb 1, 2024

The connection parameters (such as dbname, user, host, ...) are stored in their original format and not concatenated into a conninfo string any more. We are now using a different database connection function from libpq that takes them in this form. This allows us to get rid of the code that transforms those parameters into the conninfo string that takes various forms of connection parameters into account, especially around the URI form of the connection parameters. The libpq has this code anyway, see also the last parameter "expand_dbname" of the PQconnectdbParams() function (https://www.postgresql.org/docs/current/libpq-connect.html).

This also allow us to have slightly different database connection parameters for different database connection. This is used here to add the connection id into the fallback_application_name parameter. This connection id also reported when using --log-sql. This way you can correlate the ids from the log with the information shown in pg_stat_activity.

This commit looks large, because it changes the type std::string to connection_parameters_t in many places. I have split the work into two commmits, in the first I have kept the parameter name "conninfo" in an effort to keep the commit small. The second commit renames "conninfo" to "connection_params" everywhere.

joto added 2 commits February 1, 2024 10:37
The connection parameters (such as dbname, user, host, ...) are stored
in their original format and not concatenated into a conninfo string any
more. We are now using a different database connection function from
libpq that takes them in this form. This allows us to get rid of the
code that transforms those parameters into the conninfo string that
takes various forms of connection parameters into account, especially
around the URI form of the connection parameters. The libpq has this
code anyway, see also the last parameter "expand_dbname" of the
PQconnectdbParams() function
(https://www.postgresql.org/docs/current/libpq-connect.html).

This also allow us to have slightly different database connection
parameters for different database connection. This is used here to add
the connection id into the fallback_application_name parameter. This
connection id also reported when using --log-sql. This way you can
correlate the ids from the log with the information shown in
pg_stat_activity.

This commit looks large, because it changes the type std::string to
connection_parameters_t in many places. I have kept the parameter name
"conninfo" in an effort to keep the commit small, the next commit will
change that also.
This is really part of the previous commit but was factored out to keep
that one reasonably legible.
@lonvia lonvia merged commit d6fedbd into osm2pgsql-dev:master Feb 2, 2024
26 checks passed
@joto joto deleted the connection-params branch February 4, 2024 08:19
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