Bug with plpgsql handling of NULL argument of compound type

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Bug with plpgsql handling of NULL argument of compound type
Дата
Msg-id 4f6a90a0-c6e8-22eb-3b7a-727f8a60f3b1@BlueTreble.com
обсуждение исходный текст
Ответы Re: Bug with plpgsql handling of NULL argument of compound type  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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



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

Предыдущее
От: Guangzhou Zhang
Дата:
Сообщение: Re: Unexpected memory usage for repeated inserts within plpgsql function
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: fixes for the Danish locale