Re: Fix missing FORMAT when deparsing JSON_ARRAY(query)

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix missing FORMAT when deparsing JSON_ARRAY(query)
Date: 2026-07-23 08:57:05
Message-ID: CAMbWs49BR-Pk56t6LC9vtFs4__AO3Lu=OzeUQO6p3e5W1z5J8Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 22, 2026 at 3:22 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
> Currently, JsonConstructorExpr does not store the JsonFormat information. To fix this problem, we need to add a JsonFormat field to JsonConstructorExpr. Please see the attached patch for details.

I considered recovering the format from func, as the arg that carries
the format lives there. However, reaching it requires walking a
complex CoalesceExpr tree to find the JsonValueExpr, which seems too
fragile.

So, recording the input FORMAT in JsonConstructorExpr for deparsing
seems like the most feasible approach.

Regarding the patch, I don't think we need to handle format in
expression_tree_mutator/walker. I also don't think we need to
copyObject the format. Other than that, the patch LGTM.

I plan to push the attached patch soon barring any objections.

- Richard

Attachment Content-Type Size
v2-0001-Fix-deparsing-of-JSON_ARRAY-subquery-with-a-FORMA.patch application/octet-stream 5.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Feike Steenbergen 2026-07-23 09:17:27 Re: BUG: ReadStream look-ahead exhausts local buffers when effective_io_concurrency>=64
Previous Message Peter Smith 2026-07-23 08:55:32 Re: DOCS QUESTION - space added within synopsis replaceable tag.