Re: BUG #18222: Unexpected Error--Cannot delete from scalar

From: Ba Jinsheng <bajinsheng(at)u(dot)nus(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #18222: Unexpected Error--Cannot delete from scalar
Date: 2023-12-04 14:21:16
Message-ID: SEZPR06MB6494E1FDA041FAB9B40510A28A86A@SEZPR06MB6494.apcprd06.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I thought it would probably give a warning that no available operator for text-text, not this error.
Anyway, thanks!
________________________________
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Sent: Monday, December 4, 2023 10:15:46 PM
To: Ba Jinsheng <bajinsheng(at)u(dot)nus(dot)edu>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #18222: Unexpected Error--Cannot delete from scalar

- External Email -

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> SELECT ('1'-to_hex(2))::BOOLEAN; -- ERROR: cannot delete from scalar

> This error looks strange to me as I do not understand what this error
> means.

Just out of curiosity, what did you expect that to do?

to_hex() produces type text, and there's no "text - text" operator.
What's evidently happening is that the parser finds "jsonb - text"
(i.e., jsonb_delete) as the only potentially applicable operator.
It successfully coerces '1' to a scalar jsonb value, but then
jsonb_delete() spits up because it's expecting an array.

I'm not sure that it was such a great idea to define '-' as having
this meaning for jsonb, but it's been there awhile now so probably
too late to change.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2023-12-04 14:53:22 Re: BUG #18225: chdb's s3 table function crashes postgresql with plpython3
Previous Message Tom Lane 2023-12-04 14:18:12 Re: BUG #18224: message bug in libpqwalreceiver.c.