title: How do I create a DOMAIN that accept NULL?
body: <p>I can't seem to figure out how to get a <a href="http://www.postgresql.org/docs/current/static/sql-createdomain.html" rel="nofollow">custom domain</a> to accept a NULL value. Notice, for shits and giggles I've tried it many different ways:</p>
  
  <pre><code>DROP SCHEMA census CASCADE;
  CREATE SCHEMA census;
  -- FIRST FOUR METHODS: NULL before CHECK, in CHECK, and NULL after CHECK
  CREATE DOMAIN census.sex AS text NULL CHECK ( VALUE IN ('M', 'F', 'NULL') OR VALUE IS NULL ) NULL;
  CREATE TABLE census.names (
    name       text
    , freq     int
    , cumfreq  float
    , rank     float
    , is_last  bool
    , sex      census.sex NULL -- fourth way
    , PRIMARY KEY ( is_last, sex, name )
  );
  </code></pre>
  
  <p>But, still no luck...</p>
  
  <pre><code># \d census.names;
            Table "census.names"
   Column  |       Type       | Modifiers 
  ---------+------------------+-----------
   name    | text             | not null
   freq    | integer          | 
   cumfreq | double precision | 
   rank    | double precision | 
   is_last | boolean          | not null
   sex     | census.sex       | not null
  Indexes:
      "names_pkey" PRIMARY KEY, btree (is_last, sex, name)
  </code></pre>
  
  <p>More amusingly, <a href="http://www.postgresql.org/docs/9.1/static/sql-createdomain.html" rel="nofollow">the docs</a> say</p>
  
  <blockquote>
    <p>NULL</p>
    
    <p>Values of this domain are allowed to be null. This is the default.</p>
    
    <p>This clause is only intended for compatibility with nonstandard SQL
    databases. Its use is discouraged in new applications.</p>
  </blockquote>
  
  <p>Without the clause it still says <code>NOT NULL</code>.</p>
  
  <pre><code>$ psql --version
  psql (PostgreSQL) 9.1.1
  contains support for command-line editing
  </code></pre>