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.96) (envelope-from ) id 1wf5bY-005Fox-14 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jul 2026 00:48:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wf5bV-00GRlv-1Z for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jul 2026 00:48:33 +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.96) (envelope-from ) id 1wf5bV-00GRll-0X for pgsql-hackers@lists.postgresql.org; Thu, 02 Jul 2026 00:48:33 +0000 Received: from meldrar.postgresql.org ([2a02:c0:301:0:ffff::31]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wf5bS-00000001I5O-2pCI for pgsql-hackers@postgresql.org; Thu, 02 Jul 2026 00:48:32 +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=HbOOhqOZdg1DCL28OBxlhH0UJUtQ4l21VXqJ915bUr8=; b=DCACflWrfDehkg1j1vfBo9YKTq o6yN9K5qNfbpLVvIvylkwTEsRJZT7t11334wrM6AaqSIskc9Zw52mqCSrqjm/wTnEU72lXgZYrsYg groczOvfHMyphH5z4P8sbiRfCnTCF0R7Na6yvlZCEC2XC81AO00ONA1HhLu+Slnl8MvFQvvOJDXnc wJq3bR7iFU9hgxUAp8NzJVuawzJThEjnID3rnFAoo8Gva8oI6QuN7rP+fmHMFwX0RHpp9MYUWNZP+ rQ0+uLb7SXewFWqEdFjaIhZIBbmxR+zB49w8aZZ/ZraCw6irYR3o6kpeOVRnMUbWM2uaJMXp170s2 tUN779gQ==; Received: from [2409:11:4120:300:10cd:4f98:1e95:9358] (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 1wf5bQ-008r7f-0Z; Thu, 02 Jul 2026 00:48:30 +0000 Date: Thu, 02 Jul 2026 09:48:13 +0900 (JST) Message-Id: <20260702.094813.2267011850936872788.ishii@postgresql.org> To: assam258@gmail.com Cc: jian.universality@gmail.com, pgsql-hackers@postgresql.org, zsolt.parragi@percona.com, sjjang112233@gmail.com, vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, li.evan.chao@gmail.com Subject: Re: Row pattern recognition From: Tatsuo Ishii In-Reply-To: References: <20260629.183730.1799088184925453299.ishii@postgresql.org> <20260701.211805.2273383346456030984.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:10cd:4f98:1e95:9358 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Henson, > Hi Tatsuo, > > Thanks for the review. I agree with the direction -- the (void) is > confusing. I did try your exact suggestion and the regression tests pass > unchanged, but I would keep one guard, for the following reason. > >> Is there any reason that we call row_is_in_reduced_frame() here, >> instead of something like: >> >> update_frameheadpos(winstate); >> update_reduced_frame(winobj, pos); > > row_is_in_reduced_frame() guards the update: > > state = get_reduced_frame_status(winstate, pos); > if (state == RF_NOT_DETERMINED) > { > update_frameheadpos(winstate); > update_reduced_frame(winobj, pos); > } > > Calling update_reduced_frame() unconditionally drops that guard. When > currentpos is already determined -- e.g. an interior row of a previous > match under AFTER MATCH SKIP PAST LAST ROW (RF_SKIPPED) -- it takes an > O(1) early return and overwrites the shared rpr_match_* record, silently > reclassifying a SKIPPED row as UNMATCHED. > > This is not observable today -- I confirmed with a guarded-vs-unguarded > differential (patterns, both skip modes, various aggregates: identical > output), because both paths end up with an empty reduced frame. But it > does change the state semantics and leans on that convergence, so I would > rather keep the guard. Two ways, both of which remove the (void): Thanks for the explanation. That makese sense. > A) Keep the guard inline at the call site. > > B) Factor it into a small helper shared by the nav-driving call site > and row_is_in_reduced_frame(): > > static void > ensure_reduced_frame(WindowObject winobj, int64 pos) > { > WindowAggState *winstate = winobj->winstate; > > if (get_reduced_frame_status(winstate, pos) == > RF_NOT_DETERMINED) > { > update_frameheadpos(winstate); > update_reduced_frame(winobj, pos); > } > } > > I lean towards B (no duplicated guard, and the name states the intent), > but A is the smaller diff. Which do you prefer? I like B too. Regards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp