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 1rqEyg-00BL6B-FV for pgsql-jdbc@arkaria.postgresql.org; Fri, 29 Mar 2024 16:21:14 +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 1rqEyf-002mrY-FC for pgsql-jdbc@arkaria.postgresql.org; Fri, 29 Mar 2024 16:21:13 +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 1rqEyf-002mrQ-8A for pgsql-jdbc@lists.postgresql.org; Fri, 29 Mar 2024 16:21:13 +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 1rqEya-0074sN-JW for pgsql-jdbc@lists.postgresql.org; Fri, 29 Mar 2024 16:21:12 +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 42TGL6fk002951; Fri, 29 Mar 2024 12:21:06 -0400 From: Tom Lane To: Dave Cramer cc: James Pang , pgsql-jdbc@lists.postgresql.org, Laurenz Albe Subject: Re: cached plan must not change result type In-reply-to: References: <60ab210d02748b5da813007ab2504606d0fecaa1.camel@cybertec.at> Comments: In-reply-to Dave Cramer message dated "Fri, 29 Mar 2024 11:45:09 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2949.1711729266.1@sss.pgh.pa.us> Date: Fri, 29 Mar 2024 12:21:06 -0400 Message-ID: <2950.1711729266@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dave Cramer writes: > This is really an issue that needs to be solved in the backend. The error > is coming from PostgreSQL and what should happen is that when you alter a > table that a server prepared statement relies on the backend should send a > message to tell us that all of the prepared statements that rely on are now > invalid and we can reprepare them. This is something that can't change without a wire protocol change. There is nothing in the protocol that allows the backend to send out a message like "oh, that Describe I sent you awhile back? It might be a lie now" at random times. Also, what do you want to do about race conditions --- that is, what if you fire off an Execute only to find that one of those messages was already in flight to you? A non-racy way to handle it might be for Bind/Execute to refuse to run the query if its output has changed since the last Describe, which we could check after acquiring table locks during Bind. But we'd want to define "refuse" in a way that doesn't abort the transaction, and that's a concept that doesn't exist in the protocol at all. regards, tom lane