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

Multiple hosts are not supported because it's not a valid URI #387

Closed
levkk opened this issue Jun 24, 2021 · 1 comment
Closed

Multiple hosts are not supported because it's not a valid URI #387

levkk opened this issue Jun 24, 2021 · 1 comment

Comments

@levkk
Copy link

levkk commented Jun 24, 2021

Hello,

Multiple hosts, as documented by 33.1.1.3. Specifying Multiple Hosts, is not supported because the gem attempts to parse and re-stringify the URL before giving it to PQconnectdb.

Instead I think it should just pass the connection string as-is to PQconnectdb since that function is able to handle all the options and would give an error if the URI is not valid.

Thank you.

larskanis added a commit to larskanis/ruby-pg that referenced this issue Sep 13, 2021
Unfortunately the uri gem from stdlib isn't compatible with postgresql://host1:port1,host2:port2 syntax.
Therefore we introduce an extended regexp for parsing the URI.

Previously we allowed changes to the URI by overwriting URI parts with hash values.
This is no longer possible and this is a specification change.
But I think it's bad practice and a questionable feature.

Now only additions to the passed URI or connection string are possible.
That way hostaddr and fallback_application_name are automatically appended.

This patch also expands address resolution for multiple hosts.

Fixes ged#387
larskanis added a commit to larskanis/ruby-pg that referenced this issue Sep 13, 2021
Unfortunately the uri gem from stdlib isn't compatible with postgresql://host1:port1,host2:port2 syntax.
Therefore we introduce an extended regexp for parsing the URI.

Previously we allowed changes to the URI by overwriting URI parts with hash values.
This is no longer possible and this is a specification change.
But I think it's bad practice and a questionable feature.

Now only additions to the passed URI or connection string are possible.
That way hostaddr and fallback_application_name are automatically appended.

This patch also expands address resolution for multiple hosts.

Fixes ged#387
larskanis added a commit to larskanis/ruby-pg that referenced this issue Sep 13, 2021
Unfortunately the uri gem from stdlib isn't compatible with postgresql://host1:port1,host2:port2 syntax.
Therefore we introduce an extended regexp for parsing the URI.

Previously we allowed changes to the URI by overwriting URI parts with hash values.
This is no longer possible and this is a specification change.
But I think it's bad practice and a questionable feature.

Now only additions to the passed URI or connection string are possible.
That way hostaddr and fallback_application_name are automatically appended.

This patch also expands address resolution for multiple hosts.

Fixes ged#387
@larskanis
Copy link
Collaborator

I overhauled the connection option builder as part of #397, so that it is possible to specify multiple hosts.

The URI is no longer changed by the option hash, but we still extend it with hostaddr and fallback_application_name for convenience. I think this is a good tradeoff.

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 a pull request may close this issue.

2 participants