| From: | "MauMau" <maumau307(at)gmail(dot)com> |
|---|---|
| To: | "Michael Meskes" <meskes(at)postgresql(dot)org> |
| Cc: | <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [bug fix] connection service file doesn't take effect with ECPG apps |
| Date: | 2013-12-28 07:37:44 |
| Message-ID: | 908D5415F893439C87E7F1A44C84C716@maumau |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
From: "Michael Meskes" <meskes(at)postgresql(dot)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
| Attachment | Content-Type | Size |
|---|---|---|
| connect.pgc | application/octet-stream | 173 bytes |
| connect.c | text/plain | 16.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alexander Korotkov | 2013-12-28 08:28:04 | Re: PoC: Partial sort |
| Previous Message | David Rowley | 2013-12-28 06:31:34 | [PATCH] work_mem calculation possible overflow |