pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jonathan S. Katz <jkatz@postgresql.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: David Rowley <dgrowleyml@gmail.com>
Cc: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18240: Undefined behaviour in cash_mul_flt8() and friends
Date: Sun, 24 Dec 2023 12:16:31 -0500
Message-ID: <ecdf4a19-e97d-42c8-be45-fb5a46166160@postgresql.org> (raw)
In-Reply-To: <3453263.1702739958@sss.pgh.pa.us>
References: <18240-c5da758d7dc1ecf0@postgresql.org>
	<ZXbi3xo7QhQIe1YN@paquier.xyz>
	<2171714.1702307153@sss.pgh.pa.us>
	<ZXgh74Ykj3iWvXKr@paquier.xyz>
	<CAApHDvrBLa=gQ0tCg8727RaZXWDg1sDvFJ2+-DVy5SC=NSSKkg@mail.gmail.com>
	<2433182.1702391878@sss.pgh.pa.us>
	<ZX1rmhppwgaczYQ7@paquier.xyz>
	<3453263.1702739958@sss.pgh.pa.us>

On 12/16/23 10:19 AM, Tom Lane wrote:
> Michael Paquier <michael@paquier.xyz> writes:
>> On Tue, Dec 12, 2023 at 09:37:58AM -0500, Tom Lane wrote:
>>> ... Perhaps we could allow extension
>>> modules to use binary_upgrade_set_next_pg_type_oid, and then somehow
>>> reserve the money and _money OIDs forever?
> 
>> Now, I am not sure that we're making users a favor in keeping around a
>> data type that's kind of obsolete these days, particularly when all of
>> them basically require handling of fractional cents when doing serious
>> calculations.  That's a trap in disguise, even if tying data to a
>> locale for the unit sounds appealing for some applications.
> 
> Yeah, I wouldn't propose this if money were the only type we were
> thinking of getting rid of; likely not worth the trouble.  But I've
> got one eye on the geometric types as well --- I think it would be
> great all around if we could kick those out of the core distribution
> and let them be maintained independently.  But I fear we can't do that
> without some method whereby pg_upgrade is still possible across the
> change.

"money" poses a bit more risk than the geometric types (I do want to 
come back to geometric types later), and it'd be good if we could make 
some headway on removing it. Just this past week I came across a case 
where "money" was being discussed as being valid, and had to give the 
"it's kinda, sorta deprecated" talk.

I'm of the strong opinion that we should get rid of money. I personally 
haven't encountered it in the wild -- I'm sure it's there, but it seems 
limited -- and most apps that seriously deal with money will either user 
either "numeric" or an integer-based type.

I am sensitive to the upgrade piece, as we don't want someone relying on 
that behavior to be indefinitely stuck. But perhaps part of the 
deprecation plan is to just keep the casts around[1] for a few releases, 
without exposing the type, and prevent new creations of the type? We do 
state that "A money value can be cast to numeric without loss of 
precision"[1], but I do agree with the concerns on a pg_upgrade 
operation being stuck on a costly rewrite operation.

Would it make sense to block an upgrade via pg_upgrade if we detect a 
money type unless it's rewritten to a different type? Users should still 
be able to user other upgrades methods if need be, and handle the 
rewrite during that time.

Jonathan

[1] https://www.postgresql.org/docs/current/datatype-money.html


Attachments:

  OpenPGP_signature.asc (application/pgp-signature, 839B) download

view thread (24+ messages)  latest in thread

Message-ID: <ecdf4a19-e97d-42c8-be45-fb5a46166160@postgresql.org>
Permalink:  ../ecdf4a19-e97d-42c8-be45-fb5a46166160@postgresql.org/
Also on:    postgresql.org/message-id/ecdf4a19-e97d-42c8-be45-fb5a46166160@postgresql.org

 · 

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: jkatz@postgresql.org, tgl@sss.pgh.pa.us, michael@paquier.xyz, dgrowleyml@gmail.com, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18240: Undefined behaviour in cash_mul_flt8() and friends
  In-Reply-To: <ecdf4a19-e97d-42c8-be45-fb5a46166160@postgresql.org>

* 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