pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: pgsql-hackers@lists.postgresql.org
Subject: issue in pgfdw_report_error()?
Date: Fri, 19 Nov 2021 17:18:22 +0900
Message-ID: <477c16c8-7ea4-20fc-38d5-ed3a77ed616c@oss.nttdata.com> (raw)

Hi,

pgfdw_report_error() in postgres_fdw is implemented to report the message
"could not obtain ..." if message_primary is NULL as follows.
But, just before this ereport(), message_primary is set to
pchomp(PQerrorMessage()) if it's NULL. So ISTM that message_primary is
always not NULL in ereport() and the message "could not obtain ..." is
never reported. Is this a bug?

-------------------
if (message_primary == NULL)
	message_primary = pchomp(PQerrorMessage(conn));

ereport(elevel,
		(errcode(sqlstate),
		 message_primary ? errmsg_internal("%s", message_primary) :
		 errmsg("could not obtain message string for remote error"),
-------------------


If this is a bug, IMO the following change needs to be applied. Thought?

-------------------
                 ereport(elevel,
                                 (errcode(sqlstate),
-                                message_primary ? errmsg_internal("%s", message_primary) :
+                                (message_primary != NULL && message_primary[0] != '\0') ?
+                                errmsg_internal("%s", message_primary) :
                                  errmsg("could not obtain message string for remote error"),
-------------------

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION





view thread (7+ messages)  latest in thread

Message-ID: <477c16c8-7ea4-20fc-38d5-ed3a77ed616c@oss.nttdata.com>
Permalink:  ../477c16c8-7ea4-20fc-38d5-ed3a77ed616c@oss.nttdata.com/
Also on:    postgresql.org/message-id/477c16c8-7ea4-20fc-38d5-ed3a77ed616c@oss.nttdata.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: masao.fujii@oss.nttdata.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: issue in pgfdw_report_error()?
  In-Reply-To: <477c16c8-7ea4-20fc-38d5-ed3a77ed616c@oss.nttdata.com>

* 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