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 1w337t-000qiU-2T for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 02:28:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w337s-00Fz7N-28 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 02:28:44 +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 1w337s-00Fz77-0r for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2026 02:28:44 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w337o-00000000Snt-1Ggp for pgsql-hackers@postgresql.org; Thu, 19 Mar 2026 02:28:43 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-2b05fd1d147so1947855ad.2 for ; Wed, 18 Mar 2026 19:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773887321; cv=none; d=google.com; s=arc-20240605; b=GBlZbQC0iICVuJl2bm+9D+HyRwn/IM0fg+wf5RmbizCHc80RQzqlJvUjU9fmNvYGXu o4yRCPwe0Vkg9NF3ySexOWhFVy5kuulpMk5NzprwYGiCT4AXcZFCGGLMC9C7M5GRJ5F8 Qs8DAwO4JTBJ6/jvvBbRHohWwKo5c+dcl0AOxUp0mxls7jtoZv3Ofa72PLUinCDa5vP/ /CupSbW22qWMVnL0q1WLKZzUcLLEfUMg9418mVjr0mOq31OXvZOz5KxM3nBoGuS3z4Ug G3KDBYD4N/IG3+1EIQiZkPIhZKid2HXbnlrBdrAIpc7piTBoOYzWRuN/9VGPo8XLpUI7 /dmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:dkim-signature; bh=9wUl5q8TaMYziHquZIiNJVgVNYdB2RmrsJXT4YlOQ/s=; fh=RpkixSUKBSq2kS7FQ1cbmGy/3qVDIg+0+ZBWKu2yVno=; b=c5zeji1YYufbETAM1Sdyu6XyfI8FqXQ3+U6oJNo8s61HJ+dhG8T3bHWqyiLmw/8rzT Djy62rIMsaoM4DIFoL7xq0Z1ripMTAE0Ks3h25SOJ5q6S2VdKPfwKgxTMUn779EHwUO9 fo8p5Y4ALoZXFCgZxPu+3QmHMEdGFa/OemkrgmmKpDTLTTomx0gaqfyZdaTxFzoaPcx7 4MzsFYwNf9bJe2Bj8pOptO9sGFrj40WB3MR2LuPVy6IGvqzBwIRJnd8tfQfaPTnm1RQL F3O+aWxVA6Hjp/DL4kI8hd40Lp+RFf4kZKUrKeAiUviBk1h62a4gOhLy/nROH0TNUn+8 iQiA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773887321; x=1774492121; darn=postgresql.org; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9wUl5q8TaMYziHquZIiNJVgVNYdB2RmrsJXT4YlOQ/s=; b=WGPjt//++lERI66T592GxqCTcP0NPLXHn0vhYVktTMhJi7306wO8gQbDDMvVX4ei/3 tbutWfYmg++9Gxsi6rSshGG4BRd9olpMsLT6GdXk4iNQWg/qUOQJddC4T9ksjm7KDrUd yxZHILn+MLT9+GmFT/Vwg6VyfCwRHJKQRTAW5gh+UQxxoRZez3Ww99lLLxQHFMp/0sB7 d3RXaogWp6M4XBxM1Rbh/NdwF4Vb5ZkIO//8JMvJC7fOpFgdNJN0yXSHsAp2L0iZJPyy hx+Uot+F0XyaBuMsx4m5G203QsxKRSHQw2lXGjsqDN2kUXvmxy3vrc8dtgzqgPWMiLF9 DjOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773887321; x=1774492121; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9wUl5q8TaMYziHquZIiNJVgVNYdB2RmrsJXT4YlOQ/s=; b=mVk62SnwruTfTLipG6UmDf4EvjfoG4eB6v454zgsA53ryg1Vc0+zwssZD9fiMyRoH/ sSwuIownlVwfksR5A1RqEKKTFHVH7dWh/068h0sksLVjKENuV6M2zBWQIpV0/E9I+Flt QgKsrB4hQgqEHb8H6s24aC0AZmJi8XEMvisdcbK9JFFvL8wSk4bypxe+02hFtEaNgYkb xLyp38GYIKBw0gUnbBbk9FAf1NU5XE4wHXoMivqQE2DkKzZibP4Y1R+QNySXclNArRzv R4qxTQaiVSYLRfUgn4/oVpMkdZs32UeL+j3SkIlMFQy+3A+y8koakJcucaGzjvr555tz LDxw== X-Forwarded-Encrypted: i=1; AJvYcCWW74LfU/22sq7fRbygp3Nb7T1NVXC1bZKGyH+EUt2DlcF82DU8UE3vv35c2/BMKNETC+ZXXw91LSE6xdZF@postgresql.org X-Gm-Message-State: AOJu0YxJUAQdhW29NKsvhQ34clKniDsW2Spzg5RCjz1888CVfL7aU1/y sHMi9WMJg/hUKcUOMRC7cbvclYeoq70jVSWizBtMJ62r4cUXXIfQbIhqgkcp6tQ0OhjqYSg9Hiu hlt+dblsih+fWhHc4b54FatrmyvTo4sQ= X-Gm-Gg: ATEYQzxH9Dgd+M/QCnV+KFposWfpYmHB/QRDk/SkwHskya/G7kbENDH4EAy4Mg2FHwq QyOHq8u+Zc45WkJe2hNyQAe9E09KtSYDg0GqOmnn44uNVcf/r0MLTKriR3xCErucCFVRd2BYZeV YQh9K6bZnJB5SGP8gc68moM+krTeeSjhhiXKUBd/OQ3lbvkfmWAWN+vVw+TPmbtbI5SH6Ufheag xGzn2jGEjLcl/9ZZ9eq+DFGvtErTdqyTdPFMYHM6tVrgJkAdUU+Lyv9bzAupYtPdYlriu0ekFtO R7VUhB+ccqyByVmloU/frzCEroUvUP8A5X0plsE= X-Received: by 2002:a17:902:e812:b0:2b0:5770:d485 with SMTP id d9443c01a7336-2b06e3238ffmr56172745ad.11.1773887320901; Wed, 18 Mar 2026 19:28:40 -0700 (PDT) MIME-Version: 1.0 References: <20260318.204139.106185544494720182.ishii@postgresql.org> <20260319.103930.390354862957599874.ishii@postgresql.org> In-Reply-To: <20260319.103930.390354862957599874.ishii@postgresql.org> Reply-To: assam258@gmail.com From: Henson Choi Date: Thu, 19 Mar 2026 11:28:29 +0900 X-Gm-Features: AaiRm50PRUNpvNek9vm_4hqxk9H1QzcJkltBl960bhaJnSF98LYZNGAPjyqH_BE Message-ID: Subject: Re: Row pattern recognition To: Tatsuo Ishii , zsolt.parragi@percona.com Cc: sjjang112233@gmail.com, vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, pgsql-hackers@postgresql.org Content-Type: multipart/alternative; boundary="000000000000a24cda064d5753cd" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a24cda064d5753cd Content-Type: text/plain; charset="UTF-8" Hi Tatsuo, Zsolt, I just confirmed the crash. > > Henson, What do you think? > Good catch by Zsolt. Your careful review is really helping a lot. I've fixed both the prefix merge and suffix merge paths in mergeGroupPrefixSuffix() to also increment child->max. I'll include the fix with a regression test in the next patch series. Regarding the suggested fix: if (child->max != RPR_QUANTITY_INF) child->max += 1; While the quantifier value is int (INT32_MAX = RPR_QUANTITY_INF), making such repetition counts practically impossible, the +1 approach is not semantically equivalent -- it could silently turn a finite max into infinity. Instead, I took a fallback approach: skip the merge entirely when min or max would reach RPR_QUANTITY_INF after increment, consistent with the overflow checks in mergeConsecutiveVars/Groups. > Good point. You are right, the plan cache should be read only. > However, Henson is working on a different approach and the code will > not be used any more... > Yes, I'm currently working on a slot-based approach (1-slot PREV/NEXT) that won't need attno_map, so the plan cache mutation issue will be gone. > I forggot to include the data file. Please apply attached patch on top > of v45. > Got it, thanks. By the way, how about splitting the test patch into two -- one for sql + data files and another for expected output files? The single test patch is getting quite large and cfbot often fails to apply it. Right. Maybe ERRCODE_TOO_MANY_ARGUMENTS? > I'm currently reworking PREV/NEXT to accept 2 arguments, so this error handling will change. I'll take care of the proper error codes along with the GROUPS typo and ERRCODE_WINDOWING_ERROR change. Best regards, Henson --000000000000a24cda064d5753cd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Tatsuo, Zsolt,

