Re: Should IGNORE NULLS cache nullness for volatile arguments?

Tatsuo Ishii <ishii@postgresql.org>

From: Tatsuo Ishii <ishii@postgresql.org>
To: li.evan.chao@gmail.com
Cc: pgsql-hackers@postgresql.org, ojford@gmail.com
Date: 2026-05-14T12:56:22Z
Lists: pgsql-hackers
Hi Chao,

>> The attached patch makes a small change in that direction. It only uses the IGNORE NULLS nullness cache when the argument is safe to reuse. For non-cacheable arguments, the nullness is treated as unknown and the argument is evaluated again.
>> 
>> See the attached patch for details.
> 
> I will look into the patches.

@@ -3454,7 +3455,10 @@ ignorenulls_getfuncarginframe(WindowObject winobj, int argno,
 		if (isout)
 			*isout = false;
 
-		v = get_notnull_info(winobj, abs_pos, argno);
+		if (winobj->notnull_info_cacheable[argno])

What about moving this if statement inside get_notnull_info() so that
the caller does not care about this argno is cacheable or not?

+			/* record the row status if it is safe to reuse */
+			if (winobj->notnull_info_cacheable[argno])
+				put_notnull_info(winobj, abs_pos, argno, *isnull);

Similary, we can move "if (winobj->notnull_info_cacheable[argno])" inside put_notnull_info().

Regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp