pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Abbate <jma@freedomcircle.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: DOMAIN/composite TYPE vs. base TYPE
Date: Mon, 28 Sep 2020 17:58:19 -0400
Message-ID: <57a90723-04cd-2036-7184-83e9409f8206@freedomcircle.com> (raw)
In-Reply-To: <409239.1601328317@sss.pgh.pa.us>
References: <6198aad8-df09-569e-686b-7e32979cd7e4@freedomcircle.com>
	<409239.1601328317@sss.pgh.pa.us>

Hello Tom,

On 28/9/20 17:25, Tom Lane wrote:
> Domain-over-composite might be a slightly simpler answer than your first
> one.  It's only available in relatively late-model PG, and I'm not sure
> about its performance relative to your other design, but it is an
> alternative to think about.

"Domain-over-composite" meaning create a TYPE first (DATE, CHAR(1)) and 
then a DOMAIN based on that type?  (1) How late model are we talking? 
The DOMAIN syntax doesn't seem changed from PG 11 to PG 13? (2) Can a 
CHECK constraint specify attributes of the composite?

> Note that attaching NOT NULL constraints at the domain level is almost
> never a good idea, because then you find yourself with a semantically
> impossible situation when, say, a column of that type is on the nullable
> side of an outer join.  We allow such constraints, but they will be
> nominally violated in cases like that.

NULLs: Tony Hoare's "billion dollars of pain and damage" transported to SQL.

Joe





view thread (10+ messages)  latest in thread

Message-ID: <57a90723-04cd-2036-7184-83e9409f8206@freedomcircle.com>
Permalink:  ../57a90723-04cd-2036-7184-83e9409f8206@freedomcircle.com/
Also on:    postgresql.org/message-id/57a90723-04cd-2036-7184-83e9409f8206@freedomcircle.com

 · 

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: jma@freedomcircle.com, tgl@sss.pgh.pa.us
  Subject: Re: DOMAIN/composite TYPE vs. base TYPE
  In-Reply-To: <57a90723-04cd-2036-7184-83e9409f8206@freedomcircle.com>
  References: <6198aad8-df09-569e-686b-7e32979cd7e4@freedomcircle.com> <409239.1601328317@sss.pgh.pa.us> <57a90723-04cd-2036-7184-83e9409f8206@freedomcircle.com>

* 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