From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | aasat <satriani(at)veranet(dot)pl> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Bug: dblink_send_query not work on 9.2? |
Date: | 2013-01-10 02:10:10 |
Message-ID: | 11923.1357783810@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
aasat <satriani(at)veranet(dot)pl> writes:
> This work
> do $$
> begin
> perform dblink.dblink_connect('internal');
I believe that creates an unnamed connection referencing a foreign
server definition named "internal".
> perform dblink.dblink_exec('internal', 'set application_name=''dblink'';',
> true);
This is going to find that "internal" is not the name of any known
dblink connection (since the one that does exist is unnamed). So it
creates a transient connection of its own using "internal" as a
connection string, ie a fresh reference to the foreign server. For the
duration of this command, there are two connections to the remote
database.
> perform dblink.dblink_disconnect();
And that closes the unnamed connection.
> perform dblink.dblink_send_query('internal', 'select dummy();');
This is going to fail because there is no dblink connection named
"internal". Unlike dblink_exec, there is no support for making a
transient connection for just the duration of the function call,
since it wouldn't be sensible --- the connection has to persist
so you can get the result back.
Use the two-parameter form of dblink_connect() so you can make a
named connection.
> It's works without problems on version 9.0
Consulting the commit logs, I see that that was a bug we fixed
as of 9.1.
Author: Joe Conway <mail(at)joeconway(dot)com>
Branch: master Release: REL9_2_BR [8af3596d6] 2011-06-25 15:58:07 -0700
Branch: REL9_1_STABLE Release: REL9_1_0 [e4fb58f89] 2011-06-25 15:40:49 -0700
Async dblink functions require a named connection, and therefore should
use DBLINK_GET_NAMED_CONN rather than DBLINK_GET_CONN.
Problem found by Peter Eisentraut and patch by Fujii Masao.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2013-01-10 04:30:58 | Re: Database connections seemingly hanging |
Previous Message | Alexander Gataric | 2013-01-10 02:00:59 | Custom JDBC wrapper for DB2 Fed Server |