PL/pgSQL NOT NULL variables

Поиск
Список
Период
Сортировка
От Richard Poole
Тема PL/pgSQL NOT NULL variables
Дата
Msg-id 20010105163409.C23742@office.vi.net
обсуждение исходный текст
Ответы Re: PL/pgSQL NOT NULL variables
Re: PL/pgSQL NOT NULL variables
Список pgsql-general
This is my first attempt at using PL/pgSQL so I may be carrying around
a grotesque misconception of some sort...

I can't get NOT NULL variables to work at all in PL/pgSQL. Here's a
simple function which uses a default value for a variable:

test=> create function t1() returns integer as '
test'> declare foo integer := 42;
test'> begin return foo; end;
test'> ' language 'plpgsql';
CREATE
test=> select t1();
 t1
----
 42
(1 row)


No problem at all. But if I create a function exactly identical except
for making the variable NOT NULL:

test=> create function t2() returns integer as '
test'> declare foo integer not null := 42;
test'> begin return foo; end;
test'> ' language 'plpgsql';
CREATE
test=> select t2();
ERROR:  NULL assignment to variable 'foo' declared NOT NULL

I've tried using DEFAULT instead of :=, which the docs suggest should
be equivalent, and the same thing happens. Similarly when I use type
"text". As there are no NOT NULL variables in the examples or the
regression tests, I suspect I may have found a bug. Does anybody have
NOT NULL working in a PL/pgSQL function? Can anybody shed any light
on what I may be doing wrong?

7.02 on Debian GNU/Linux, FWIW.

Richard

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Re: pg_dump return status..
Следующее
От: Scott Shealy
Дата:
Сообщение: ODBC failure