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 1t02AV-009CZJ-9M for pgsql-hackers@arkaria.postgresql.org; Sun, 13 Oct 2024 17:14: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 1t02AT-005pgi-70 for pgsql-hackers@arkaria.postgresql.org; Sun, 13 Oct 2024 17:14:09 +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 1t02AS-005pga-Sv for pgsql-hackers@lists.postgresql.org; Sun, 13 Oct 2024 17:14:09 +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 1t02AQ-000haC-Lf for pgsql-hackers@lists.postgresql.org; Sun, 13 Oct 2024 17:14:07 +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 49DHDpbV3482023; Sun, 13 Oct 2024 13:13:51 -0400 From: Tom Lane To: Pavel Stehule cc: jian he , 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> Comments: In-reply-to Pavel Stehule message dated "Sun, 13 Oct 2024 18:48:03 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3482021.1728839631.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sun, 13 Oct 2024 13:13:51 -0400 Message-ID: <3482022.1728839631@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Pavel Stehule writes: > so 12. 10. 2024 v 9:33 odesílatel jian he > napsal: >> + /* >> + * If we have a location (which, as said above, we really always should) >> + * then report a line number to aid in localizing problems in big scripts. >> + */ >> + if (location >= 0) >> so this part will always be true? > yes, after CleanQuerytext the location should not be -1 ever Right, but we might not have entered either of those previous if-blocks. The question here is whether the raw parser (gram.y) ever throws an error that doesn't include a cursor position. IMO it shouldn't, but a quick look through gram.y finds a few ereports that lack parser_errposition. We could go fix those, and probably should, but imagining that none will ever be introduced again seems like folly. regards, tom lane