Re: BUG #8329: UPDATE x SET x.y = x.y + z does not work in PL/pgSQL

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема Re: BUG #8329: UPDATE x SET x.y = x.y + z does not work in PL/pgSQL
Дата
Msg-id 7f7d6be25f85517e14f6e957a7212e8f@news-out.riddles.org.uk
обсуждение исходный текст
Ответ на BUG #8329: UPDATE x SET x.y = x.y + z does not work in PL/pgSQL  (chmelarp@fit.vutbr.cz)
Ответы Re: BUG #8329: UPDATE x SET x.y = x.y + z does not work in PL/pgSQL  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-bugs
Seems clearly your mistake to me... you do realize that (null + z) is
always going to be null, right? Maybe your totals columns should have
been declared NOT NULL (and presumably DEFAULT 0) to avoid this
problem?

Adding some diagnostics to your function (and fixing all the syntax
errors) and running it shows that you're frequently trying to add to
nulls, e.g.:

NOTICE:  sum_pkt_in_int = <NULL>
NOTICE:  sum_orig_raw_pktcount = 4
NOTICE:  sum_pkt_in_int = <NULL>
NOTICE:  sum_orig_raw_pktcount = 599

these diagnostics were obtained as follows:

CREATE OR REPLACE FUNCTION statistics.notice(text, anyelement)
 RETURNS anyelement
 LANGUAGE plpgsql
AS $function$ begin raise notice '% = %', $1, $2; return $2; end; $function$

and changing your update to:

  sum_pkt_in_int  = notice(''sum_pkt_in_int'',sum_pkt_in_int)
                    + notice(''sum_orig_raw_pktcount'',sum_orig_raw_pktcount),
       -- XXX THIS IS IT, does not work even when ... + 1000000 XXX

(doing \set VERBOSITY terse in psql is a good idea for this case to
avoid excessive CONTEXT output)

--
Andrew (irc:RhodiumToad)

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

Предыдущее
От: harshmailbox85@gmail.com
Дата:
Сообщение: BUG #8336: pgAgent is not working
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: BUG #8329: UPDATE x SET x.y = x.y + z does not work in PL/pgSQL