Re: Question about duplicate JSONTYPE_JSON check - Mailing list pgsql-hackers

From Maciek Sakrejda
Subject Re: Question about duplicate JSONTYPE_JSON check
Date
Msg-id CADXhmgTaL-6sF1dezMhOVHse1yDHTEdi3L4chEJRwLU4dV5MYg@mail.gmail.com
Whole thread Raw
In response to Question about duplicate JSONTYPE_JSON check  (Maciek Sakrejda <maciek@pganalyze.com>)
List pgsql-hackers
I'm adding the author/committer and reviewer of 3c152a2, since I think
this may be a bug (my apologies if I'm misunderstanding this). See my
previous e-mail quoted below:

On Mon, Mar 10, 2025 at 5:11 PM Maciek Sakrejda <maciek@pganalyze.com> wrote:
>
> While exploring the jsonb code, I noticed that in
> datum_to_jsonb_internal, the tcategory checks compares against
> JSONTYPE_JSON twice. There's no reason for that, right?
>
> ...
>
> Ok, so, to try to answer my own question, I went looking at the
> history, and this comes from "Unify JSON categorize type API and
> export for external use" [0]. Specifically, the change was
>
> -            (tcategory == JSONBTYPE_ARRAY ||
> -             tcategory == JSONBTYPE_COMPOSITE ||
> -             tcategory == JSONBTYPE_JSON ||
> -             tcategory == JSONBTYPE_JSONB ||
> -             tcategory == JSONBTYPE_JSONCAST))
> +            (tcategory == JSONTYPE_ARRAY ||
> +             tcategory == JSONTYPE_COMPOSITE ||
> +             tcategory == JSONTYPE_JSON ||
> +             tcategory == JSONTYPE_JSONB ||
> +             tcategory == JSONTYPE_JSON))
>
> So "JSONBTYPE_JSONCAST" turned into "JSONTYPE_JSON". Should that have
> been "JSONTYPE_CAST" (that seems to be the corresponding value in the
> new enum) instead?
>
> Thanks,
> Maciek
>
> [0]: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=3c152a27b06313fe27bd47079658f928e291986b



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: BitmapHeapScan streaming read user and prelim refactoring
Next
From: Michael Paquier
Date:
Subject: Re: Back-patch of: avoid multiple hard links to same WAL file after a crash