NULL and plpgsql rows

From: "Jim C(dot) Nasby" <jim(at)nasby(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: NULL and plpgsql rows
Date: 2006-10-02 21:41:51
Message-ID: 20061002214150.GO81937@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm looking at how NULLs are handled in relation to plpgsql row types.
Looking at exec_assign_value, it appears that we're supposed to be able
to handle setting a row variable to NULL:

if (*isNull)
{
/* If source is null, just assign nulls to the row */
exec_move_row(estate, NULL, row, NULL, NULL);
}

However, the test right above that means that we'll fail if the user
tries something like "row_variable := NULL;":

if (!(valtype == RECORDOID ||
get_typtype(valtype) == 'c'))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("cannot assign non-composite value to a row variable")));

Presumably, I can just add code to that test to allow for *isNull.

Of course, setting a row variable to null is a lot more useful if we can
actually test for it after the fact, and I'm not really sure how to make
that happen.
--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2006-10-02 21:42:29 Re: initdb ignores invalid locale names
Previous Message Bruce Momjian 2006-10-02 21:39:36 Re: on-disk bitmap indexes