From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: marcel@vybenetwork.com
Subject: BUG #18677: numeric values in arrays are stored incorrectly
Date: Tue, 29 Oct 2024 00:17:33 +0000
Message-ID: <18677-17e55341d56c7719@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 18677
Logged by: marcel r
Email address: marcel@vybenetwork.com
PostgreSQL version: 17.0
Operating system: Linux
Description:
Hi,
I'm working with 256 bit unsigned integers, currently stored as NUMERIC
type.
These values work as individual values, but odd behaviour occurs when the
values are put in an array.
Please see below for the reference.
This was tested on Postgres v17 and v14 with the same behaviour in both.
I noticed that I'm able to convert from text (such as JSONB) to NUMERIC /
uint_256 with no problem.
But the moment these values are inside an array there is some process
involved that sets the numeric value's last digits to 0.
SELECT
jsonb_path_query('605814335005781813025241542787157911726959411820757128006101511735853521072'::JSONB,
'$.number()') AS jsonb_path_value, -- Works.
ARRAY['605814335005781813025241542787157911726959411820757128006101511735853521072']::NUMERIC[]
as direct_numeric_array_outer, -- Inaccurate.
ARRAY['605814335005781813025241542787157911726959411820757128006101511735853521072'::NUMERIC]
as direct_numeric_array_inner, -- Inaccurate.
'605814335005781813025241542787157911726959411820757128006101511735853521072'::NUMERIC
as direct_numeric; -- Works.
{
"jsonb_path_value" :
"605814335005781813025241542787157911726959411820757128006101511735853521072",
"direct_numeric_array_outer" :
"{605,814,335,005,781,800,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000}",
"direct_numeric_array_inner" :
"{605,814,335,005,781,800,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000}",
"direct_numeric" :
605814335005781813025241542787157911726959411820757128006101511735853521072
}
Is it not possible to store these values in an array accurately?
Thank you.
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: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, marcel@vybenetwork.com
Subject: Re: BUG #18677: numeric values in arrays are stored incorrectly
In-Reply-To: <18677-17e55341d56c7719@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