From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Petr Chmelar <chmelarp@fit.vutbr.cz>
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #8329: UPDATE x SET x.y = x.y + z does not work in PL/pgSQL
Date: Sat, 27 Jul 2013 03:00:22 +0000
Message-ID: <7f7d6be25f85517e14f6e957a7212e8f@news-out.riddles.org.uk> (raw)
References: <E1V20Jm-0002iy-BQ@wrigleys.postgresql.org>
<CAGrpgQ9HGz=4+17-yt3uRaWHJmBXOHXX9MyfkZcTETgpCahf0g@mail.gmail.com>
<cy1oxh.mqghb4.2x6c5e-qmf@kazi.fit.vutbr.cz>
<51F17357.2030103@fit.vutbr.cz>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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)
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andrew@tao11.riddles.org.uk, chmelarp@fit.vutbr.cz
Subject: Re: BUG #8329: UPDATE x SET x.y = x.y + z does not work in PL/pgSQL
In-Reply-To: <7f7d6be25f85517e14f6e957a7212e8f@news-out.riddles.org.uk>
References: <E1V20Jm-0002iy-BQ@wrigleys.postgresql.org> <CAGrpgQ9HGz=4+17-yt3uRaWHJmBXOHXX9MyfkZcTETgpCahf0g@mail.gmail.com> <cy1oxh.mqghb4.2x6c5e-qmf@kazi.fit.vutbr.cz> <51F17357.2030103@fit.vutbr.cz> <7f7d6be25f85517e14f6e957a7212e8f@news-out.riddles.org.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox