Re: BUG #18222: Unexpected Error--Cannot delete from scalar - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18222: Unexpected Error--Cannot delete from scalar
Date
Msg-id 751502.1701699346@sss.pgh.pa.us
Whole thread Raw
In response to BUG #18222: Unexpected Error--Cannot delete from scalar  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #18222: Unexpected Error--Cannot delete from scalar
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.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



pgsql-bugs by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: BUG #18224: message bug in libpqwalreceiver.c.
Next
From: Tom Lane
Date:
Subject: Re: BUG #18224: message bug in libpqwalreceiver.c.