>I doubt we'd consider doing anything about that. >The whole business of domains with NOT NULL constraints >is arguably a defect of the SQL standard, because >there are multiple ways to produce a value that >is NULL and yet must be considered to be of the domain type.
In my opinion it is inconsistent and illogical if a type sometimes contains a value and sometimes not. CREATE DOMAIN d_int INTEGER NOT NULL; All the following statements fail (and correctly so in my opinion). SELECT (NULL)::d_int; /*ERROR: domain d_int does not allow null values*/ SELECT Cast(NULL AS d_int); /*ERROR: domain d_int does not allow null values*/ WITH val (v) AS (VALUES (1), (NULL)) SELECT Cast(v AS d_int) AS v FROM Val; /*ERROR: domain d_int does not allow null values*/ In my opinion the confusion and related problems arise from the widespread practice of sometimes treating a domain as a type (which it is not) and sometimes treating NULL as a value (which it is not). Best regards Erki Eessaar