Re: [GENERAL] Bug and/or feature? Complex data types in tables...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Michael Glaesemann <grzm(at)myrealbox(dot)com>, pgsql-hackers(at)postgreSQL(dot)org, Chris Travers <chris(at)travelamericas(dot)com>
Subject: Re: [GENERAL] Bug and/or feature? Complex data types in tables...
Date: 2004-01-16 15:02:32
Message-ID: 29619.1074265352@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Joe Conway <mail(at)joeconway(dot)com> writes:
> Tom Lane wrote:
>> ... That means that the contained fields had better not be
>> out-of-line TOAST value references, because there's no way to keep track
>> of them and keep from deleting the referenced value too soon.

> Why wouldn't we handle this just like we do when we build an array from
> elemental datums (i.e. allocate sufficient space and copy the individual
> datums into the structure)?

Well, the problem is that there are tuples and there are tuples. We do
*not* want to force expansion of TOAST references every time we build an
intermediate tuple to return up one level in a plan. That would cost
gobs of memory, and it's possible the expanded value will never actually
be used at all (eg, the row might fail a join qual further up the plan).
Ideally the forced expansion should only occur if a composite-type tuple
is actually about to be stored on disk. Maybe this says that the
toaster routines are the right place to take care of it after all, but
I'm not quite sure where it should go.

BTW, you could argue that TOAST references in a constructed array ought
not be expanded until/unless the array gets written to disk, too. But
the expense of scanning a large array on the off chance there's some
TOAST references in there might dissuade us from doing that. (Hmm ...
maybe use a flag bit in the array flag word?)

>> The other point was that what's actually returned at the moment from a
>> function-returning-tuple is a Datum that contains a pointer to a
>> TupleTableSlot, not a pointer to a datum of this kind.

> If you had something akin to arrayin/arrayout, would this still need to
> be changed?

I don't see the connection. This is an internal representation either
way, and there's no point at which one would want to invoke an I/O
routine.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2004-01-16 15:49:59 Re: Returning large select results from stored procedures
Previous Message Jeff Eckermann 2004-01-16 14:57:15 Re: check date validity

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-01-16 15:12:46 Missed bet in toaster routines
Previous Message Jan Wieck 2004-01-16 14:43:46 Re: Missed bet in toaster routines