Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Demitri Muna <postgresql@xxxxxxxxxxx> 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 of a 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






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux