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 1wYEQe-0008fm-32 for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Jun 2026 02:49:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wYEQd-002Yv0-2D for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Jun 2026 02:48:59 +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.96) (envelope-from ) id 1wYEQd-002Yuo-0i for pgsql-hackers@lists.postgresql.org; Sat, 13 Jun 2026 02:48:59 +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.98.2) (envelope-from ) id 1wYEQa-000000006Gm-14t2; Sat, 13 Jun 2026 02:48:58 +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=4USQpqgoTJnsl9v03m/plkxREj1rndwkzAaFePyX3cU=; b=2Vyav4ZmK/GfCkNJo60FtJVgV7 /R6O/elP8ruUFv2E41DxhjqsB8X1Hh2q05NZoqnCxh9v5G8xEvbTx/I9dfzzKcKqp7pj/WirFX2o4 GcPGi3z7xKWDb5fsIXquyZqoGxFJv1yZczcxntDaRBiPk1rlEDPNlkzCpO2ppM3pC17vP8jU7OJAF 45G5UTNCBL4FJLjkvgVYYDA6MqtWlwrnj3f2SftKJ4yxfbHwKOscIMgHaQ5VTSNEygTh6DzIr4FAp mXEDU5fzZB7qnwpMRLbUbbVS/lNhQmrFnDKsgXgUSs3N0EJh0/+aMYN80wox5jTdSS/LO1IArw+If z554tygA==; Received: from [2409:11:4120:300:df6d:47f8:2800:6b15] (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 1wYEQQ-000GCO-0u; Sat, 13 Jun 2026 02:48:48 +0000 Date: Sat, 13 Jun 2026 11:48:31 +0900 (JST) Message-Id: <20260613.114831.102648086806206558.ishii@postgresql.org> To: assam258@gmail.com Cc: jian.universality@gmail.com, ishii@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, pgsql-hackers@postgresql.org Subject: Re: Row pattern recognition From: Tatsuo Ishii In-Reply-To: References: 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:df6d:47f8:2800:6b15 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Henson, I looked into 0051 and have some suggestions. If you like, can you please included the changes in v49? I am going to release v48 soon. Regards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp > index 1a754bcdac5..7ba0b6df849 100644 > --- a/src/backend/commands/explain.c > +++ b/src/backend/commands/explain.c > +static int > +deparse_rpr_node(RPRPattern *pattern, int i, int limit, StringInfo buf) One letter function argument name "i" looks unusual and better to be named more meaningful one, like idx? > /* > - * Process an ALT element: adjust depth parens and register separator positions. > + * Find the END that closes the group opened by the BEGIN at beginIdx: the > + * first END at the same depth scanning forward. > */ > -static void > -deparse_rpr_alt(RPRPattern *pattern, int *idx, StringInfoData *buf, > - RPRDepth *prevDepth, bool *needSpace, List **altSeps) > +static int > +rpr_match_end(RPRPattern *pattern, int beginIdx) > { > - RPRPatternElement *elem = &pattern->elements[*idx]; > - > - /* Close parens for depth decrease */ > - while (*prevDepth > elem->depth) > - { > - appendStringInfoChar(buf, ')'); > - (*prevDepth)--; > - *needSpace = true; > - } > - > - /* Open parens up to ALT's depth */ > - while (*prevDepth < elem->depth) > - { > - if (*needSpace) > - appendStringInfoChar(buf, ' '); > - appendStringInfoChar(buf, '('); > - (*prevDepth)++; > - *needSpace = false; > - } > + RPRDepth d = pattern->elements[beginIdx].depth; > + int j; If we change function arugument to other than "i", "j" here better to be named "i". > /* > - * Process a VAR element: adjust depth parens and output variable name. > + * Scope end of the construct at index i: the first following element whose > + * depth is no greater than i's own. For an ALT marker this is the index just > + * past its last branch, since depth stays constant across branch boundaries. > + * FIN sits at depth 0, so a top-level ALT stops there. > */ > -static void > -deparse_rpr_var(RPRPattern *pattern, int *idx, StringInfoData *buf, > - RPRDepth *prevDepth, bool *needSpace, List **altSeps) > +static int > +rpr_alt_scope_end(RPRPattern *pattern, int i) One letter argument name "i" looks unusual and better to be named more meaningful one, like idx? > { > - RPRPatternElement *elem = &pattern->elements[*idx]; > - > - /* Open parens for depth increase */ > - while (*prevDepth < elem->depth) > - { > - if (*needSpace) > - appendStringInfoChar(buf, ' '); > - appendStringInfoChar(buf, '('); > - (*prevDepth)++; > - *needSpace = false; > - } > + RPRDepth d = pattern->elements[i].depth; > + int k; If we change function arugument to other than "i", "j" here better to be named "i". > +/* > + * Boundary of the alternation branch starting at b (i.e. the start of the next > + * branch, or altEnd if b is the last branch). > + * > + * The branch-start element's jump points at the next branch when this is not > + * the last branch. jump is overloaded (a group BEGIN also uses it for its > + * skip path), so confirm a real branch boundary with the relative test > + * elem[j-1].next != j: at a true boundary the preceding branch's tail has its > + * next redirected past the alternation, so it does not point at j. > + */ > +static int > +rpr_next_branch(RPRPattern *pattern, int b, int altEnd) One letter function argument name "b" looks unusual and better to be named more meaningful one, like bno or bid? Regards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp