pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18240: Undefined behaviour in cash_mul_flt8() and friends
Date: Mon, 11 Dec 2023 10:05:53 -0500
Message-ID: <2171714.1702307153@sss.pgh.pa.us> (raw)
In-Reply-To: <ZXbi3xo7QhQIe1YN@paquier.xyz>
References: <18240-c5da758d7dc1ecf0@postgresql.org>
	<ZXbi3xo7QhQIe1YN@paquier.xyz>

Michael Paquier <michael@paquier.xyz> writes:
> On Mon, Dec 11, 2023 at 06:00:02AM +0000, PG Bug reporting form wrote:
>> The following multiplication:
>> SELECT 1_000_000_000::money * 1_000_000_000::float8;
>> gives the incorrect result:
>> -$92,233,720,368,547,758.08

> Yep, good catch.  Reproduced here.

Yeah, approximately none of cash.c pays any attention to the risks
of overflow/underflow.  Improving that situation would be a good
finger exercise for some aspiring hacker, perhaps.  Although I bet
somebody will ask again why it is that we continue to support the
money type.

			regards, tom lane





view thread (24+ messages)  latest in thread

Message-ID: <2171714.1702307153@sss.pgh.pa.us>
Permalink:  ../2171714.1702307153@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2171714.1702307153@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, michael@paquier.xyz, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18240: Undefined behaviour in cash_mul_flt8() and friends
  In-Reply-To: <2171714.1702307153@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox