Re: plpgsql + dblink() question

From: Joe Conway <mail(at)joeconway(dot)com>
To: Frankie <frankie(at)ucr(dot)com(dot)hk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: plpgsql + dblink() question
Date: 2003-02-08 06:03:23
Message-ID: 3E449DAB.9050106@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Frankie wrote:
> The case is when I call a function (from Server 1 at psql prompt) that will
> call dblink to do some operation
> on another server(it will take certain time), i.e. Server 2, and meanwhile I
> just unplug the network cable to Server 2.
> The consequence is that the function will never return except I plug the
> cable into it again, moreover I cannot even cancel
> the query and stop the postgresql server (have to 'kill -9'.)

dblink just uses libpq to handle the communication, so you can use the
connect_timeout connection parameter. It defaults to infinite if not
explicitly set. Something like this should set a 5 second timeout:

select * into tmp from dblink(''host=linux dbname=twins connect_timeout=5'',
''select mysleep();'') as (retval text);

See:
http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/libpq-connect.html

HTH,

Joe

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Roberto Mello 2003-02-08 06:35:39 Re: query help/sugestions
Previous Message John Cavacas 2003-02-08 05:50:20 query help/sugestions