pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: bajinsheng@u.nus.edu
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18222: Unexpected Error--Cannot delete from scalar
Date: Mon, 04 Dec 2023 09:15:46 -0500
Message-ID: <751502.1701699346@sss.pgh.pa.us> (raw)
In-Reply-To: <18222-de86a89e6ed68f3d@postgresql.org>
References: <18222-de86a89e6ed68f3d@postgresql.org>

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





view thread (4+ messages)  latest in thread

Message-ID: <751502.1701699346@sss.pgh.pa.us>
Permalink:  ../751502.1701699346@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/751502.1701699346@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, bajinsheng@u.nus.edu, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18222: Unexpected Error--Cannot delete from scalar
  In-Reply-To: <751502.1701699346@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox