[bug fix] connection service file doesn't take effect with ECPG apps

Поиск
Список
Период
Сортировка
От MauMau
Тема [bug fix] connection service file doesn't take effect with ECPG apps
Дата
Msg-id 6ABE137B9CF04026B6902A192A0FFE22@maumau
обсуждение исходный текст
Ответы Re: [bug fix] connection service file doesn't take effect with ECPG apps
Список pgsql-hackers
Hello,

I've found a small bug of ECPG and attached a patch.  I tested the fix with
9.4.  I'd like the fix to be back-ported.


[Problem]
The ECPG app runs the statement:

EXEC SQL CONNECT TO 'tcp:postgresql://?service=my_service';

I want this app to connect to any database based on the connection service
file.
For example, I wrote the following connection service file pg_service.conf,
placed it in the current directory, set PGSERVICEFILE environment variable
to point to it:

[my_service]
dbname = mydb
host = myhost
port = 5555

myhost is a different host than the one where the app runs.

Unfortunately, the app could not connect to the intended database.  It tried
to connect to the (non-existent) database server on the local machine and
failed.


[Cause]
ECPGconnect() parses the URI and produces an empty host name.  It passes an
empty string as the value for "host" connection parameter to
PQconnectdbParams().

Given an empty host name, PQconnectdbParams() ignores the host parameter in
pg_service.conf.  When host is "", PQconnectdbParams() try to connect via
local UNIX domain socket.


[Fix]
It doesn't make sense for ECPGconnect() to pass an empty host name to
PQconnectdbParams(), so prevent it from passing host parameter for the
service setting to take effect.  port is the same.


Regards
MauMau

Вложения

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

Предыдущее
От: "MauMau"
Дата:
Сообщение: Re: [bug fix] pg_ctl always uses the same event source
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: Optimize kernel readahead using buffer access strategy