Re: BUG #17376: Adding unique column with a function() default results in "could not read block 0 in file" error

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #17376: Adding unique column with a function() default results in "could not read block 0 in file" error
Дата
Msg-id 1318100.1642824925@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #17376: Adding unique column with a function() default results in "could not read block 0 in file" error  (Japin Li <japinli@hotmail.com>)
Список pgsql-bugs
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



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Japin Li
Дата:
Сообщение: Re: BUG #17376: Adding unique column with a function() default results in "could not read block 0 in file" error
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #17376: Adding unique column with a function() default results in "could not read block 0 in file" error