From: Takahiro Itagaki on

itagaki(a)postgresql.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



--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers