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:
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
--
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 |