Re: NULL and plpgsql rows

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: "Jim C(dot) Nasby" <jim(at)nasby(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: NULL and plpgsql rows
Date: 2007-02-17 01:35:56
Message-ID: 200702170135.l1H1Zu006201@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Added to TODO under PL/pgSQL:

o Allow row and record variables to be set to NULL constants,
and allow NULL tests on such variables

Because a row is not scalar, do not allow assignment
from NULL-valued scalars.

---------------------------------------------------------------------------

Jim C. Nasby wrote:
> On Tue, Feb 13, 2007 at 05:55:11PM -0500, Bruce Momjian wrote:
> >
> > Is there a TODO here?
> >
> > ---------------------------------------------------------------------------
> >
> > Jim Nasby wrote:
> > > On Oct 2, 2006, at 6:28 PM, Tom Lane wrote:
> > > > "Jim C. Nasby" <jim(at)nasby(dot)net> writes:
> > > >> However, the test right above that means that we'll fail if the user
> > > >> tries something like "row_variable := NULL;":
> > > >
> > > > The patch you seem to have in mind would allow
> > > > row_variable := int_variable;
> > > > to succeed if the int_variable chanced to contain NULL, which is
> > > > surely
> > > > not very desirable.
>
> Well, that's Tom's objection, though I'm not sure if by 'int_variable'
> he means 'internal' or 'integer'.
>
> Personally, I think it would be useful to just allow setting a row or
> record variable to NULL as I showed it above; ie: no variables involved.
> This is something you might want to do to invalidate a row/record
> variable after taking some action (perhaps deleting a row).
>
> You'd also think that you should be able to detect if a record variable
> is null, as you can with row.
>
> So, I suggest:
>
> * Allow row and record variables in plpgsql to be set to NULL
>
> It's not clear if it's a wise idea to allow this assignment from a
> variable. It may be better to only allow explicitly setting them,
> ie:
>
> row_variable := NULL;
>
> * Allow testing a record variable to see if it's NULL
>
> Currently works for row variables, but not record variables
> --
> Jim Nasby jim(at)nasby(dot)net
> EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ron Mayer 2007-02-17 01:37:26 Re: autovacuum next steps
Previous Message Bruce Momjian 2007-02-17 01:27:03 Re: integer datetimes