From: | Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com> |
---|---|
To: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Bug with plpgsql handling of NULL argument of compound type |
Date: | 2016-07-22 17:50:30 |
Message-ID: | 4f6a90a0-c6e8-22eb-3b7a-727f8a60f3b1@BlueTreble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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 $$
BEGIN
RETURN pg_typeof(i);
END$$;
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! http://BlueTreble.com
855-TREBLE2 (855-873-2532) mobile: 512-569-9461
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Janes | 2016-07-22 18:03:35 | Re: fixes for the Danish locale |
Previous Message | Tom Lane | 2016-07-22 15:33:03 | Re: Oddity in handling of cached plans for FDW queries |