Re: PostgreSQL domains and NOT NULL constraint

Поиск
Список
Период
Сортировка
От Erki Eessaar
Тема Re: PostgreSQL domains and NOT NULL constraint
Дата
Msg-id AM9PR01MB8268087307B06FF1AEDC6A1BFED1A@AM9PR01MB8268.eurprd01.prod.exchangelabs.com
обсуждение исходный текст
Ответ на Re: PostgreSQL domains and NOT NULL constraint  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
>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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Erik Wienhold
Дата:
Сообщение: Re: [Doc] Glossary Term Definitions Edits
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: logical decoding and replication of sequences, take 2