Re: Composite IS NULL again, this time with plpgsql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Composite IS NULL again, this time with plpgsql
Date: 2017-03-18 22:57:38
Message-ID: 12557.1489877858@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
> This obviously happens because plpgsql is storing the variable as an
> expanded list of fields rather than as a single composite datum, and
> rebuilding the datum value when it needs to be passed to SQL for
> evaluation. Without an "isnull" flag for each composite subvalue, this
> can't regenerate the original datum closely enough to give the same
> value on an isnull test.

> What to do about this?

Sooner or later, I think we're going to have to bite the bullet and
switch over to using regular composite datums for plpgsql composite
variables --- that is, use the REC not ROW code paths for that case.

The ROW code paths should only get used for cases like "SELECT INTO a,b,c"
--- where there's no way to name the row-as-a-whole so no question
arises of whether it's null or not.

People have pushed back on that idea for various reasons, but we're
never going to have consistent behavior at this level of detail
until we do it.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2017-03-19 00:29:34 Re: Improve OR conditions on joined columns (common star schema problem)
Previous Message Andrew Gierth 2017-03-18 22:40:42 Composite IS NULL again, this time with plpgsql