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 1tiSN2-00GDPk-Uf for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Feb 2025 06:06:44 +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 1tiSN0-002jAQ-GA for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Feb 2025 06:06:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tiSN0-002jAG-7m for pgsql-bugs@lists.postgresql.org; Thu, 13 Feb 2025 06:06:42 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tiSMz-000WjX-0X for pgsql-bugs@lists.postgresql.org; Thu, 13 Feb 2025 06:06:42 +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 51D66cnj3530349; Thu, 13 Feb 2025 01:06:38 -0500 From: Tom Lane To: "David G. Johnston" cc: "mark.drake@golden-hind.com" , "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #18809: Inconsistent JSON behavoir In-reply-to: References: <18809-601694c9be8a4026@postgresql.org> Comments: In-reply-to "David G. Johnston" message dated "Wed, 12 Feb 2025 22:24:22 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3530347.1739426798.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 13 Feb 2025 01:06:38 -0500 Message-ID: <3530348.1739426798@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Wednesday, February 12, 2025, PG Bug reporting form < > noreply@postgresql.org> wrote: >> broadway=3D# select jsonb('[2,3,1]') - to_jsonb(1); >> ERROR: operator does not exist: jsonb - jsonb >> LINE 1: select jsonb('[2,3,1]') - to_jsonb(1); > This would be a feature request, not a bug report. Indeed. We have these cases today: postgres=3D# \do - List of o= perators Schema | Name | Left arg type | Right arg type = | Result type | Description = ------------+------+-----------------------------+------------------------= -----+-----------------------------+------------------------------------- ... pg_catalog | - | jsonb | integer = | jsonb | delete array element pg_catalog | - | jsonb | text = | jsonb | delete object field pg_catalog | - | jsonb | text[] = | jsonb | delete object fields ... These are already less than consistent, for example this is allowed: postgres=3D# select jsonb('[2,3,1]') - 'foo'::text; ?column? = ----------- [2, 3, 1] (1 row) but this not so much: postgres=3D# select jsonb('{"a": 1, "b": 2}') - 1; ERROR: cannot delete from object using integer index To invent jsonb - jsonb, you'd need to define its behavior for every possible JSON structure on each side. I foresee plenty of bikeshedding. regards, tom lane