agora inbox for pgsql-bugs@postgresql.org  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: 303677365@qq.com
Subject: BUG #19652: to_number() silently truncates over-length integers
Date: Thu, 03 Sep 2026 06:48:00 +0000
Message-ID: <19652-53cdb1205ea93a19@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      19652
Logged by:          chunling qin
Email address:      303677365@qq.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.








view thread (2+ messages)  latest in thread

Message-ID: <19652-53cdb1205ea93a19@postgresql.org>
Permalink:  ../19652-53cdb1205ea93a19@postgresql.org/
Also on:    postgresql.org/message-id/19652-53cdb1205ea93a19@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: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, 303677365@qq.com
  Subject: Re: BUG #19652: to_number() silently truncates over-length integers
  In-Reply-To: <19652-53cdb1205ea93a19@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox