Thread: AW: to_char() dumps core

AW: to_char() dumps core

From
Zeugswetter Andreas SB
Date:
> (Also, if you do want to check for a NULL input in current sources,
> looking for a NULL pointer is the wrong way to code it anyway;
> PG_ARGISNULL(n) is the right way.)

For pass by reference datatypes setting the reference to a null pointer
for a NULL value imho would be a fine thing in addition to the indicator, 
no ?

Andreas


Re: AW: to_char() dumps core

From
Tom Lane
Date:
Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at> writes:
> For pass by reference datatypes setting the reference to a null pointer
> for a NULL value imho would be a fine thing in addition to the indicator, 
> no ?

At the moment it generally will be, but that's not certain to be true
forever.  I believe we've had discussions in the past about supporting
multiple kinds of NULL.  (I had the idea this was actually required by
SQL99, in fact, though I can't find anything about it at the moment.)

The obvious way to do that is to commandeer the otherwise unused
contents of a Datum when the associated null-flag is true.  At that
point checking the null-flag will be the only valid way to check for
NULL.

Assuming that the null-kind values are small integers, attempts to
dereference them will still SEGV on reasonable systems, so I don't
think any error checking is lost.  Just don't do "if (datum == NULL)".
        regards, tom lane