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 1nAxqI-0003Pi-Du for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jan 2022 17:36:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nAxqH-0002jl-45 for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jan 2022 17:36:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAxqG-0002jb-SA for pgsql-bugs@lists.postgresql.org; Fri, 21 Jan 2022 17:36:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAxqE-0002Om-I9 for pgsql-bugs@lists.postgresql.org; Fri, 21 Jan 2022 17:36:51 +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 20LHaiuT1196188; Fri, 21 Jan 2022 12:36:44 -0500 From: Tom Lane To: Japin Li cc: adrien.gilmore+pg@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17376: Adding unique column with a function() default results in "could not read block 0 in file" error In-reply-to: References: <17376-07b867ccc817828f@postgresql.org> Comments: In-reply-to Japin Li message dated "Sat, 22 Jan 2022 01:27:55 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1196186.1642786604.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 21 Jan 2022 12:36:44 -0500 Message-ID: <1196187.1642786604@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Japin Li writes: > On Fri, 21 Jan 2022 at 17:22, PG Bug reporting form wrote: >> The error message content returned is what I suspect of being a bug, no= t so >> much that this SQL didn't work. > +1. The error message makes user confused IMO, maybe we can fix it, but = I have > no idea for this. Any suggestion is welcomed. Yeah. Ideally we'd throw an error along the lines of "can't access a table that's in process of being altered". The SELECT inside the function is not part of the ALTER TABLE machinery and ought to be locked out. However, I fear we don't have adequate infrastructure to tell which table accesses *are* part of the ALTER TABLE machinery and which aren't. Maybe it'd be sufficient to check for an active ALTER TABLE in the parser, but I'm not sure. regards, tom lane