Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v5Rxm-0070PX-VR for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Oct 2025 16:51:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v5Rxj-0035fu-6X for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Oct 2025 16:51:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v5Rxi-0035fm-TP for pgsql-hackers@lists.postgresql.org; Sun, 05 Oct 2025 16:51:55 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v5Rxh-000XDx-0W for pgsql-hackers@lists.postgresql.org; Sun, 05 Oct 2025 16:51:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 595Gpjfk1694378; Sun, 5 Oct 2025 12:51:45 -0400 From: Tom Lane To: =?utf-8?Q?=C3=81lvaro?= Herrera cc: Tatsuo Ishii , ojford@gmail.com, peter@eisentraut.org, li.evan.chao@gmail.com, krasiyan@gmail.com, vik@postgresfriends.org, andrew@tao11.riddles.org.uk, david@fetter.org, pgsql-hackers@lists.postgresql.org Subject: Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options In-reply-to: <202510051612.gw67jlc2iqpw@alvherre.pgsql> References: <202510051612.gw67jlc2iqpw@alvherre.pgsql> Comments: In-reply-to =?utf-8?Q?=C3=81lvaro?= Herrera message dated "Sun, 05 Oct 2025 18:20:30 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1694376.1759683105.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 05 Oct 2025 12:51:45 -0400 Message-ID: <1694377.1759683105@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =3D?utf-8?Q?=3DC3=3D81lvaro?=3D Herrera writes: > I just noticed this compiler warning in a CI run, > [16:06:29.920] ../src/backend/executor/nodeWindowAgg.c:3820:16: warning:= =E2=80=98datum=E2=80=99 may be used uninitialized [-Wmaybe-uninitialized] > [16:06:29.920] 3820 | return datum; > [16:06:29.920] | ^~~~~ Yeah, I can easily believe that a compiler running at relatively low optimization level wouldn't make the connection that the NN_NOTNULL case must perform the "prepare to exit this loop" bit if the loop will be exited this time. But there's another thing that is confusing: the NN_NULL case certainly looks like it's expecting to exit the loop, but that "break" will only get out of the switch not the loop. Moreover, the NN_NULL case looks like it'd fail to notice end-of-frame. And it's not entirely clear what the default case thinks it's doing either. In short, this loop is impossible to understand, and the lack of comments doesn't help. Even if it's not actually buggy, it needs to be rewritten in a way that helps readers and compilers see that it's not buggy. I think it might help to separate the detection of null-ness and fetching of the datum value (if required) from the loop control logic. regards, tom lane