Re: [COMMITTERS] pgsql: Fix dblink to treat connection names longer than NAMEDATALEN-2

From: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Fix dblink to treat connection names longer than NAMEDATALEN-2
Date: 2010-06-08 06:17:20
Message-ID: 20100608151720.3606.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers


itagaki(at)postgresql(dot)org (Takahiro Itagaki) wrote:

> Fix dblink to treat connection names longer than NAMEDATALEN-2 (62 bytes).
> Now long names are adjusted with truncate_identifier() and NOTICE messages
> are raised if names are actually truncated.
>
> Modified Files:
> --------------
> pgsql/contrib/dblink:
> dblink.c (r1.91 -> r1.92)
> (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/dblink/dblink.c?r1=1.91&r2=1.92)

I had a mistake in the fix below. get_connect_string() is called
not only in the case of server-based connections, but also in
connection-string-based connections. If connection strings longer
than 63 bytes are passed the routine emits "identifier will be truncated"
warning. It is an incompatbile change.

Should we revert the change, or just adjust to call truncate_identifier
with warn=false ?

*************** get_connect_string(const char *servernam
*** 2390,2399 ****
StringInfo buf = makeStringInfo();
ForeignDataWrapper *fdw;
AclResult aclresult;

/* first gather the server connstr options */
! if (strlen(servername) < NAMEDATALEN)
! foreign_server = GetForeignServerByName(servername, true);

if (foreign_server)
{
--- 2390,2401 ----
StringInfo buf = makeStringInfo();
ForeignDataWrapper *fdw;
AclResult aclresult;
+ char *srvname;

/* first gather the server connstr options */
! srvname = pstrdup(servername);
! truncate_identifier(srvname, strlen(srvname), true);
! foreign_server = GetForeignServerByName(srvname, true);

if (foreign_server)
{

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

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Teodor Sigaev 2010-06-08 09:31:28 Re: pgsql: Add missed function dblink_connect_u(text[,text]) to uninstall
Previous Message User Itagaki 2010-06-08 02:54:51 pgbulkload - pgbulkload: Added English documentation.

Browse pgsql-hackers by date

  From Date Subject
Next Message Koichi Suzuki 2010-06-08 06:19:43 pg_lesslog 1.4.2 beta now available
Previous Message Koichi Suzuki 2010-06-08 06:06:33 How to generate specific WAL records again for PostgreSQL 9.0?