Re: Detection of nested function calls

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Hugo Mercier <hugo(dot)mercier(at)oslandia(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Detection of nested function calls
Date: 2013-10-28 20:14:47
Message-ID: 10342.1382991287@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2013-10-28 14:26:20 -0400, Tom Lane wrote:
>> No; see my upthread comments. I think what we want to do is to have
>> PG_DETOAST_DATUM automatically flatten non-flat datums, and to require
>> functions that can cope with non-flat inputs to use a new argument
>> fetching macro, exactly along the lines of what we did with non-aligned
>> toasted values awhile ago (see PG_GETARG_TEXT_PP and suchlike).

> My problem isn't datatype specific functions doing superflous
> detoasting. If it were just them, I'd be perfectly happy going your way.
> My concern is type-independent code detoasting everything without giving
> the type specific code any say over it. Like, printtup.c, spi.c,
> rowtype.c...

In all those cases, if we're detoasting at all then there is probably good
reason to flatten as well. Or if not, we'll teach the code the
difference. Just as with function arguments, it can never be *wrong* to
flatten, it might only be inefficient --- so we'll improve the
inefficiencies. One at a time.

>> If we do what you're suggesting here, any attempt to de-flatten a datatype
>> will be a flag day on which *every* *single* *function* that deals with
>> that datatype has to change simultaneously.

> I don't think this is a change on the same scale as V1 call conventions
> or short varlenas which are type independent because a type explicitly
> has to sign up for it.

I think it's going to be more widely adopted than you think, unless we
make it so impractical to adopt that only one or two types ever do it.

> E.g. the numeric storage is private to numeric.c, so it'd be perfectly
> fine to change the numeric representation in a flag day manner as long
> as we still can read the old representation.

So in other words, you believe there is no extension anywhere that deals
with numeric values? Sorry, I don't believe that. And even if I believed
it for numeric, the assumption certainly falls to the ground once you
extend it to every datatype that might have use for this facility.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-10-28 20:22:36 Re: better atomics
Previous Message Peter Geoghegan 2013-10-28 20:11:19 Re: OSX doesn't accept identical source/target for strcpy() anymore