public inbox for [email protected]
help / color / mirror / Atom feedRe: ERROR: could not read block 0 in file when creating an index out of a function
2+ messages / 2 participants
[nested] [flat]
* Re: ERROR: could not read block 0 in file when creating an index out of a function
@ 2025-03-12 11:54 Artur Zakirov <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Artur Zakirov @ 2025-03-12 11:54 UTC (permalink / raw)
To: Luca Ferrari <[email protected]>; +Cc: pgsql-general <[email protected]>
Hey,
On Wed, 12 Mar 2025 at 10:11, Luca Ferrari <[email protected]> wrote:
> Now, according to the documentation, the function f_t is immutable
> since it is not modifying the database, so what is going on? And why
> is the same function working if the table has not the constraint on
> the column?
I can reproduce this with the table `t` on PG 15.10.
In your case `base/357283/365810` file is a new index file. For some
reason Postgres tries to read the new index. I suppose this is because
during reading the table `t` within the function `f_t` it tries to
access the new index.
According to the documentation, IMMUTABLE functions should not only
modify the database, but also return the same results given the same
arguments forever, which might not be true when you query a table
within such a function. Such a function should be defined as STABLE or
VOLATILE.
--
Kind regards,
Artur
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: ERROR: could not read block 0 in file when creating an index out of a function
@ 2025-03-12 12:31 Luca Ferrari <[email protected]>
parent: Artur Zakirov <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Luca Ferrari @ 2025-03-12 12:31 UTC (permalink / raw)
To: Artur Zakirov <[email protected]>; +Cc: pgsql-general <[email protected]>
On Wed, Mar 12, 2025 at 12:54 PM Artur Zakirov <[email protected]> wrote:
>
> I can reproduce this with the table `t` on PG 15.10.
I didn't mention I'm running 16.6, but I'm pretty sure it is
reproducible on other versions too.
>
> In your case `base/357283/365810` file is a new index file. For some
> reason Postgres tries to read the new index. I suppose this is because
> during reading the table `t` within the function `f_t` it tries to
> access the new index.
Yeah, even if it is not clear to me why it is trying to read the index
that is under creation (i.e., not usable yet).
>
> According to the documentation, IMMUTABLE functions should not only
> modify the database, but also return the same results given the same
> arguments forever, which might not be true when you query a table
> within such a function. Such a function should be defined as STABLE or
> VOLATILE.
As I stated, this example is controversial, and as the documentation
states, the IMMUTABLE set of functions should not perform database
lookups, as in my example.
However, the error message is quite obscure to me, and reminds me a
disk corruption rather a stability/function/lookup problem.
Luca
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-03-12 12:31 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-03-12 11:54 Re: ERROR: could not read block 0 in file when creating an index out of a function Artur Zakirov <[email protected]>
2025-03-12 12:31 ` Luca Ferrari <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox