| From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
|---|---|
| To: | Ewan Young <kdbase(dot)hack(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, David Rowley <dgrowleyml(at)gmail(dot)com>, Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Subject: | Re: right() returns the whole string for the most negative n |
| Date: | 2026-08-25 07:29:05 |
| Message-ID: | CB77897E-6553-4B69-9FC2-BEE7F16E45D7@yesql.se |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On 25 Aug 2026, at 08:57, Ewan Young <kdbase(dot)hack(at)gmail(dot)com> wrote:
> Negating PG_INT32_MIN overflows; under -fwrapv it comes back as
> PG_INT32_MIN, still negative, and pg_mbcharcliplen() returns 0 for any
> negative limit, so off is 0 and the whole string is returned.
Thanks for the report and patch, the fix seems correct to me.
> This dates to 49b27ab5514, which added left()/right() in 2010, and the
> line has not been touched since; I could not find a previous report.
Understandably so, it's not an issue likely to cause issues in production.
> It's the same shape as b4dfae2ffac (money, INT64_MIN / -1) from a few weeks
> ago.
Agreed, so backpatching all the way for this one as well makes sense. I'll
have another look and will leave it open to input from others before applying.
--
Daniel Gustafsson
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Smith | 2026-08-25 07:35:07 | Re: Support EXCEPT for TABLES IN SCHEMA publications |
| Previous Message | Ashutosh Sharma | 2026-08-25 07:28:38 | Re: Switching XLog source from archive to streaming when primary available |