From: Jorge Gustavo Rocha <jgr@geomaster.pt>
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2
Date: Wed, 19 Jun 2019 21:01:49 +0100
Message-ID: <81d9d421-6947-7111-a1dc-cfd99cd3ae53@geomaster.pt> (raw)
In-Reply-To: <CA+mi_8aBnLKypX2Ttksg8JEhApBo=JpF6P_STQGp-FOvDpn6Yw@mail.gmail.com>
References: <15827-e6ba53a3a7ed543c@postgresql.org>
<82491.1559409563@sss.pgh.pa.us>
<e12a23c6-5e00-3fa6-6179-681336130361@geomaster.pt>
<1473.1560866085@sss.pgh.pa.us>
<fcb5c34c-cf5f-6dc9-c68e-6b297f073b79@geomaster.pt>
<CA+mi_8aBnLKypX2Ttksg8JEhApBo=JpF6P_STQGp-FOvDpn6Yw@mail.gmail.com>
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@geomaster.pt
> <mailto: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
>
--
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@geomaster.pt
Attachments:
[image/png] cropped-geomaster300x300-1.png (33.1K, ../81d9d421-6947-7111-a1dc-cfd99cd3ae53@geomaster.pt/3-cropped-geomaster300x300-1.png)
download | view image
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: jgr@geomaster.pt, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2
In-Reply-To: <81d9d421-6947-7111-a1dc-cfd99cd3ae53@geomaster.pt>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox