pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jorge Gustavo Rocha <jgr@geomaster.pt>
Cc: 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 16:44:58 -0400
Message-ID: <23215.1560977098@sss.pgh.pa.us> (raw)
In-Reply-To: <81d9d421-6947-7111-a1dc-cfd99cd3ae53@geomaster.pt>
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>
	<81d9d421-6947-7111-a1dc-cfd99cd3ae53@geomaster.pt>

Jorge Gustavo Rocha <jgr@geomaster.pt> writes:
> 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.

Ah-hah!  That explains much.  So a non-invasive fix would be to force
parseServiceFile to open the file in text mode; I think this would
work for that:

-	f = fopen(serviceFile, "r");
+	f = fopen(serviceFile, "rt");

I don't think that that's really a good solution, because it does little
to prevent the same problem from reappearing elsewhere.  But if we wanted
the smallest possible fix that might do.

> In my humble opinion, we could make pg_services.conf agnostic in terms
> of \r, just by filtering them, if present.

I think we should have it go further and ignore any trailing isspace()
characters, so that trailing spaces don't cause problems either.
But in any case, the real stumbling block here is to get a project-wide
convention as to how to do it.

			regards, tom lane





view thread (23+ messages)  latest in thread

Message-ID: <23215.1560977098@sss.pgh.pa.us>
Permalink:  ../23215.1560977098@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23215.1560977098@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, 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: <23215.1560977098@sss.pgh.pa.us>

* 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