The following bug has been logged online: Bug reference: 3314 Logged by: Dmitry Maksyoma Email address: [EMAIL PROTECTED] PostgreSQL version: 8.2.4-1 Debian Operating system: Debian unstable, 2.6.18-4-686 Description: DOMAIN NOT NULL constraint enforced in plPgSQL DECLARE clause. Details:
Had to modify postgresql.conf to listen on localhost. su postgres createdb test createlang plPgSQL test psql test CREATE SCHEMA test; CREATE DOMAIN test.text_not_null AS TEXT NOT NULL; CREATE TABLE test.test_domain ( name test.text_not_null); CREATE TABLE test.test_text ( t TEXT NOT NULL); CREATE OR REPLACE FUNCTION test.get_domain() RETURNS TEXT STABLE LANGUAGE plPgSQL AS ' DECLARE row test.test_domain%ROWTYPE; BEGIN RETURN ''HELLO''; END;'; CREATE OR REPLACE FUNCTION test.get_text() RETURNS TEXT STABLE LANGUAGE plPgSQL AS ' DECLARE row test.test_text%ROWTYPE; BEGIN RETURN ''HELLO''; END;'; \set VERBOSITY verbose SELECT test.get_text(); SELECT test.get_domain(); # Test output. test=# \set VERBOSITY verbose test=# SELECT test.get_text(); get_text ---------- HELLO (1 row) test=# SELECT test.get_domain(); ERROR: 23502: domain test.text_not_null does not allow null values CONTEXT: PL/pgSQL function "get_domain" line 3 at block variables initialization LOCATION: domain_check_input, domains.c:128 First, it used to work without error in Postgres 7.4. Second, it is, from my point of view, inconsistent to have the same constraint to be enforced in case of DOMAIN type and not enforced in case of columnt constraint. ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster