From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Darafei Komяpa Praliaskouski <me@komzpa.net>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Better testing coverage and unified coding for plpgsql loops
Date: Wed, 03 Jan 2018 13:53:22 -0500
Message-ID: <20911.1515005602@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoZRN3x5s5VnVqVMVatUSwWtnJabxc-v25x9MNyc8R7+EQ@mail.gmail.com>
References: <20180102134623.4mhrbnc2im6bfp7a@alvherre.pgsql>
<31838.1514905690@sss.pgh.pa.us>
<CA+TgmoZRN3x5s5VnVqVMVatUSwWtnJabxc-v25x9MNyc8R7+EQ@mail.gmail.com>
Robert Haas <robertmhaas@gmail.com> writes:
> On Tue, Jan 2, 2018 at 10:08 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> It could be converted into a function returning bool, a la
>> if (!loop_rc_processing(...))
>> break;
> I prefer writing this sort of thing using a function call and
> dispatching on the return value, as you suggest in the text quoted
> here. Long macros that involve a zillion continuation lines are hard
> to edit, and often hard to step through properly in a debugger.
I thought about this a bit harder and realized that if we make it
a function, we will have to pass "rc" by reference since the function
needs to change it in some cases. That might have no impact if the
compiler is smart enough, but I expect on at least some compilers
it would end up forcing rc into memory with an attendant speed hit.
I really think we should stick with the macro implementation, unless
somebody wants to do some actual investigation to prove that a
function implementation imposes negligible cost. I'm not prepared
to just assume that, especially not after the work I just did on
plpgsql record processing --- I initially thought that an extra
function call or three wouldn't matter in those code paths either,
but I found out differently.
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, alvherre@alvh.no-ip.org, me@komzpa.net, pgsql-hackers@lists.postgresql.org
Subject: Re: Better testing coverage and unified coding for plpgsql loops
In-Reply-To: <20911.1515005602@sss.pgh.pa.us>
* 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