Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XKC1A-0007JN-Lo for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Aug 2014 19:58:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XKC1A-0005lO-1I for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Aug 2014 19:58:00 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XKC17-0005lD-Uu for pgsql-bugs@postgresql.org; Wed, 20 Aug 2014 19:57:58 +0000 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XKC0z-0006Fo-1p for pgsql-bugs@postgresql.org; Wed, 20 Aug 2014 19:57:55 +0000 Received: from mfilter31-d.gandi.net (mfilter31-d.gandi.net [217.70.178.162]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id B5A55A8075; Wed, 20 Aug 2014 21:57:43 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter31-d.gandi.net Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by mfilter31-d.gandi.net (mfilter31-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 44K8xZBLeLJw; Wed, 20 Aug 2014 21:57:12 +0200 (CEST) X-Originating-IP: 98.27.58.255 Received: from [192.168.10.146] (cpe-098-027-058-255.nc.res.rr.com [98.27.58.255]) (Authenticated sender: adsend@dunslane.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 3519AA80B9; Wed, 20 Aug 2014 21:57:10 +0200 (CEST) Message-ID: <53F4FD94.4070201@dunslane.net> Date: Wed, 20 Aug 2014 15:57:08 -0400 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Tom Lane CC: Peter Geoghegan , justin.vanwinkle@gmail.com, pgsql-bugs Subject: Re: BUG #11207: empty path will segfault jsonb #> References: <20140818195634.2543.56277@wrigleys.postgresql.org> <22294.1408487132@sss.pgh.pa.us> <26461.1408497576@sss.pgh.pa.us> <27009.1408558097@sss.pgh.pa.us> <28104.1408561567@sss.pgh.pa.us> In-Reply-To: <28104.1408561567@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 08/20/2014 03:06 PM, Tom Lane wrote: > Peter Geoghegan writes: >> On Wed, Aug 20, 2014 at 11:08 AM, Tom Lane wrote: >>> Is there a reason for these to behave inconsistently, and if not, which >>> behavior should we standardize on? Considering that you get NULL not an >>> error for extracting a nonexistent element from an object, I think there >>> is some case to be made for saying that returning NULL is the more >>> convenient behavior. Of course one can also argue for wanting this >>> operator to throw errors if the JSON structure doesn't match the >>> operation, but it seems like we've chosen to prefer being lax. >> I discussed this very issue with Andrew during development (I think >> that this happened to occur in private). My view was that since users >> will frequently use -> within expression indexes, it's best to have it >> return NULL for non-objects, rather than make them worry about the >> case where it'll be rejected, which is rather contrary to the spirit >> of jsonb (at least as a default behavior). > Hadn't thought of that angle, but it's a really good point. I'd certainly > rather be able to put an index on (jsoncol -> 'foo') without worrying > about what will happen if the column includes things that aren't objects. > >> Andrew argued it was >> preferable to stick to the historic behavior of json operators. IMV, >> we should have both operators return NULL. They should be consistent, >> which implies changing the behavior of the existing json variants too, >> but I don't think that's a big problem. > None of these operators existed before 9.3, so I don't put a lot of stock > in the idea that their corner-case behaviors should be considered > sacrosanct already. But that will become the case pretty soon; if we > don't get it right in 9.4 it will arguably be too late. > > I'm not terribly dogmatic about it. If the consensus is to change it then let's do it. cheers andrew -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs