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

Re: use of dblink_build_sql_insert() induces a server crash

From: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: use of dblink_build_sql_insert() induces a server crash
Date: 2010-02-03 12:49:33
Message-ID: 460abcb11002030449q873b784kd8a0f1c0a7520ee1@mail.gmail.com (view raw)
Hi All,

Testcase:

create table foo (a  int );
postgres=# SELECT dblink_build_sql_insert('foo','1 2',2,'{\"0\",
\"a\"}','{\"99\", \"xyz\"}');
HINT:  Use the escape string syntax for escapes, e.g., E'\r\n'.
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

Version: Latest

Description:  The dblink_build_sql_insert()/get_tuple_of_interest functions
is not taking care number of attributes in the target.

PFA patch to fix the same.

Thanks,
Rushabh Lathia
(www.EnterpriseDB.com)
Attachment: dblink.patch
Description: text/x-diff (603 bytes)
From: Joe Conway <mail(at)joeconway(dot)com>
To: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: use of dblink_build_sql_insert() induces a server crash
Date: 2010-02-03 17:26:52
Message-ID: 4B69B1DC.8030208@joeconway.com (view raw)
On 02/03/2010 04:49 AM, Rushabh Lathia wrote:
> Testcase:
> 
> create table foo (a  int );
> postgres=# SELECT dblink_build_sql_insert('foo','1 2',2,'{\"0\",
> \"a\"}','{\"99\", \"xyz\"}');
> HINT:  Use the escape string syntax for escapes, e.g., E'\r\n'.
> server closed the connection unexpectedly

Thanks for the report -- will have a look later today.

Joe


From: Joe Conway <mail(at)joeconway(dot)com>
To: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: use of dblink_build_sql_insert() induces a server crash
Date: 2010-02-03 18:08:16
Message-ID: 4B69BB90.5050607@joeconway.com (view raw)
On 02/03/2010 04:49 AM, Rushabh Lathia wrote:
> 
> create table foo (a  int );
> postgres=# SELECT dblink_build_sql_insert('foo','1 2',2,'{\"0\",
> \"a\"}','{\"99\", \"xyz\"}');
> HINT:  Use the escape string syntax for escapes, e.g., E'\r\n'.
> server closed the connection unexpectedly

The problem exists with all three dblink_build_sql_* functions. Here is
a more complete patch. If there are no objections I'll apply this to
HEAD and look at back-patching -- these functions have hardly been
touched since inception.

Joe
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: use of dblink_build_sql_insert() induces a server crash
Date: 2010-02-03 18:18:00
Message-ID: 446.1265221080@sss.pgh.pa.us (view raw)
Joe Conway <mail(at)joeconway(dot)com> writes:
> The problem exists with all three dblink_build_sql_* functions. Here is
> a more complete patch. If there are no objections I'll apply this to
> HEAD and look at back-patching -- these functions have hardly been
> touched since inception.

Do you really need to copy the relation tupdesc when you only are going
to make a one-time check of the number of attributes?  This coding would
make some sense if you intended to use the tupdesc again later in the
functions, but it appears you don't.

Also, what about cases where the relation contains dropped columns ---
it's not obvious whether this test is correct in that case.

			regards, tom lane

From: Joe Conway <mail(at)joeconway(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: use of dblink_build_sql_insert() induces a server crash
Date: 2010-02-03 19:39:14
Message-ID: 4B69D0E2.4000703@joeconway.com (view raw)
On 02/03/2010 10:18 AM, Tom Lane wrote:
> Joe Conway <mail(at)joeconway(dot)com> writes:
>> The problem exists with all three dblink_build_sql_* functions. Here is
>> a more complete patch. If there are no objections I'll apply this to
>> HEAD and look at back-patching -- these functions have hardly been
>> touched since inception.
> 
> Do you really need to copy the relation tupdesc when you only are going
> to make a one-time check of the number of attributes?  This coding would
> make some sense if you intended to use the tupdesc again later in the
> functions, but it appears you don't.
> 
> Also, what about cases where the relation contains dropped columns ---
> it's not obvious whether this test is correct in that case.

Good input, as always. Here's another whack at it.

Thanks,

Joe


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