pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Japin Li <japinli@hotmail.com>
Cc: adrien.gilmore+pg@gmail.com
Cc: 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
Date: Fri, 21 Jan 2022 23:15:25 -0500
Message-ID: <1318100.1642824925@sss.pgh.pa.us> (raw)
In-Reply-To: <MEYP282MB1669B9CC5478AF0421227FA8B65C9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM>
References: <17376-07b867ccc817828f@postgresql.org>
	<MEYP282MB166905F8F98ED50AD619CB54B65B9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM>
	<1196187.1642786604@sss.pgh.pa.us>
	<MEYP282MB1669B9CC5478AF0421227FA8B65C9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM>

Japin Li <japinli@hotmail.com> writes:
> On Sat, 22 Jan 2022 at 01:36, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> 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.

> Right.

>> Maybe it'd be sufficient to check for an active ALTER TABLE in the
>> parser, but I'm not sure.

> Do you mean check the table is accessed by ALTER TABLE when calling SPI to
> execute the function?  How can we get the table that is be accessed by
> ALTER TABLE in parser?

The reason there's not a problem like this with respect to cross-session
accesses is that the exclusive lock acquired by ALTER TABLE prevents
other sessions from touching the table.  Conversely, the reason we do
have a problem here is that such locks don't prevent accesses within
our own session.  So a rough sketch for fixing this might be "at
the point where we acquire a lock on some table for a new statement,
also check to see if some internal-to-our-session operation has
declared a need for exclusive access".  The problem is that we don't
have a well-defined line as to what's part of the ALTER and what
is not.  For example, I recall that ALTER TABLE handles index rebuilding
by creating textual ALTER ADD INDEX commands, and parsing and executing
those.  How can we distinguish that behavior from a SQL function within
an index or CHECK constraint trying to execute ALTER ADD INDEX?

			regards, tom lane





view thread (6+ messages)  latest in thread

Message-ID: <1318100.1642824925@sss.pgh.pa.us>
Permalink:  ../1318100.1642824925@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1318100.1642824925@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, japinli@hotmail.com, 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: <1318100.1642824925@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox