Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJrAc-00032D-0Q for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Dec 2016 00:23:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cJrAb-0001PY-I9 for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Dec 2016 00:23:41 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cJr9D-0008G7-0z for pgsql-hackers@postgresql.org; Thu, 22 Dec 2016 00:22:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cJr99-0005G1-QM for pgsql-hackers@postgresql.org; Thu, 22 Dec 2016 00:22:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id uBM0M9aD019853; Wed, 21 Dec 2016 19:22:09 -0500 From: Tom Lane To: Joe Conway cc: pgsql-hackers@postgresql.org Subject: Re: Getting rid of "unknown error" in dblink and postgres_fdw In-reply-to: <02fa2d90-2efd-00bc-fefc-c23c00eb671e@joeconway.com> References: <19872.1482338965@sss.pgh.pa.us> <21630.1482341251@sss.pgh.pa.us> <1312.1482343733@sss.pgh.pa.us> <02fa2d90-2efd-00bc-fefc-c23c00eb671e@joeconway.com> Comments: In-reply-to Joe Conway message dated "Wed, 21 Dec 2016 16:12:34 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19851.1482366129.1@sss.pgh.pa.us> Date: Wed, 21 Dec 2016 19:22:09 -0500 Message-ID: <19852.1482366129@sss.pgh.pa.us> X-Pg-Spam-Score: -5.0 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Joe Conway writes: > I did notice that postgres_fdw has the following stanza that I don't see > in dblink: > 8<------------------ > /* > * If we don't get a message from the PGresult, try the PGconn. This > * is needed because for connection-level failures, PQexec may just > * return NULL, not a PGresult at all. > */ > if (message_primary == NULL) > message_primary = PQerrorMessage(conn); > 8<------------------ > I wonder if the original issue on pgsql-bugs was a connection-level > failure rather than OOM? Seems like dblink ought to do the same. Oooh ... I had thought that code was in both, which was why I was having a hard time explaining the OP's failure. But I see you're right, which provides a very straightforward explanation for the report. I believe that if libpq is unable to malloc a PGresult, it will return NULL but put an "out of memory" message into the PGconn's error buffer. I had supposed that we'd capture and report the latter, but as the dblink code stands, it won't. In short, yes, please copy that bit into dblink. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers