Thread: Parameter NOT NULL to CREATE DOMAIN not the same as CHECK (VALUE IS NOT NULL)

Parameter NOT NULL to CREATE DOMAIN not the same as CHECK (VALUE IS NOT NULL)

From
PG Doc comments form
Date:
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/17/sql-createdomain.html
Description:

The manual claims:

The syntax NOT NULL in this command is a PostgreSQL extension. (A
standard-conforming way to write the same would be CHECK (VALUE IS NOT
NULL). […])

But both variants differ when composite types are involved:

CREATE TYPE complex AS (real float8, imag float8);

CREATE DOMAIN d1 AS complex NOT NULL;
CREATE DOMAIN d2 AS complex CHECK (VALUE IS NOT NULL);

SELECT '(,)'::d1; -- allowed
SELECT '(,)'::d2; -- not allowed

Kind Regards,
Jan Behrens