CREATE DOMAIN text_not_null AS text NOT NULL;
CREATE TYPE c AS( t text_not_null, i int );
CREATE TABLE test_table( id serial, c c );
CREATE OR REPLACE FUNCTION test_func(i test_table) RETURNS oid LANGUAGE plpgsql AS $$
RETURN pg_typeof(i);
SELECT test_func(NULL);
ERROR:  domain text_not_null does not allow null values
CONTEXT: PL/pgSQL function test_func(test_table) while storing call arguments into local variables

I think what's happening is when plpgsql_exec_function() is copying the arguments into plpgsql variables it's recursing into test_table.c and attempting to create c(NULL,NULL) instead of just setting test_table.c to NULL.

FWIW, the only reason I created 'text_not_null' in my real-word case is because I have a compound type that I don't want to allow NULLS for some of it's fields. I'm not sure why that's not supported, but it would be nice if I could just do CREATE TYPE c AS (t text NOT NULL, i int);
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble!
855-TREBLE2 (855-873-2532)   mobile: 512-569-9461

Sent via pgsql-hackers mailing list (
To make changes to your subscription:

Reply via email to