Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3IFB-0003Om-WE for pgsql-general@arkaria.postgresql.org; Tue, 03 Apr 2018 09:28:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f3IFA-0002TN-93 for pgsql-general@arkaria.postgresql.org; Tue, 03 Apr 2018 09:28:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3IFA-0002TE-11 for pgsql-general@lists.postgresql.org; Tue, 03 Apr 2018 09:28:44 +0000 Received: from mx1.mailbox.org ([80.241.60.212]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f3IF6-0001tU-NG for pgsql-general@lists.postgresql.org; Tue, 03 Apr 2018 09:28:43 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 7D59442BE5; Tue, 3 Apr 2018 11:28:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id oV3agsYXzDUj; Tue, 3 Apr 2018 11:28:12 +0200 (CEST) Message-ID: <1522747691.2414.5.camel@cybertec.at> Subject: Re: dblink: could not send query: another command is already in progress From: Laurenz Albe To: Thiemo Kellner , PostgreSQL General Date: Tue, 03 Apr 2018 11:28:11 +0200 In-Reply-To: <62f4ba30-6302-89af-2341-16c821427158@gelassene-pferde.biz> References: <8d6c6faa-4878-68bf-d1b7-6b1f86c1445c@gelassene-pferde.biz> <1522388386.2396.2.camel@cybertec.at> <1522401246.2396.16.camel@cybertec.at> <62f4ba30-6302-89af-2341-16c821427158@gelassene-pferde.biz> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thiemo Kellner wrote: > On 03/30/18 11:14, Laurenz Albe wrote: > > You have to consume the result before you can send the next query. > > I changed implementation but still get the same error but now different > context. I tried to retrieve the result but I failed > > I committed the last code to its project repository at SourceForge > https://sourceforge.net/p/pglogger/code/HEAD/tree/ > > and put the code to pastebin.com > Test calls: https://pastebin.com/xfUp9NAL > function WRITE_MESSAGE: https://pastebin.com/LDjE0Czx > function WRITE_MESSAGE_TO_TABLE: https://pastebin.com/vkBkehZF > > [...] > psql:testing/test.pg_sql:42: ERROR: function > WRITE_MESSAGE_TO_TABLE(i_function => text, i_message => text, i_level => > text, i_present_user => name, i_session_user => name, > i_transaction_timestamp => timestamp with time zone, i_transaction_id => > bigint, i_server_pid => bigint, i_remote_address => inet, i_remote_port > => integer) does not exist > HINT: No function matches the given name and argument types. You might > need to add explicit type casts. > CONTEXT: Error occurred on dblink connection named > "PGLOGGER_CONNECTION": could not execute query. > SQL statement "SELECT * from > dblink_get_result(V_DBLINK_CONNECTION_NAME) as t(ID bigint)" > PL/pgSQL function write_message(text,text) line 126 at PERFORM > psql:testing/test.pg_sql:42: STATEMENT: select WRITE_MESSAGE('Test > WRITE_MESSAGE 2nd call', 'NOTICE'); I couldn't dig through all your code, but two things seemed suspicious: > if ( > V_DBLINK_CONNECTION_NAMES is null > or V_DBLINK_CONNECTION_NAME != any(V_DBLINK_CONNECTION_NAMES) I don't think you want "!=ANY" there. Shouldn't that be "<>ALL" ? "<>ANY" will *always* be true if there are at least two different entries. 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. One of your error messages above seems to suggest that this is your problem. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com