NULL values in PL/pgSQL functions input

Поиск
Список
Период
Сортировка
От Alex Bolenok
Тема NULL values in PL/pgSQL functions input
Дата
Msg-id 000901bffde8$284984d0$df02a8c0@artey.ru
обсуждение исходный текст
Список pgsql-general
I wrote a function in PL/pgSQL that can accept NULL input values in some
variables. But I found that if I pass a single NULL value to the function,
all other values become NULL too. Here is the example:

CREATE FUNCTION fn_test(INT4, NUMERIC)
    RETURNS NUMERIC AS '
    BEGIN
        RAISE NOTICE
        ''%, %'', $1, $2;
        RETURN $2;
    END;
    ' LANGUAGE 'plpgsql';

peroon#= SELECT fn_test(1, 2.00);
NOTICE:  1, 2.000000
 fn_test
---------
       2
(1 row)
peroon#= SELECT fn_test(1, NULL);
NOTICE:  <NULL>, <NULL>
 fn_test
---------

(1 row)

Is it a bug?

I found no notice about it in documentation, so one more question:

Is there any workaround?

Alex Bolenok.


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

Предыдущее
От: Peter Mount
Дата:
Сообщение: RE: [HACKERS] pg_dump/restore to convert BLOBs to LZTEXT (optiona l!)
Следующее
От: Philip Warner
Дата:
Сообщение: Strange strategy with COALESCE?