| From: | Neil Chen <carpenter(dot)nail(dot)cz(at)gmail(dot)com> |
|---|---|
| To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
| Cc: | Andreas Karlsson <andreas(at)proxel(dot)se>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH] Handle SQL NULL results from casts in JSON generation |
| Date: | 2026-12-03 07:19:51 |
| Message-ID: | CAA3qoJmbDHYp6iGfUWySbe8PLJ5kcy73Zw=ptJYzxL7+5Lp4Xg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Andreas and David,
On Thu, Dec 3, 2026 at 1:59 PM David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
wrote:
> On Wednesday, December 2, 2026, Andreas Karlsson <andreas(at)proxel(dot)se>
> wrote:
>
>> what is your use case for a cast which returns NULL? If you want to
>> return a JSON null the proper way to do that is the below, but I do not see
>> any use case for returning an SQL NULL.
>
>
>>
I don’t have a production use case for this. The enum was just a small
reproducer. If I wanted the cast to produce JSON null, I’d return
'null'::json too.
What caught my attention was that when the cast returns SQL NULL,
json_build_array(x::json) gives [null], but json_build_array(x) errors
even though it uses the same cast. That’s the difference I was trying to
fix.
>
> b7eee09eab738e085d6b62d35788f542dd233877
>
> And
>
> 6aecabcd5ed54ac055b4df031336e997c84f7450
>
>
Thanks for the pointers, David. The foreign-key case looks particularly
close to this one.
--
Ze Chen (Neil)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Michael Paquier | 2026-12-03 07:08:47 | Re: Backend goes in infinite loop when a GUC_REPORT value can’t be converted to client_encoding |