Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2
Daniele Varrazzo <daniele.varrazzo@gmail.com>
From: Daniele Varrazzo <daniele.varrazzo@gmail.com>
To: Jorge Gustavo Rocha <jgr@geomaster.pt>
Cc: pgsql-bugs@lists.postgresql.org, Jürgen E. Fischer <jef@norbit.de>
Date: 2019-06-18T14:54:40Z
Lists: pgsql-bugs
On Tue, Jun 18, 2019 at 3:43 PM Jorge Gustavo Rocha <jgr@geomaster.pt>
wrote:
> psycopg2.OperationalError: could not translate host name "192.168.1.24
> " to address: Unknown host
>
> You can see replies related to the '\r' issue.
> 1) https://github.com/qgis/QGIS/issues/30027#issuecomment-497433789
>
> 2) https://github.com/qgis/QGIS/issues/30027#issuecomment-498690261
>
> 3) https://github.com/qgis/QGIS/issues/30027#issuecomment-498700090
>
> 4) https://github.com/qgis/QGIS/issues/30027#issuecomment-501799219
>
> I didn't invented the '\r' problem. I've just jumped into it.
>
> I didn't found any other issue with line endings problems in Postgresql. Maybe other '\r' are not harmful. But these in front of host names or host addresses are critical to resolve the ip addresses.
>
> But, for the sake of clarity, the summary is this:
>
> Installing QGIS, in Windows, with libpq, if the pg_services.conf file has '\r\n' line endings, the pg_services fails.
>
> Installing QGIS, in Windows, with libpq, if the pg_services.conf file only has '\n' line endings, the pg_services rocks!
>
> In all likelyhood, if you are using psycopg on windows, you are using a
libpq compiled for the client, not the libpq shipped with postgres server
for windows.
Compiling the libpq happens in this script:
https://github.com/psycopg/psycopg2/blob/master/scripts/appveyor.py
you can verify if the right compiler and libraries are used, or things are
used in a way that '\r' is not handled correctly.
-- Daniele
Commits
-
Fix failures to ignore \r when reading Windows-style newlines.
- 8c52b77ddea7 9.4.24 landed
- 6266654db7fa 9.5.19 landed
- ba27151d1eb0 9.6.15 landed
- cb65b454f87b 10.10 landed
- 11a0a4db3cdb 11.5 landed
- c58cf97f2fc4 12.0 landed
- b654714f9bcf 13.0 landed