Re: Getting "could not read block" error when creating an index on a function.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Getting "could not read block" error when creating an index on a function.
Дата
Msg-id 2344514.1609347027@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Getting "could not read block" error when creating an index on a function.  (Demitri Muna <postgresql@demitri.com>)
Ответы Re: Getting "could not read block" error when creating an index on a function.
Список pgsql-general
Demitri Muna <postgresql@demitri.com> writes:
> I’m getting stuck on a problem I was hoping I could get some help with. I’m trying to create an index for the results
ofa function that touches two tables like this and get the following error: 

> CREATE INDEX my_idx ON mytable (first_time(id));
> ERROR:  could not read block 0 in file "base/16386/42868": read only 0 of 8192 bytes
> CONTEXT:  SQL function "first_time" during startup

What's apparently happening is that some query in the function is trying
to examine the newly-created index before it's been populated.

I would call this a bug if it were a supported case, but really you are
doing something you are not allowed to.  Functions in indexed expressions
are required to be immutable, and a function that looks at the contents of
a table --- particularly the very table that the index is on --- is simply
not going to be that.  Marking such a function immutable to try to end-run
around the restriction is unsafe.

            regards, tom lane



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Problem with ssl and psql in Postgresql 13
Следующее
От: Demitri Muna
Дата:
Сообщение: Re: Getting "could not read block" error when creating an index on a function.