From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mephysto <mephystoonhell@gmail.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: jsonb_array_elements issue
Date: Tue, 16 Aug 2016 11:56:22 -0400
Message-ID: <13284.1471362982@sss.pgh.pa.us> (raw)
In-Reply-To: <CAG0sfBWHLZXzu9RMXTV0bZRFbw+EfsAY6Uv6BLkN9e_FgOpGAw@mail.gmail.com>
References: <1470404352397-5915026.post@n5.nabble.com>
<CAKFQuwZvbHFh6z8GamjHHXZsE6auRL4Nnee_8=jVSPQv9=5=aw@mail.gmail.com>
<CAB7nPqQ_S7s0BhWQkXg3Re2Qg9A1AH1+d+F5U1HTa8E29Qt0PQ@mail.gmail.com>
<CAG0sfBXgzw6bHwEBur=ivnO+nz+jE-7pZ6soHN31OOFm_CS_LQ@mail.gmail.com>
<CAB7nPqTd_tt_9r_EdhXZPdFmcn6H-J2=LAO+Zhqy0979M-jpNQ@mail.gmail.com>
<CAG0sfBWHLZXzu9RMXTV0bZRFbw+EfsAY6Uv6BLkN9e_FgOpGAw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Mephysto <mephystoonhell@gmail.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, mephystoonhell@gmail.com, michael.paquier@gmail.com, david.g.johnston@gmail.com
Subject: Re: jsonb_array_elements issue
In-Reply-To: <13284.1471362982@sss.pgh.pa.us>
References: <1470404352397-5915026.post@n5.nabble.com> <CAKFQuwZvbHFh6z8GamjHHXZsE6auRL4Nnee_8=jVSPQv9=5=aw@mail.gmail.com> <CAB7nPqQ_S7s0BhWQkXg3Re2Qg9A1AH1+d+F5U1HTa8E29Qt0PQ@mail.gmail.com> <CAG0sfBXgzw6bHwEBur=ivnO+nz+jE-7pZ6soHN31OOFm_CS_LQ@mail.gmail.com> <CAB7nPqTd_tt_9r_EdhXZPdFmcn6H-J2=LAO+Zhqy0979M-jpNQ@mail.gmail.com> <CAG0sfBWHLZXzu9RMXTV0bZRFbw+EfsAY6Uv6BLkN9e_FgOpGAw@mail.gmail.com> <13284.1471362982@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox