| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | Amit Langote <amitlangote09(at)gmail(dot)com>, 303677365(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19872: JSON_TABLE: an UNUSED PASSING argument's COLLATE leaks into the output columns (wrong results, persi |
| Date: | 2026-12-02 15:43:34 |
| Message-ID: | CACJufxG0BUG0nt5fX868g1EreKok3GsOGZZ3=94UNEgDuUKexg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Tue, Dec 1, 2026 at 7:57 AM shihao zhong <zhong950419(at)gmail(dot)com> wrote:
>
+ case T_JsonExpr:
+ {
+ /*
+ * The PASSING arguments only supply values for
+ * JSON path variables. They are independent of
+ * each other and don't contribute to the node's
+ * collation.
+ */
+ JsonExpr *expr = (JsonExpr *) node;
+
+ assign_list_collations(context->pstate,
+ expr->passing_values);
+ (void) assign_collations_walker(expr->formatted_expr,
+ &loccontext);
+ (void) assign_collations_walker(expr->path_spec,
+ &loccontext);
+ (void) assign_collations_walker((Node *) expr->on_empty,
+ &loccontext);
+ (void) assign_collations_walker((Node *) expr->on_error,
+ &loccontext);
+ }
+ break;
The JsonExpr's collation is settled in transformJsonFuncExpr().
Each subexpression only needs to figure out its own collation as
mentioned before.
So processes every subexpression with assign_expr_collations() instead of
assign_collations_walker(). That is more robust, because
assign_collations_walker() merges each child's collation into loccontext, while
assign_expr_collations() leaves it untouched.
I hope the attached patch makes sense to you.
The regression tests are copied from your patch.
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-fix-JsonExpr-node-collation.patch | text/x-patch | 3.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-12-02 15:45:18 | Re: BUG #19969: Result inconsistency with scale() over an INTERSECT subquery |
| Previous Message | Fujii Masao | 2026-12-02 15:36:13 | Re: BUG #19895: dblink() never returns and spins at 100% CPU when the remote command is COPY ... TO STDOUT; |