Re: [PATCHES] Eliminate more detoast copies for packed varlenas
| От | Tom Lane |
|---|---|
| Тема | Re: [PATCHES] Eliminate more detoast copies for packed varlenas |
| Дата | |
| Msg-id | 5986.1192135845@sss.pgh.pa.us обсуждение |
| Ответ на | Re: [PATCHES] Eliminate more detoast copies for packed varlenas (Tom Lane <tgl@sss.pgh.pa.us>) |
| Список | pgsql-hackers |
I wrote:
> In fact, it seems there's a different risk here: if such a datum were
> toasted out-of-line, the reference in a cached plan might live longer
> than the underlying toast-table data. Maybe we need a forcible detoast
> in evaluate_function().
Sure enough, it seems we do. The attached script fails in every release
back to 7.3. It's a rather contrived case, because a function marked
immutable probably shouldn't be reading from a table at all, especially
not one you are likely to change or drop. That's probably why we've not
heard reports of this before. But it's definitely a bug.
regards, tom lane
create table big(f1 text);
insert into big values(repeat('xyzzy',100000));
create or replace function getbig() returns text as
'select f1 from big' language sql immutable;
create or replace function usebig(text) returns bool as '
begin return $1 ~ ''xyzzy''; end
' language plpgsql;
prepare foo as select usebig(getbig()) from int4_tbl;
execute foo;
drop table big;
execute foo;
В списке pgsql-hackers по дате отправления: