Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZgjB-0002lF-2v for pgsql-bugs@arkaria.postgresql.org; Tue, 16 Aug 2016 15:56:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bZgjA-0005lZ-GI for pgsql-bugs@arkaria.postgresql.org; Tue, 16 Aug 2016 15:56:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bZgj9-0005lN-VA for pgsql-bugs@postgresql.org; Tue, 16 Aug 2016 15:56:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bZgj2-0000o2-8g for pgsql-bugs@postgresql.org; Tue, 16 Aug 2016 15:56:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u7GFuMwH013285; Tue, 16 Aug 2016 11:56:22 -0400 From: Tom Lane To: Mephysto cc: Michael Paquier , "David G. Johnston" , "pgsql-bugs@postgresql.org" Subject: Re: jsonb_array_elements issue In-reply-to: References: <1470404352397-5915026.post@n5.nabble.com> Comments: In-reply-to Mephysto message dated "Tue, 16 Aug 2016 10:51:08 +0200" Date: Tue, 16 Aug 2016 11:56:22 -0400 Message-ID: <13284.1471362982@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) 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 Mephysto writes: > In my previous email I forgot to say that I create a cast in my database as > I made with JSON. The cast is this: > CREATE CAST (text AS JSONB) WITHOUT FUNCTION AS IMPLICIT; Well, that's rather a critical bit of information :-( > If you create this cast and you launch my select without the explicit cast, > you should get the error. With this cast created I reported some other > issues, so at this point my question is: can I use this implicit cast or is > better to explicit it anytime is needed? This cast definition is completely broken; it's astonishing that you haven't had outright crashes, because text and jsonb do NOT have the same underlying representation, which is what would be required to make a cast WITHOUT FUNCTION work correctly. But this certainly explains 'unknown type of jsonb container' errors. You could fix that by providing a suitable casting function. I'm still dubious that making it an implicit cast is a good idea though. The trouble with implicit casts is that they tend to kick in when you were not expecting them to. Past experience has suggested a rule of thumb that implicit cross-type-category casts are best avoided, and I'd certainly call this a type category crossing. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs