BUG #19652: to_number() silently truncates over-length integers

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: 303677365(at)qq(dot)com
Subject: BUG #19652: to_number() silently truncates over-length integers
Date: 2026-09-03 06:48:00
Message-ID: 19652-53cdb1205ea93a19@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19652
Logged by: chunling qin
Email address: 303677365(at)qq(dot)com
PostgreSQL version: 18.6
Operating system: x86_64
Description:

When the number of integer digits exceeds what the format template provides,
the excess digits are silently dropped. The very same input with a decimal
point added raises an overflow error — one "value exceeds the format"
scenario, two opposite behaviors:

SELECT to_number('1234567', '999');
-- 123 (digits beyond the 3-digit format silently discarded)

SELECT to_number('1234567.89', '999.99');
-- ERROR: numeric field overflow
-- DETAIL: A field with precision 3, scale 0 must round to an absolute
value
-- less than 10^3.

Both inputs should raise an error ("value too long" / overflow), since the
integral part exceeds the format in both cases; silently returning 123 for
'1234567' loses the high-order digits without any diagnostic.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kirill Reshke 2026-09-03 06:48:10 Re: BUG #19628: Uninterruptible vacuum during hash index processing
Previous Message PG Bug reporting form 2026-09-03 06:46:30 BUG #19651: to_date()/to_timestamp() silently accept out-of-range values for SSSSS, RM, IW and ID format fields