I just confirmed th= e crash.

Henson, What do you think?=C2=A0

Good catch = by Zsolt. Your careful review is really helping a lot.

I've fixe= d both the prefix merge and suffix merge paths in
mergeGroupPrefixSuffix= () to also increment child->max. I'll
include the fix with a regr= ession test in the next patch series.

Regarding the suggested fix:
=C2=A0 =C2=A0 if (child->max !=3D RPR_QUA= NTITY_INF)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 child->max +=3D 1;
<= br>While the quantifier value is int (INT32_MAX =3D RPR_QUANTITY_INF),
m= aking such repetition counts practically impossible, the +1
approach is = not semantically equivalent -- it could silently turn
a finite max into = infinity. Instead, I took a fallback approach:
skip the merge entirely w= hen min or max would reach
RPR_QUANTITY_INF after increment, consistent = with the overflow
checks in mergeConsecutiveVars/Groups.=C2=A0
=C2=A0
Good point. You are right, the plan cach= e should be read only.
However, Henson is working on a different approach and the code will
not be used any more...

Yes, I'm cu= rrently working on a slot-based approach (1-slot
PREV/NEXT) that won'= ;t need attno_map, so the plan cache mutation
issue will be gone.
=C2=A0
I forggot to include the data file. Please apply attached patch on top
of v45.
=C2=A0
Got it, thanks. By the way, h= ow about splitting the test patch
into two -- one for sql + data files a= nd another for expected
output files? The single test patch is getting q= uite large and
cfbot often fails to apply it.

Right. Maybe ERRCODE_TOO_MANY_ARGUMENTS?

=C2=A0I'm currently reworking PREV/NEXT to accept 2 ar= guments, so this
error handling will change. I'll take care of the= proper error
codes along with the GROUPS typo and ERRCODE_WINDOWING_ERR= OR change.

Best regards,
Henson
--000000000000a24cda064d5753cd--