Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YsZWy-0007kk-GU for pgsql-committers@arkaria.postgresql.org; Wed, 13 May 2015 16:29:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YsZWx-0000aI-VN for pgsql-committers@arkaria.postgresql.org; Wed, 13 May 2015 16:29:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YsZWx-0000Zr-5f for pgsql-committers@postgresql.org; Wed, 13 May 2015 16:29:11 +0000 Received: from mail-wi0-f181.google.com ([209.85.212.181]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1YsZWt-0000lQ-IP for pgsql-committers@postgresql.org; Wed, 13 May 2015 16:29:10 +0000 Received: by wicmx19 with SMTP id mx19so14912935wic.0 for ; Wed, 13 May 2015 09:29:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=6u6RpEeBwVxYQ3zm4zM6u9WSalR24JKB8o71NIjsedk=; b=TYawHoNo+vBxQQVNHsSiVOoelmN7/vwcmLlSdnzLWqX5poiGMVlFauWk6oqgaF5GQ2 LiznAYjaToW9Z+r7cuSMnT8T5e3jyBwN4ZCk6HvtOfZEPx6Pe3aAE8TXi9+KHczPf8ql uqG2c6PuBjF5py2uo+i0dq8w5OnZ8d4+ozAURYyi6URFA4vNF8Nibrj088cVUfKavaFA YmoI+pYKjmhnt5jlaYpNVT3qYGu5whKxPyqpSBHd6KKC2XSVFhJIDUl94ZZdr3najUZB 3PHblK+E6ATLpn+zf9GRdIniV72L3EY7kYd+f3d2ri8uB8Kxd3hSFZD4gAEhdqTbTNDF eiWA== X-Gm-Message-State: ALoCoQnH5+OI6zu8Fyn+MOHhA1gQkIRVEJ2LnE31J5K7vmu5ZO2Sgoh2EBzXcT3Pi9i1wgJqOzZm X-Received: by 10.180.9.78 with SMTP id x14mr15973047wia.69.1431534545714; Wed, 13 May 2015 09:29:05 -0700 (PDT) Received: from [192.168.10.107] (host10-5-static.99-5-b.business.telecomitalia.it. [5.99.5.10]) by mx.google.com with ESMTPSA id mc20sm8849376wic.15.2015.05.13.09.29.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 May 2015 09:29:04 -0700 (PDT) Message-ID: <55537BC9.1080805@2ndquadrant.com> Date: Wed, 13 May 2015 18:28:57 +0200 From: Petr Jelinek User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Andrew Dunstan , Pavel Stehule CC: "pgsql-committers@postgresql.org" , Dmitry Dolgov <9erthalion6@gmail.com> Subject: Re: pgsql: Additional functions and operators for jsonb References: <555360E0.2040004@dunslane.net> In-Reply-To: <555360E0.2040004@dunslane.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org On 13/05/15 16:34, Andrew Dunstan wrote: > > On 05/12/2015 04:11 PM, Pavel Stehule wrote: >> Hi >> >> I did some tests, and I am not sure if this is not bug: >> >> postgres=# select '{"x":20}'::jsonb - 'x'::text; >> ERROR: unknown type of jsonb container --->>> it should be empty >> jsonb, not error >> Time: 0.971 ms >> postgres=# select '{"x":20, "y":30}'::jsonb - 'x'::text; >> ┌───────────┐ >> │ ?column? │ >> ╞═══════════╡ >> │ {"y": 30} │ >> └───────────┘ >> (1 row) >> >> >> > > > > Some of this logic needs tightening. The attached patch should do that. > Among other things, it errors out if we attempt to delete or replace on > a scalar, just returns the input argument if there are no changes > instead of cloning it, checks via an Assert that the constructed > JsonbValue is not null, and otherwise returns it unconditionally. The > result is actually simpler code, I think. Before I apply it I'd like to > have comments from Dmitry and Petr, just to make sure I haven't > inadvertently slipped my moorings. > I think it's ok like this, except that the "cannot get delete from scalar" error message should probably be "cannot delete from scalar" in both places. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers