Re: to_char() dumps core - Mailing list pgsql-hackers

From Tom Lane
Subject Re: to_char() dumps core
Date
Msg-id 2023.972176649@sss.pgh.pa.us
Whole thread Raw
In response to to_char() dumps core  (Tatsuo Ishii <t-ishii@sra.co.jp>)
List pgsql-hackers
Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> In 7.0.2 
>    select to_char(sum(n),'999') from t1;

> causes backend dump a core if n is a float/numeric ...data type AND if
> sum(n) returns NULL. This seems due to a bad null pointer handling for
> aruguments of pass-by-reference data types.  I think just a simple
> null pointer checking at very top of each function (for example
> float4_to_char()) would solve the problem.  Comments?

Just a note to remind everyone, since I haven't yet updated the
documentation for the new-fmgr changes: under the 7.1 fmgr it is *no
longer necessary* to check for NULL pointer in function execution
routines, assuming that your function is marked "strict" in pg_proc
(as nearly all built-in functions are).  The fmgr will not call such
a function in the first place, if any of its inputs are NULLs.

So, while adding the NULL-pointer checks is an OK patch for 7.0.*,
don't stick such checks into current sources.

(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.)
        regards, tom lane


pgsql-hackers by date:

Previous
From: Philip Warner
Date:
Subject: Re: Last builtin OID?
Next
From: Tom Lane
Date:
Subject: Re: Unable to access CVS server