From: Michael Paquier <michael@paquier.xyz>
To: Tatsuo Ishii <ishii@postgresql.org>
Cc: li.evan.chao@gmail.com
Cc: tgl@sss.pgh.pa.us
Cc: pramsey@cleverelephant.ca
Cc: ojford@gmail.com
Cc: peter@eisentraut.org
Cc: krasiyan@gmail.com
Cc: vik@postgresfriends.org
Cc: andrew@tao11.riddles.org.uk
Cc: david@fetter.org
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options
Date: Thu, 16 Oct 2025 15:19:21 +0900
Message-ID: <aPCOabSE4VfJLaky@paquier.xyz> (raw)
In-Reply-To: <20251014.192113.1554227757626092006.ishii@postgresql.org>
References: <20251011.144218.1729318385118014326.ishii@postgresql.org>
<66A28678-BDC0-4266-9244-74320D578222@gmail.com>
<20251013.143941.1447453701514209859.ishii@postgresql.org>
<20251014.192113.1554227757626092006.ishii@postgresql.org>
On Tue, Oct 14, 2025 at 07:21:13PM +0900, Tatsuo Ishii wrote:
> V2 patch pushed. Thanks.
Coverity thinks that this code has still some incorrect bits, and I
think that it is right to think so even on today's HEAD at
02c171f63fca.
In WinGetFuncArgInPartition()@nodeWindowAgg.c, we have the following
loop (keeping only the relevant parts:
do
{
[...]
else /* need to check NULL or not */
{
/* get tuple and evaluate in partition */
datum = gettuple_eval_partition(winobj, argno,
abs_pos, isnull, &myisout);
if (myisout) /* out of partition? */
break;
if (!*isnull)
notnull_offset++;
/* record the row status */
put_notnull_info(winobj, abs_pos, *isnull);
}
} while (notnull_offset < notnull_relpos);
/* get tuple and evaluate in partition */
datum = gettuple_eval_partition(winobj, argno,
abs_pos, isnull, &myisout);
And Coverity is telling that there is no point in setting a datum in
this else condition to just override its value when we exit the while
loop. To me, it's a sigh that this code's logic could be simplified.
In passing, gettuple_eval_partition() is under-documented for me. Its
name refers to the fact that it gets a tuple and evaluates a
partition. Its top comment tells the same thing as the name of the
function, so it's a bit hard to say why it is useful with the code
written this way, and how others many benefit when attempting to reuse
it, or if it even makes sense to reuse it for other purposes.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
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-hackers@postgresql.org
Cc: michael@paquier.xyz, ishii@postgresql.org, li.evan.chao@gmail.com, tgl@sss.pgh.pa.us, pramsey@cleverelephant.ca, ojford@gmail.com, peter@eisentraut.org, krasiyan@gmail.com, vik@postgresfriends.org, andrew@tao11.riddles.org.uk, david@fetter.org
Subject: Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options
In-Reply-To: <aPCOabSE4VfJLaky@paquier.xyz>
References: <20251011.144218.1729318385118014326.ishii@postgresql.org> <66A28678-BDC0-4266-9244-74320D578222@gmail.com> <20251013.143941.1447453701514209859.ishii@postgresql.org> <20251014.192113.1554227757626092006.ishii@postgresql.org> <aPCOabSE4VfJLaky@paquier.xyz>
* 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