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 1v5hca-00AYLe-5Z for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Oct 2025 09:35:08 +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 1v5hcW-006ykQ-63 for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Oct 2025 09:35:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v5hcV-006yk0-Os for pgsql-hackers@lists.postgresql.org; Mon, 06 Oct 2025 09:35:04 +0000 Received: from meldrar.postgresql.org ([2a02:c0:301:0:ffff::31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v5hcS-000IA9-2B for pgsql-hackers@lists.postgresql.org; Mon, 06 Oct 2025 09:35:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Content-Transfer-Encoding:Content-Type: Mime-Version:References:In-Reply-To:From:Subject:Cc:To:Message-Id:Date:Sender :Reply-To:Content-ID:Content-Description; bh=X0ZoQOcgokwo7ub1UMB7T/m1bxDLb0ojyeGjBF0ytIU=; b=oIDqE9mvVE/n39F1QA62FH+hjo SwIh8mEowjWUbaTJOP262R/awYNUZaribrjN1q2RiqHExL4/mE+Z9NNdmYVAlq1NoHfiFQuTRhbre fcdcFMm4FsUv2RM6JrqyerwWQLZspNWil0VcNyle/zmjIqAeMA43kZj4BQPlmVXv+9mogge0E4Vno CcbbWkIA32e8yQGHm67UfhO9RbBUm+uV038msO2X3k24Am7ubKS1oLwylsp9eBQLoamM8GHvyKM1T QG73mYf02ZAcNmYFPrq/gTME66964TBPOSrRyL82p2dPj8wM1gK0GgKwweOq3CAmVwStzkofphnpi Inu5YfMw==; Received: from [2409:11:4120:300:5a63:5e94:1fae:2e4] (helo=localhost) by meldrar.postgresql.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v5hcK-001aJw-2A; Mon, 06 Oct 2025 09:34:54 +0000 Date: Mon, 06 Oct 2025 18:34:39 +0900 (JST) Message-Id: <20251006.183439.876014721998277138.ishii@postgresql.org> To: tgl@sss.pgh.pa.us Cc: 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 From: Tatsuo Ishii In-Reply-To: <20251006.085133.920304905412132984.ishii@postgresql.org> References: <20251003.100606.2086363717963832725.ishii@postgresql.org> <1686755.1759679957@sss.pgh.pa.us> <20251006.085133.920304905412132984.ishii@postgresql.org> X-Mailer: Mew version 6.8 on Emacs 29.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2409:11:4120:300:5a63:5e94:1fae:2e4 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > Thank you for the report! > >> Coverity is not very happy with this patch. >> It's complaining that the result of window_gettupleslot >> is not checked, which seems valid: >> >> 1503 { >> 1504 if (fetch_tuple) >>>>> CID 1666587: Error handling issues (CHECKED_RETURN) >>>>> Calling "window_gettupleslot" without checking return value (as is done elsewhere 8 out of 9 times). >> 1505 window_gettupleslot(winobj, pos, slot); >> 1506 if (!are_peers(winstate, slot, winstate->ss.ss_ScanTupleSlot)) >> 1507 return -1; > > Yes, I forgot to check the return value of window_gettupleslot. > >> and also that WinGetFuncArgInPartition is dereferencing >> a possibly-null "isout" pointer at several places, including >> >>>>> Dereferencing null pointer "isout". >> 3806 if (*isout) /* out of partition? */ >> >>>>> Dereferencing null pointer "isout". >> 3817 if (!*isout && set_mark) >> 3818 WinSetMarkPosition(winobj, abs_pos); >> >>>>> Dereferencing null pointer "isout". >> 3817 if (!*isout && set_mark) >> 3818 WinSetMarkPosition(winobj, abs_pos); >> >> The latter complaints seem to be because some places in >> WinGetFuncArgInPartition check for nullness of that pointer >> and some do not. That looks like at least a latent bug >> to me. > > Agreed. > > Attached is a patch to fix the issue. Please disregard the v1 patch. It includes a bug: If WinGetFuncArgInPartition() is called with set_mark == true and isout == NULL, WinSetMarkPosition() is not called by WinGetFuncArgInPartition(). I will post v2 patch. Best regards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp