Re: BUG #19491: Segmentation fault triggered by IS NULL

From: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
To: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
Cc: 798604270(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Subject: Re: BUG #19491: Segmentation fault triggered by IS NULL
Date: 2026-06-05 16:11:34
Message-ID: CAJTYsWX3wF0Mm0TX4iMdRvtUHmVeLnARzQXzQAKVxmH+m3zE9g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On Mon, 25 May 2026 at 22:06, Srinath Reddy Sadipiralla <
srinath2133(at)gmail(dot)com> wrote:

> Hi,
>
> I have reviewed the patch , i think the error message might be
> something like
>
> diff --git a/src/backend/parser/parse_expr.c
> b/src/backend/parser/parse_expr.c
> index 89d0f348303..59e34f082e4 100644
> --- a/src/backend/parser/parse_expr.c
> +++ b/src/backend/parser/parse_expr.c
> @@ -4203,6 +4203,13 @@ transformJsonParseArg(ParseState *pstate, Node
> *jsexpr, JsonFormat *format,
>
> TEXTOID, -1,
>
> COERCION_IMPLICIT,
>
> COERCE_IMPLICIT_CAST, -1);
> + if(expr == NULL)
> + ereport(ERROR,
> + (errcode(ERRCODE_CANNOT_COERCE),
> + errmsg("cannot cast type %s to %s",
> + format_type_be(*exprtype),
> + format_type_be(TEXTOID)),
> + parser_errposition(pstate,
> exprLocation(raw_expr))));
> *exprtype = TEXTOID;
> }
>

Thanks, that reads better. v2 attached, raising ERRCODE_CANNOT_COERCE
right where the coercion fails:

ERROR: cannot cast type sqljson_mystr to text

which also covers the JSON() WITH UNIQUE KEYS path.

Regards,
Ayush

Attachment Content-Type Size
v2-0001-Avoid-NULL-IS-JSON-expressions-after-failed-text-.patch application/octet-stream 5.7 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Matheus Alcantara 2026-06-05 18:09:26 Re: BUG #19480: PL/Python SRF crashes (SIGSEGV) when function is replaced mid-iteration: use-after-free in PLy_funct
Previous Message Fujii Masao 2026-06-05 15:38:15 Re: BUG #19508: pg_buffercache_pages() crashes the backend with an incompatible caller-supplied record definition