Skip site navigation (1) Skip section navigation (2)

Re: BUG #5487: dblink failed with 63 bytes connection names

From: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5487: dblink failed with 63 bytes connection names
Date: 2010-06-01 02:55:11
Message-ID: 20100601115511.95D2.52131E4D@oss.ntt.co.jp (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
"Takahiro Itagaki" <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> wrote:

> Bug reference:      5487
> Logged by:          Takahiro Itagaki
> Email address:      itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp
> Description:        dblink failed with 63 bytes connection names
> Details: 
> 
> Contib/dblink module seems to have a bug in handling
> connection names in NAMEDATALEN-1 bytes.

Here is a patch to fix the bug. I think it comes from wrong usage
of snprintf(NAMEDATALEN - 1). It just copies 62 bytes + \0.

In addition, it should be safe to use pg_mbcliplen() to truncate
extra bytes in connection names because we might return invalid
text when a multibyte character is at 62 or 63 bytes.

Note that the fix should be ported to previous versions, too.


> It cannot use exiting connections with 63 bytes name
> in some cases. For example, we cannot disconnect
> such connections. Also, we can reconnect with the
> same name and will have two connections with the name.
> 
> =# SELECT dblink_connect(repeat('1234567890', 6) || 'ABC',
> 'host=localhost');
>  dblink_connect
> ----------------
>  OK
> (1 row)
> 
> =# SELECT dblink_get_connections();
>                       dblink_get_connections
> -------------------------------------------------------------------
>  {123456789012345678901234567890123456789012345678901234567890ABC}
> (1 row)
> 
> =# SELECT dblink_disconnect(repeat('1234567890', 6) || 'ABC');
> ERROR:  connection
> "123456789012345678901234567890123456789012345678901234567890ABC" not
> available

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center


Attachment: dblink_63bytes.patch
Description: application/octet-stream (2.5 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Giles LeanDate: 2010-06-01 02:58:28
Subject: Re: is_absolute_path incorrect on Windows
Previous:From: Robert HaasDate: 2010-06-01 02:40:35
Subject: Re: functional call named notation clashes with SQL feature

pgsql-bugs by date

Next:From: Pavel StehuleDate: 2010-06-01 04:44:49
Subject: Re: Bug in CREATE FUNCTION with character type (CONFIRMED BUG)
Previous:From: Takahiro ItagakiDate: 2010-06-01 02:17:15
Subject: BUG #5487: dblink failed with 63 bytes connection names

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group