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 1qYYwS-0025L9-0L for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Aug 2023 21:29:36 +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 1qYYwQ-005Rho-Rs for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Aug 2023 21:29:34 +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 1qYYwQ-005RhM-H2 for pgsql-hackers@lists.postgresql.org; Tue, 22 Aug 2023 21:29:34 +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 1qYYwN-000PCA-G7 for pgsql-hackers@lists.postgresql.org; Tue, 22 Aug 2023 21:29:33 +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 37MLTPMW3211511; Tue, 22 Aug 2023 17:29:25 -0400 From: Tom Lane To: Robert Haas cc: Peter Eisentraut , paul.kulakov@systematica.ru, pgsql-hackers@lists.postgresql.org Subject: Re: BUG #18059: Unexpected error 25001 in stored procedure In-reply-to: References: <18059-79c692f036b25346@postgresql.org> <2341329.1692465562@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Mon, 21 Aug 2023 09:32:27 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3211509.1692739765.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Tue, 22 Aug 2023 17:29:25 -0400 Message-ID: <3211510.1692739765@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > On Sat, Aug 19, 2023 at 1:19 PM Tom Lane wrote: >> What I'm inclined to propose, therefore, is that we make revalidation >> be a no-op for every statement type for which transformStmt() reaches >> its default: case. (When it does so, the resulting CMD_UTILITY Query >> will not get any processing from the rewriter or planner either.) > That sounds like the right thing. It is perhaps unfortunate that we > don't have a proper parse analysis/execution distinction for other > types of statements, but if that ever changes then this can be > revisited. I started to code this, and immediately noticed that transformStmt() already has a companion function analyze_requires_snapshot() that returns "true" in the cases of interest ... except that it does not return true for T_CallStmt. Perhaps that was intentional to begin with, but it is very hard to believe that it isn't a bug now, since transformCallStmt can invoke nearly arbitrary processing via transformExpr(). What semantic anomalies, if any, do we risk if CALL processing forces a transaction start? (I rather imagine it does already, somewhere later on...) Anyway, I'm now of two minds whether to use analyze_requires_snapshot() as-is for plancache.c's invalidation test, or duplicate it under a different name, or have two names but one is just an alias for the other. It still seems like "analyze requires snapshot" isn't necessarily the exact inverse condition of "analyze is a no-op", but it is today (assuming we agree that CALL needs a snapshot), and maybe maintaining two duplicate functions is silly. Thoughts? regards, tom lane