The following bug has been logged online:
Bug reference: 2948
Logged by: Sergiy Vyshnevetskiy
Email address: serg@vostok.net
PostgreSQL version: 8.2.1
Operating system: FreeBSD-6 stable
Description: default null values for not-null domains
Details:
create domain "DInt4" as int not null;
CREATE DOMAIN
#psql = serg@[local]:5432 test
create or replace function test() returns "DInt4" immutable strict language
plpgsql as $F$declare t "DInt4"; begin return t; end$F$;
CREATE FUNCTION
#psql = serg@[local]:5432 test
select test() is null;
?column?
----------
t
(1 запиÑÑ)
#psql = serg@[local]:5432 test
Last select should have risen an exception:
ERROR: variable "t" declared NOT NULL cannot default to NULL