From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Japin Li <japinli(at)hotmail(dot)com> |
Cc: | adrien(dot)gilmore+pg(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #17376: Adding unique column with a function() default results in "could not read block 0 in file" error |
Date: | 2022-01-22 04:15:25 |
Message-ID: | 1318100.1642824925@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Japin Li <japinli(at)hotmail(dot)com> writes:
> On Sat, 22 Jan 2022 at 01:36, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2022-01-22 06:33:18 | Re: BUG #17376: Adding unique column with a function() default results in "could not read block 0 in file" error |
Previous Message | Japin Li | 2022-01-22 00:18:14 | Re: BUG #17376: Adding unique column with a function() default results in "could not read block 0 in file" error |