pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Thiemo Kellner <thiemo@gelassene-pferde.biz>
To: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: dblink: could not send query: another command is already in progress
Date: Wed, 04 Apr 2018 08:11:56 +0200
Message-ID: <1522822316.2456.9.camel@cybertec.at> (raw)
In-Reply-To: <f2f51a9f-bfc7-53b2-5c44-1881c796d7e0@gelassene-pferde.biz>
References: <8d6c6faa-4878-68bf-d1b7-6b1f86c1445c@gelassene-pferde.biz>
	<1522388386.2396.2.camel@cybertec.at>
	<fc1691cf-dde4-f6fd-71f2-a92836a446f5@gelassene-pferde.biz>
	<1522401246.2396.16.camel@cybertec.at>
	<62f4ba30-6302-89af-2341-16c821427158@gelassene-pferde.biz>
	<1522747691.2414.5.camel@cybertec.at>
	<f2f51a9f-bfc7-53b2-5c44-1881c796d7e0@gelassene-pferde.biz>

Thiemo Kellner wrote:
> > The other thing is that you seem to call "dblink_get_result" on any existing
> > connection before use.  But you can only call the function if there is a
> > result outstanding.
> 
> I call dblink_get_result only if I do not open a dblink connection, i. 
> e. only on second and following function calls. I put more notice output 
> into the code showing that dblink_send_query has been called once before 
> the first call of dblink_get_result. I changed my query to reflect 
> return bigint value of the called function write_message_to_table. Error 
> persists.

That's not going to work.
You can only call dblink_get_result if there is an outstanding result.
You cannot call it on an idle connection, that will cause an error.

You should write your code so that whenever dblink_send_query has been
called, you also call dblink_get_result, regardless if the query has
been cancelled or not, so that you always leave the connection in
the "ready for query" state.
Then you don't have to clean up.

Of course you could also ignore the error you get on dblink_get_result,
but that is ugly.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com




view thread (8+ messages)

Message-ID: <1522822316.2456.9.camel@cybertec.at>
Permalink:  ../1522822316.2456.9.camel@cybertec.at/
Also on:    postgresql.org/message-id/1522822316.2456.9.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, thiemo@gelassene-pferde.biz
  Subject: Re: dblink: could not send query: another command is already in progress
  In-Reply-To: <1522822316.2456.9.camel@cybertec.at>
  References: <8d6c6faa-4878-68bf-d1b7-6b1f86c1445c@gelassene-pferde.biz> <1522388386.2396.2.camel@cybertec.at> <fc1691cf-dde4-f6fd-71f2-a92836a446f5@gelassene-pferde.biz> <1522401246.2396.16.camel@cybertec.at> <62f4ba30-6302-89af-2341-16c821427158@gelassene-pferde.biz> <1522747691.2414.5.camel@cybertec.at> <f2f51a9f-bfc7-53b2-5c44-1881c796d7e0@gelassene-pferde.biz> <1522822316.2456.9.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox