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

Поиск
Список
Период
Сортировка
От MauMau
Тема Re: [bug fix] connection service file doesn't take effect with ECPG apps
Дата
Msg-id 908D5415F893439C87E7F1A44C84C716@maumau
обсуждение исходный текст
Ответ на Re: [bug fix] connection service file doesn't take effect with ECPG apps  (Michael Meskes <meskes@postgresql.org>)
Ответы Re: [bug fix] connection service file doesn't take effect with ECPG apps
Список pgsql-hackers
From: "Michael Meskes" <meskes@postgresql.org>
> On Tue, Dec 17, 2013 at 09:26:49PM +0900, MauMau wrote:
>> [Problem]
>> The ECPG app runs the statement:
>>
>> EXEC SQL CONNECT TO 'tcp:postgresql://?service=my_service';
>> ...
>> ECPGconnect() parses the URI and produces an empty host name.  It
>> passes an empty string as the value for "host" connection parameter
>> to PQconnectdbParams().
>
> Interestingly enough it works flawlessly on my system. Any idea where the
> empoty host name comes from? Before accepting the patch I'd like to find
> out
> why you got an empty host variable and I don't.

You can confirm it by adding the following code fragment to
ecpglib/connect.c.  The attached file contains this.

if (host)
    printf("host=%s\n", host);
else
    printf("host=NULL\n");

Build and run the attached sample program like this (this is an example on
Windows, but the result should be the same on Linux):

ecpg connect.pgc
cl /nologo /MD /I<pg_inst_dir>\include connect.c /link
/libpath:<pg_inst_dir>\lib libecpg.lib
connect.exe

The added code in ecpglib/connect.c displays "host=", which shows that an
empty host is passed to PQconnectdbParams().
Of course, on Linux, you can use gdb to run the sample program, set a
breakpoint at PQconnectDbParams(), and display the keywords/values arrays of
the argument.

An empty string is set to the host local variable at line 430 in
ecpglib/connect.c (this line number is that of PostgreSQL 9.4).  That is the
else block shown below:

if (strncmp(dbname, "unix:", 5) == 0)
{
    ...
}
else
{
    host = ecpg_strdup(dbname + offset, lineno);
    connect_params++;
}



Regards
MauMau

Вложения

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

Предыдущее
От: David Rowley
Дата:
Сообщение: [PATCH] work_mem calculation possible overflow
Следующее
От: Alexander Korotkov
Дата:
Сообщение: Re: PoC: Partial sort