Re: Patch: Implement failover on libpq connect level.

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Mithun Cy <mithun(dot)cy(at)enterprisedb(dot)com>
Cc: Peter van Hardenberg <pvh(at)pvh(dot)ca>, Peter Eisentraut <peter_e(at)gmx(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch: Implement failover on libpq connect level.
Date: 2016-11-01 14:14:03
Message-ID: CA+TgmoZQLcGa1v9-ZY4bi8RdsqMqU2CEdk4Bzz11Y5nqZoVXDQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

On Tue, Nov 1, 2016 at 9:43 AM, Mithun Cy <mithun(dot)cy(at)enterprisedb(dot)com> wrote:
>> Starting program: /home/mithun/libpqbin/bin/./psql
>> postgres://%2fhome%2fmithun:5555/postgres -U mithun1
>> [Thread debugging using libthread_db enabled]
>> Using host libthread_db library "/lib64/libthread_db.so.1".
>> psql: could not connect to server: No such file or directory
>> Is the server running locally and accepting
>> connections on Unix domain socket "/home/mithun/.s.PGSQL.5555"?
>
> Accidentally when testing further on this line I found a crash when invalid
> encoding "%2" (not recognised as hexa) was used.
> Test:
>>
>> Starting program: /home/mithun/libpqbin/bin/./psql
>> postgres://%2home%2mithun:5555/postgres -U mithun1

You seem to be confused about how to escape characters in URLs. The
format is a % followed by exactly two hex digits. In this case, that
would give you %2h and %2m, and h and m are not hex characters, so the
error message is right. Your input is not valid.

> There can be PGconn which have no connhost.
> exposed API's PQpass, PQreset->connectDBStart access conn->connhost without
> checking whether it is set.

Can you provide a concrete test scenario or some test code that fails?
connhost is supposed to be getting set in connectOptions2(), which is
run (AIUI) when the PGconn is first created. So I think that it will
be set in all scenarios of the type you mention, but I might be
missing something.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2016-11-01 14:14:29 Re: [PATCH] pgpassfile connection option
Previous Message Robert Haas 2016-11-01 14:10:53 Re: Improve output of BitmapAnd EXPLAIN ANALYZE

Browse pgsql-jdbc by date

  From Date Subject
Next Message Mithun Cy 2016-11-01 15:21:40 Re: Patch: Implement failover on libpq connect level.
Previous Message Dave Cramer 2016-11-01 14:03:30 Re: JDBC and the hstore ? operator - no longer working with build 1211