Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jF78x-0002Ql-5Y for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Mar 2020 02:12:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jF78v-0006OI-ET for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Mar 2020 02:12:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jF78v-0006OB-1v for pgsql-hackers@lists.postgresql.org; Fri, 20 Mar 2020 02:12:13 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jF78s-0002n6-91 for pgsql-hackers@lists.postgresql.org; Fri, 20 Mar 2020 02:12:11 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 800CC6B5; Thu, 19 Mar 2020 22:12:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 19 Mar 2020 22:12:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=fT2gKxM91cMwnV++tgSCQ+bS7r9 xeMlfwrnW+lnkGt4=; b=dIEOWD51iAvXyCAT6Jxh0uJA6XBo0Ym++sTvrZ6+24x 2xVDqCzFqPRyhDoAaEPD5YipkyCg3zJ5zT1rnkOACrjoYyVxidbPeDup0eXPys14 x/MDObn85/34mhwcKDMjwX9LU7qm7zefeqvv1NULJQStnAjJrdBvuaTnDx2s/mAM SkW47+hnhDvNx6Rrm4jNzoA/JHfGz/cmz6HQYFZ1+DQbnveQFVGqn62KAqnQ3b6n S6x94KkUfBEkxVp0gtxcKNtLilYnZc+VBK2tPNQ9/nCOGFUVFzjRPVCroI5jXCsh IghxKR9jBenTn2Yxf6Jrj/dM3M2fPkWAyd3CrtHFdoQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=fT2gKx M91cMwnV++tgSCQ+bS7r9xeMlfwrnW+lnkGt4=; b=t70wshM1YnZJY1o4CnFTLN t6WBHyy4so5ihr6qu935arv2CE39QZVEL7a82bZKMYhmNBGhHbxbWMdd34imgGBw N4LyeR0Z1tu6Be0wDLj9+vfb0gUGAJwcwfo1kryEfwPSvzEYHmBMQlZSdB8JI6RZ stIq17aFeNxN+Ag7L/4KCsSOiTJ5hD4xz4g78clClP0V87zMpqQ81bGNTgk+3Ck1 JtuzwtUH8/2V9feO0iL+gUzCce0PXFC/CuxHxrncpKl6hTcXN9wCHn+AfXJcrutM dktSNFQMCcg+CSrjOaEY9+AGwTkaFimDEJxWIsVYwNrb0mU4UvjYp6l7V2HSZL7g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrudegtddggeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucfkphepie ejrdduiedtrddvudejrddvhedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-217-250.hsd1.ca.comcast.net [67.160.217.250]) by mail.messagingengine.com (Postfix) with ESMTPA id 2A9D73280066; Thu, 19 Mar 2020 22:12:06 -0400 (EDT) Date: Thu, 19 Mar 2020 19:12:04 -0700 From: Andres Freund To: Tom Lane Cc: Amit Kapila , Michael Paquier , Julien Rouhaud , Masahiko Sawada , PostgreSQL Hackers Subject: Re: Missing errcode() in ereport Message-ID: <20200320021204.flrybgh4a7wltzye@alap3.anarazel.de> References: <20200317095839.GG2206@paquier.xyz> <32174.1584454158@sss.pgh.pa.us> <20200319175902.vjib2tslosw65iyr@alap3.anarazel.de> <5063.1584641224@sss.pgh.pa.us> <20200319230446.lxjybufdcgwaqkhj@alap3.anarazel.de> <5995.1584660775@sss.pgh.pa.us> <18567.1584666197@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18567.1584666197@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2020-03-19 21:03:17 -0400, Tom Lane wrote: > I wrote: > > I think that at least some compilers will complain about side-effect-free > > subexpressions of a comma expression. Could we restructure things so > > that the errcode/errmsg/etc calls form a standalone comma expression > > rather than appearing to be arguments of a varargs function? > > Yeah, the attached quick-hack patch seems to work really well for > this. Heh, you're too fast. I just sent something similar, and a few followup patches. What is your thinking about pain around backpatching it might introduce? We can't easily backpatch support for ereport-without-extra-parens, I think, because it needs __VA_ARGS__? > As a nice side benefit, the backend gets a couple KB smaller from > removal of errfinish's useless dummy argument. I don't think it's the removal of the dummy parameter itself that constitutes most of the savings, but instead it's not having to push the return value of errmsg(), errcode(), et al as vararg arguments. > I think that we could now also change all the helper functions > (errmsg et al) to return void instead of a dummy value, but that > would make the patch a lot longer and probably not move the > goalposts much in terms of error detection. I did include that in my prototype patch. Agree that it's not necessary for the error detection capability, but it seems misleading to leave the return values around if they're not actually needed. > It also looks like we could use the same trick to get plain elog() > to have the behavior of not evaluating its arguments when it's > not going to print anything. I've not poked at that yet either. I've included a patch for that. I think it's now sufficient to #define elog(elevel, ...) \ ereport(elevel, errmsg(__VA_ARGS__)) which imo is quite nice, as it allows us to get rid of a lot of duplication. Greetings, Andres Freund