Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rA9jk-0054F9-BC for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Dec 2023 14:15:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rA9ji-00H5kF-Sv for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Dec 2023 14:15:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rA9ji-00H5k6-KK for pgsql-bugs@lists.postgresql.org; Mon, 04 Dec 2023 14:15:50 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rA9jg-00A3pE-AO for pgsql-bugs@lists.postgresql.org; Mon, 04 Dec 2023 14:15:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3B4EFk7p751503; Mon, 4 Dec 2023 09:15:47 -0500 From: Tom Lane To: bajinsheng@u.nus.edu cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18222: Unexpected Error--Cannot delete from scalar In-reply-to: <18222-de86a89e6ed68f3d@postgresql.org> References: <18222-de86a89e6ed68f3d@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 04 Dec 2023 05:56:09 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <751501.1701699346.1@sss.pgh.pa.us> Date: Mon, 04 Dec 2023 09:15:46 -0500 Message-ID: <751502.1701699346@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form 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