From: Nathan Bossart <nathandbossart@gmail.com>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: Joseph Koshakow <koshy44@gmail.com>
Cc: jian he <jian.universality@gmail.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Matthew Kim <matthewkmkim@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Andres Freund <andres@anarazel.de>
Subject: Re: Remove dependence on integer wrapping
Date: Fri, 16 Aug 2024 15:11:52 -0500
Message-ID: <Zr-yiLatqDlen3oH@nathan> (raw)
In-Reply-To: <Zr-b1c6x-Yf31TCZ@nathan>
References: <ZrznaJTIOPgSjEJ7@nathan>
<CAAvxfHc2Smk92cJX4aUju1AdW_RpNN8csEj5rvf29b-YFHRmfQ@mail.gmail.com>
<Zrz0Zv4PVFxieEii@nathan>
<CACJufxH-uLR5SnnmVbGYj7Oy90zF_pYV3G_HxfbJ6Lu3XKGXxQ@mail.gmail.com>
<Zr5M3KxOZlEZRZIN@nathan>
<Zr50ZpSyrBx0EHfR@nathan>
<CAAvxfHfkHS1n0+wMbtKwj6_GE6+aSJ9JjnsCOOdZPhTKRs-Yhw@mail.gmail.com>
<Zr-DwBxep-IaayQF@nathan>
<bfff906f-300d-81ea-83b7-f2c93845e7f2@gmail.com>
<Zr-b1c6x-Yf31TCZ@nathan>
On Fri, Aug 16, 2024 at 01:35:01PM -0500, Nathan Bossart wrote:
> On Fri, Aug 16, 2024 at 09:00:00PM +0300, Alexander Lakhin wrote:
>> Sp it looks like jsonb_array_element_text() still needs the same
>> treatment as jsonb_array_element().
>
> D'oh. I added a test for that but didn't actually fix the code. I think
> we just need something like the following.
>
> diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
> index 1f8ea51e6a..69cdd84393 100644
> --- a/src/backend/utils/adt/jsonfuncs.c
> +++ b/src/backend/utils/adt/jsonfuncs.c
> @@ -990,7 +990,7 @@ jsonb_array_element_text(PG_FUNCTION_ARGS)
> {
> uint32 nelements = JB_ROOT_COUNT(jb);
>
> - if (-element > nelements)
> + if (pg_abs_s32(element) > nelements)
> PG_RETURN_NULL();
> else
> element += nelements;
I've committed this one.
--
nathan
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-hackers@postgresql.org
Cc: nathandbossart@gmail.com, exclusion@gmail.com, koshy44@gmail.com, jian.universality@gmail.com, hlinnaka@iki.fi, matthewkmkim@gmail.com, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org, andres@anarazel.de
Subject: Re: Remove dependence on integer wrapping
In-Reply-To: <Zr-yiLatqDlen3oH@nathan>
* 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