Re: to_char() dumps core

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: to_char() dumps core
Date: 2000-10-22 01:04:09
Message-ID: 2023.972176649@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-10-22 01:08:15 Re: Unable to access CVS server
Previous Message Tom Lane 2000-10-22 00:13:24 Re: Navigating time-warps in the CVS tree (was re the rule system)

Browse pgsql-patches by date

  From Date Subject
Next Message Denis Perchine 2000-10-22 06:30:56 Re: Re: [PATCHES] Patch to support transactions with BLOBs for current CVS
Previous Message Bruce Momjian 2000-10-22 00:10:03 Re: Re: [PATCHES] Patch to support transactions with BLOBs for current CVS