pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Gilleain Torrance <Gilleain.Torrance@alfasystems.com>
Cc: pgsql-bugs\@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: Incorrect rounding of double values at max precision
Date: Tue, 22 Oct 2019 04:53:59 +0100
Message-ID: <871rv5h3dc.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <26443.1571712071@sss.pgh.pa.us>
References: <DB3D1D143DDA534BBB39DE713E92343701CBA89718@GBEDBP01.chp.co.uk>
	<5045.1571686957@sss.pgh.pa.us>
	<875zkhhjs0.fsf@news-spur.riddles.org.uk>
	<26443.1571712071@sss.pgh.pa.us>

>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:

 >> Perhaps it would make more sense for the float8 to numeric cast to
 >> look at the requested typmod and use that for the conversion?

 Tom> As things stand right now, float8_numeric has no idea what the
 Tom> target typmod is; any typmod-driven rounding happens in a separate
 Tom> function call afterwards. I don't recall whether the parser's
 Tom> casting infrastructure could support merging those steps,

As far as I can tell it does; it looks at whether the cast function
takes a typmod parameter, and if it does, it passes the typmod,
otherwise it generates a separate typmod coercion and stacks that on top
of the cast proper.

So changing the function declaration to include a typmod parameter, and
using it, should just work... but I've not tested it yet.

 Tom> and I'm not sure it matters in most cases. Commonly, we don't have
 Tom> a target typmod. (Still, if we do, having two separate rounding
 Tom> steps isn't nice.)

So we'd still need to decide what to do in the no-typmod case.

-- 
Andrew (irc:RhodiumToad)





view thread (11+ messages)  latest in thread

Message-ID: <871rv5h3dc.fsf@news-spur.riddles.org.uk>
Permalink:  ../871rv5h3dc.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/871rv5h3dc.fsf@news-spur.riddles.org.uk

 · 

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: andrew@tao11.riddles.org.uk, tgl@sss.pgh.pa.us, Gilleain.Torrance@alfasystems.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: Incorrect rounding of double values at max precision
  In-Reply-To: <871rv5h3dc.fsf@news-spur.riddles.org.uk>

* 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