Re: SQL/JSON: JSON_TABLE

From: Zhihong Yu <zyu(at)yugabyte(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, Oleg Bartunov <obartunov(at)postgrespro(dot)ru>, Matthias Kurz <m(dot)kurz(at)irregular(dot)at>, Himanshu Upadhyaya <upadhyaya(dot)himanshu(at)gmail(dot)com>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
Subject: Re: SQL/JSON: JSON_TABLE
Date: 2022-03-25 21:18:29
Message-ID: CALNJ-vRfVSMhUORVH0FWtrd-pi66M6gj7v62=rB7adJN9AD-sA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 25, 2022 at 1:30 PM Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:

>
> On 3/22/22 10:55, Daniel Gustafsson wrote:
> >> On 22 Mar 2022, at 16:31, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
> >> I'm planning on pushing the functions patch set this week and json-table
> >> next week.
> > My comments from 30827B3C-EDF6-4D41-BBF1-2981818744A8(at)yesql(dot)se are yet
> to be
> > addressed (or at all responded to) in this patchset. I'll paste the
> ones which
> > still apply to make it easier:
> >
>
>
> I think I have fixed all those. See attached. I haven't prepared a new
> patch set for SQL/JSON functions because there's just one typo to fix,
> but I won't forget it. Please let me know if there's anything else you see.
>
>
> At this stage I think I have finished with the actual code, and I'm
> concentrating on improving the docs a bit.
>
>
> cheers
>
>
> andrew
>
>
> --
> Andrew Dunstan
> EDB: https://www.enterprisedb.com

Hi,
w.r.t. 0001-SQL-JSON-functions-without-sql_json-GUC-v59.patch :

+ Datum *innermost_caseval =
state->innermost_caseval;
+ bool *innermost_isnull =
state->innermost_casenull;
+
+ state->innermost_caseval = resv;
+ state->innermost_casenull = resnull;
+
+ ExecInitExprRec(jve->formatted_expr, state, resv,
resnull);
+
+ state->innermost_caseval = innermost_caseval;
+ state->innermost_casenull = innermost_isnull;

Code similar to the above block appears at least twice. Maybe extract into
a helper func to reuse code.

+ * Evaluate a JSON path variable caching computed value.
+ */
+int
+EvalJsonPathVar(void *cxt, char *varName, int varNameLen,

Please add description for return value in the comment.

+ if (formatted && IsA(formatted, Const))
+ return formatted;

If formatted is NULL, it cannot be Const. So the if can be simplified:

+ if (IsA(formatted, Const))

For transformJsonConstructorOutput(), it seems the variable have_json is
not used - you can drop the variable.

+ * Coerce a expression in JSON DEFAULT behavior to the target output type.

a expression -> an expression

Cheers

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2022-03-25 21:25:37 Re: [PATCH] Enable SSL library detection via PQsslAttribute
Previous Message Daniel Gustafsson 2022-03-25 21:09:33 Re: pg_dump new feature: exporting functions only. Bad or good idea ?