From: | Jorge Gustavo Rocha <jgr(at)geomaster(dot)pt> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2 |
Date: | 2019-06-19 20:01:49 |
Message-ID: | 81d9d421-6947-7111-a1dc-cfd99cd3ae53@geomaster.pt |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hi Tom,
Just an update on this problem. I'm grateful to the valuable comments by
Daniele Varrazzo, Jason Erickson and Jürgen Fischer.
I confirm that MSC behavior is to discard \r if the file is open in text
mode.
The error I was facing in QGIS is because the application changes the
default fopen mode to binary mode. So, every file is opened in binary
mode and so is pg_services.conf.
So, in this specific usage of libpq, used in another application, we
lost the expected behavior of discarding \r characters.
In my humble opinion, we could make pg_services.conf agnostic in terms
of \r, just by filtering them, if present.
By filtering \r, we make libpq agnostic in terms of line terminators and
also agnostic in terms of compiler. libpq will read pg_services.conf
files with or without \r and compiled with any compiler.
I don't have any more arguments to add.
Thanks for all that helped to identified the problem.
Regards,
Jorge Gustavo
Às 15:54 de 18/06/19, Daniele Varrazzo escreveu:
> On Tue, Jun 18, 2019 at 3:43 PM Jorge Gustavo Rocha <jgr(at)geomaster(dot)pt
> <mailto:jgr(at)geomaster(dot)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
>
--
Logo* Geomaster, LDA*
*VENHA DESCOBRIR O CAMINHO DO OPEN SOURCE CONNOSC**O
*
Avenida Barros e Soares
N.º 423, 4715-214 Braga
VAT/NIF510 906 109
Phone +351 253 680 323
Site geomaster.pt <http://geomaster.pt>
GPS 41.53322, -8.41929
------------------------------------------------------------------------
Jorge Gustavo Rocha
CTO
Mobile +351 910 333 888
Email jgr(at)geomaster(dot)pt
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-06-19 20:44:58 | Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2 |
Previous Message | Tom Lane | 2019-06-19 19:31:28 | Re: BUG #15854: postgres wtih Docker: binding port fails with release greater than 9.6.13 |