Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group