Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t18b5-00Et2f-Qk for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Oct 2024 18:18:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t18b4-007jDa-1Q for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Oct 2024 18:18:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t18b3-007jCr-Ny for pgsql-hackers@lists.postgresql.org; Wed, 16 Oct 2024 18:18:10 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t18b1-001Dsz-JA for pgsql-hackers@lists.postgresql.org; Wed, 16 Oct 2024 18:18:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 49GIHwus204605; Wed, 16 Oct 2024 14:17:58 -0400 From: Tom Lane To: jian he cc: Pavel Stehule , Christoph Berg , Michael Banck , Tommy Pavlicek , =?UTF-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= , pgsql-hackers@lists.postgresql.org Subject: Re: Better error reporting from extension scripts (Was: Extend ALTER OPERATOR) In-reply-to: References: <560086.1698160614@sss.pgh.pa.us> <570833.1698162135@sss.pgh.pa.us> <66f33840.050a0220.1f9e60.7fb9@mx.google.com> <325394.1727365907@sss.pgh.pa.us> <571930.1727454668@sss.pgh.pa.us> <621972.1727459684@sss.pgh.pa.us> <1092841.1727552736@sss.pgh.pa.us> <2245576.1728418678@sss.pgh.pa.us> <3482022.1728839631@sss.pgh.pa.us> <3748500.1728924327@sss.pgh.pa.us> Comments: In-reply-to jian he message dated "Tue, 15 Oct 2024 15:10:32 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <204603.1729102678.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 16 Oct 2024 14:17:58 -0400 Message-ID: <204604.1729102678@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian he writes: > just found out the"elog(INFO, "should not reached here");" part never re= ached. You didn't check any of the cases we were discussing I guess? (That is, places in gram.y that throw an error without a parser_errposition call.) Note that even if we fix all of those and keep them fixed, we still couldn't assume the case is unreachable, because gram.y isn't self-contained. For instance, if we hit out-of-memory during raw parsing, the OOM error out of mcxt.c isn't going to provide a syntax error position. I'm not too concerned about doing better than what the patch does now (i.e. nothing) in such edge cases, but we can't do worse. > i guess, we don't need performance in script_error_callback, > but in script_error_callback arrange code seperate syntax error(raw > parser) and other error seems good. > please check the attached minor refactor. I do not think that's an improvement. It's more complicated and less readable, and I don't see why we need to squeeze more performance out of this error-reporting path that should never be taken in production. regards, tom lane