pgsql: contrib/intarray: always parse query_int integers as decimal.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: contrib/intarray: always parse query_int integers as decimal.
Date: 2026-10-20 19:13:40
Message-ID: E1xJFHI-0000000038V-0jI9@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

contrib/intarray: always parse query_int integers as decimal.

Previously we called strtol() with base 0, so that a leading zero
digit caused the number to be read as octal. This is not documented
because it was not the original intent: before commit 7ccb6dc2d, this
code used atoi() which would have read the number as decimal always.
Use base 10 instead to restore the original behavior.

Also reject a bare minus sign consistently. Per POSIX, strtol()
"may" set errno for that case but doesn't have to, and if it doesn't
then we'd not have noticed the bad syntax but read the value as 0.

Although this change restores old behavior, 7ccb6dc2d was a long
time ago, so it's at least possible that someone out there is
expecting the octal behavior. So it doesn't seem like a great
idea to put this into stable branches. But I (tgl) judge it
not too late for v19.

Author: Marko Grujic <marko(dot)grujic(at)enterprisedb(dot)com>
Reviewed-by: Manu <manuelreyesbravo(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CAOvwyF3=brZoxwcwHRQqvLjuqSqxiTN7RXpKMNHXJ1WAS5GQ2Q@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ccfe1db5a8a7c95f33c877a228af676b2e68e31d

Modified Files
--------------
contrib/intarray/_int_bool.c | 5 +++--
contrib/intarray/expected/_int.out | 10 ++++++++++
contrib/intarray/sql/_int.sql | 2 ++
3 files changed, 15 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-10-20 21:32:46 pgsql: Fix OLD/NEW aliases that EXPLAIN prints in RETURNING SubPlans.
Previous Message Tom Lane 2026-10-20 18:29:22 pgsql: In deparsing, parenthesize IS DOCUMENT where it is an operand.