Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2

Поиск
Список
Период
Сортировка
От Jorge Gustavo Rocha
Тема Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2
Дата
Msg-id 81d9d421-6947-7111-a1dc-cfd99cd3ae53@geomaster.pt
обсуждение исходный текст
Ответ на Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Ответы Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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@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:


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 CONNOSCO

 
Avenida Barros e Soares
N.º 423, 4715-214 Braga
VAT/NIF
510 906 109
Phone
  +351 253 680 323
Site       geomaster.pt
GPS       41.53322, -8.41929


 
Jorge Gustavo Rocha

CTO

Mobile
  +351 910 333 888
Email    jgr@geomaster.pt

Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #15854: postgres wtih Docker: binding port fails with release greater than 9.6.13
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2