Re: [PATCHES] Eliminate more detoast copies for packed varlenas

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: "PostgreSQL-development Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] Eliminate more detoast copies for packed varlenas
Date: 2007-10-11 20:50:45
Message-ID: 5986.1192135845@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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;

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Hammond 2007-10-11 20:58:53 Re: Release notes introductory text
Previous Message Neil Conway 2007-10-11 20:50:05 Re: Release notes introductory text

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2007-10-12 06:22:57 Re: [HACKERS] quote_literal with NULL
Previous Message Marko Kreen 2007-10-11 20:48:19 Re: txid cleanup