pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: contrib/intarray: always parse query_int integers as decimal.
Date: Tue, 20 Oct 2026 19:13:40 +0000
Message-ID: <E1xJFHI-0000000038V-0jI9@gemulon.postgresql.org> (raw)

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.grujic@enterprisedb.com>
Reviewed-by: Manu <manuelreyesbravo@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.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(-)



view thread (2+ messages)

Message-ID: <E1xJFHI-0000000038V-0jI9@gemulon.postgresql.org>
Permalink:  ../E1xJFHI-0000000038V-0jI9@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xJFHI-0000000038V-0jI9@gemulon.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: contrib/intarray: always parse query_int integers as decimal.
  In-Reply-To: <E1xJFHI-0000000038V-0jI9@gemulon.postgresql.org>
  References: <E1xJFHI-0000000038V-0jI9@gemulon.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