Re: [Bug Fix]ECPG: cancellation of significant digits on ECPG

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Higuchi, Daisuke" <higuchi(dot)daisuke(at)jp(dot)fujitsu(dot)com>
Cc: "'Dmitry Dolgov'" <9erthalion6(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [Bug Fix]ECPG: cancellation of significant digits on ECPG
Date: 2018-11-14 01:09:37
Message-ID: 30390.1542157777@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Higuchi, Daisuke" <higuchi(dot)daisuke(at)jp(dot)fujitsu(dot)com> writes:
> From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
>> So I think that we ought to unconditionally make the sqlda value's digit
>> buffer look just like the one we're copying, even when ndigits = 0,
>> which just requires removing the tests on ndigits.

> I agree with you. Seeing this thread[1], 'if (ndigits = 0)' was introduced only to avoid memcpy() crash. I do not know this solution was best or not, but no crash occurs in the current version. So, I also think 'if (ndigits = 0)' should be removed.

Hmmm ... looking at PGTYPESnumeric_from_asc, it seems like the current
behavior is different from what was described in that old thread; the only
case where a digit buffer wouldn't be created is a NaN. But maybe a crash
could occur for NaN. Perhaps we should use "if (num->sign !=
NUMERIC_NAN)" as a guard?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-11-14 01:33:57 pgsql: Add flag values in WAL description to all heap records
Previous Message Amit Langote 2018-11-14 01:09:09 Re: move PartitionBoundInfo creation code