pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bryn Llewellyn <bryn@yugabyte.com>
Cc: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Subject: Re: Outer joins and NULLs (old subject "ERROR: failed to find conversion function from key_vals_nn to record[]")
Date: Sun, 19 Jun 2022 19:28:35 -0400
Message-ID: <2287377.1655681315@sss.pgh.pa.us> (raw)
In-Reply-To: <E0FD12C0-FA6B-4D12-936C-B37A3052837D@yugabyte.com>
References: <E0FD12C0-FA6B-4D12-936C-B37A3052837D@yugabyte.com>

Bryn Llewellyn <bryn@yugabyte.com> writes:
> Self-evidently, a view does *not* inherit constraints from the columns of its base table(s).

Check.

> A view on a single table doesn't necessarily inherit the data types of its base table's columns. Rather, the view compilation's analysis is *sometimes* clever enough to notice when a projected column might have a NULL even when the base column doesn't allow NULLs. In this case, if the base column's data type is (in my example) the domain "text_nn", then the corresponding column in the view is given the data type plain "text". My test that uses a single table shows this.

This is nonsense.  The parser does not account for domain constraints in
that way.  It would be incorrect to do so, because then the view's data
types could need to change as a consequence of adding/dropping domain
constraints.  I think that your result is actually just an illustration
of the rules in
    https://www.postgresql.org/docs/current/typeconv-union-case.html
about how the output type of a CASE expression is determined ---
specifically, that domains are smashed to base types as soon as
the CASE arms are discovered to not be all of the same type.

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <2287377.1655681315@sss.pgh.pa.us>
Permalink:  ../2287377.1655681315@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2287377.1655681315@sss.pgh.pa.us

 · 

reply

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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, bryn@yugabyte.com, hjp-pgsql@hjp.at, david.g.johnston@gmail.com
  Subject: Re: Outer joins and NULLs (old subject "ERROR: failed to find conversion function from key_vals_nn to record[]")
  In-Reply-To: <2287377.1655681315@sss.pgh.pa.us>
  References: <E0FD12C0-FA6B-4D12-936C-B37A3052837D@yugabyte.com> <2287377.1655681315@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