Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lXHn3-000605-QX for pgsql-novice@arkaria.postgresql.org; Fri, 16 Apr 2021 06:17:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lXHn2-0008Of-Ot for pgsql-novice@arkaria.postgresql.org; Fri, 16 Apr 2021 06:17:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lXHn2-0008OY-I3 for pgsql-novice@lists.postgresql.org; Fri, 16 Apr 2021 06:17:16 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lXHmv-0004AO-PT for pgsql-novice@lists.postgresql.org; Fri, 16 Apr 2021 06:17:16 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id D3FD4173E; Fri, 16 Apr 2021 02:17:06 -0400 (EDT) Received: from imap38 ([10.202.2.88]) by compute3.internal (MEProxy); Fri, 16 Apr 2021 02:17:07 -0400 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=IJ/jri JXbCrQxZWgX1w1M9gtbSNzOsqo10MACPWMYLw=; b=BdQnqYtX+BNfy0M9VaXL5s Kwqy/a73/Fa0iwHidIEnuty1eAYqo9k46n8CD/6tgYnHJ80dvDhQiXQRQYUKzwSo Eeqr/KxkxsDWZ3Ri0qgSkIUK2wPR6FNgaEwzXWbIbfcDq5lbT1IkyOLk7VggErbY AThtbTrMeeSADAxOhVG4c5f2GZpz+AvCtoGp5HoRZWwPXUk5lgm/DlMK8D070hC0 Ni4BOLriwwDsdu/xbAiLTYmflG6VLRJgWB/6ngvDTAmU/QLJKuPc/6zvB7xBkw+p NYH4EosK9rGSg24cNo61OPpySnwkrdGVceAkmF+azfFtIdXXz/D4QBtm184rX9EQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudelgedguddtkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdduhedmnecujfgurhepof gfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdffrghnihgvlhcujfgv rghthhdfuceouggrnhhivghlsehhvggrthhhrdgttgeqnecuggftrfgrthhtvghrnhepgf fgkeeuledvffethffhudeghedtkefgledtudduvdeggedtgfehheeukeehvefhnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepuggrnhhivghlse hhvggrthhhrdgttg X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id E17F9CA005E; Fri, 16 Apr 2021 02:17:05 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-273-g8500d2492d-fm-20210323.002-g8500d249 Mime-Version: 1.0 Message-Id: <42a0fd97-8cb2-4615-b9a8-698dc7c55962@www.fastmail.com> In-Reply-To: <3969078.1618532221@sss.pgh.pa.us> References: <3969078.1618532221@sss.pgh.pa.us> Date: Fri, 16 Apr 2021 16:16:45 +1000 From: "Daniel Heath" To: "Tom Lane" Cc: pgsql-novice@lists.postgresql.org Subject: Re: Prepared statement invalidation Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Is there a transaction isolation mode that would help with the specific case of adding a column to a table? EG to prevent a prepared statement from seeing the new schema? Thanks, Daniel Heath On Fri, Apr 16, 2021, at 10:17 AM, Tom Lane wrote: > "Daniel Heath" writes: > > I've found that when I add a new column, I sometimes get a spike of errors on the application side due to prepared statement query plans getting invalidated, causing transactions to rollback. > > The error is: > > ERROR: cached plan must not change result type > > Is there a way to make postgres recalculate the query plan instead of failing the transaction when a new column is added? > > No. It'd be easy enough to remove that restriction on the server side, > but we're afraid that it would break applications, which probably aren't > expecting the result rowtype of a prepared query to be different from what > they were told (perhaps only milliseconds earlier). > > I'd say the short answer is "don't use prepared queries, or if you do, > spell out the columns you want instead of saying SELECT *". > > regards, tom lane > > > > > > Thanks, > > Daniel Heath > >