pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: contrib/intarray: always parse query_int integers as decimal.
2+ messages / 1 participants
[nested] [flat]

* pgsql: contrib/intarray: always parse query_int integers as decimal.
@ 2026-10-20 19:13  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2026-10-20 19:13 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3745790f53bc5dd87b2df3d5a0c9c62d7ff0360d

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: contrib/intarray: always parse query_int integers as decimal.
@ 2026-10-20 19:13  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2026-10-20 19:13 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-10-20 19:13 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20 19:13 pgsql: contrib/intarray: always parse query_int integers as decimal. Tom Lane <tgl@sss.pgh.pa.us>
2026-10-20 19:13 pgsql: contrib/intarray: always parse query_int integers as decimal. Tom Lane <tgl@sss.pgh.pa.us>

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