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 1vqVRU-00C51m-1C for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Feb 2026 12:05:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vqVRT-008MJB-0t for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Feb 2026 12:05:08 +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 1vqVRS-008MJ2-2h for pgsql-hackers@lists.postgresql.org; Thu, 12 Feb 2026 12:05:07 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vqVRQ-00000000HNf-40UD for pgsql-hackers@postgresql.org; Thu, 12 Feb 2026 12:05:06 +0000 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-3530e7b3dc2so2685348a91.3 for ; Thu, 12 Feb 2026 04:05:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1770897904; cv=none; d=google.com; s=arc-20240605; b=i8OoQpiI8nqR4nuRj+vj+Yijs0gYzLX8gBAXemKXlyli5utp3j0odOR9OH7avvgj+X VSs0KR8/d8XpJiIrt21HlnvbsSJLsOCZMw2HnOYIjpJoQu9IWvp07KtYY0ODjg6b+mVM ioxzye2nViNMfvmuASEL7AWJYwQ5thkV2DtQoYTbH5R6tewJOCyBkk1m2HZSBUD6unaz PUnakn7WDDLg/WQIBEU/rZylRHaQt0oRjmnor3HFDkNnYGjTmPo3YTI/JderCZrYkoX7 jdnNRxqYMcZPpXU4I+iDw+triuS37N9FpMlJbynFv6w56jrNF+XpSZ2dlDzZla9oiULV oKLA== 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=Y+KSuCXkpkvEfz3EXvtBIvZfQqP1FtDiEpk2a/l52Oo=; fh=AA/qtjb4tuEpihPjjKyhYy4Sf31EphbgFoL7fuS7J5g=; b=UaImwO8zz1Rb7YgqnlrsWxAlurOEG92j/0aaGziW+ATmXBRNHJF50790SJmViVnHxI lYGKx+3JXpd/S8mgEY0WrynWProz82VaHD15ugjGP8UDLQPLBuOkD/8lSRHzY8AXYxDp tosuv6uICGh5fUqXzqeMJ/fj7AbVhAaOmcTQuPIz69fuRWLwoOTckVDHNSMmoOmykpAD 1AlstDR1K20PgEtJWM+ZewvEx+aJtrDTj4B9UDS3N4WEi1AHaguFhpn2pINZkFw8bGKN UNNbBnDxdAIGZp8plsKUeLR0jfB8OiHqOtQDeWkyxP6BnNYvoF6fGzJp9hFWFOGvEsRN +Rjg==; 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=1770897904; x=1771502704; 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=Y+KSuCXkpkvEfz3EXvtBIvZfQqP1FtDiEpk2a/l52Oo=; b=cuQFV9Wzo3FrIpy5Eb6lXq4CMtg9GKJLcSoX5qYI3QfC1qVHfGnbJdgliQuHneKRnU GaIqMzNYVb8k2TFkaNOtQn/q8zohCkjlQa2BCSYWkzZFpdQU5QTs45MW+SX2v+cUR4w+ kx7EJqTokBItVzyGPwKlCVP8IsPqCaza498xeXneJRliqMMKMOvadT9lrKjIQPROOBpz OaxWgsLH7rfEX3lh7uFHMkLhRGzybaoG5r0g7LCGn88l5pphYtAotJtBaqUPm0SlJv/h gt00xi0rPYShurzzO2IDgsf3chg+tNiM6XYkWYPP8ZGzsYWMj7d9Hhy+M5rBuhnAiTbT WIJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770897904; x=1771502704; 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=Y+KSuCXkpkvEfz3EXvtBIvZfQqP1FtDiEpk2a/l52Oo=; b=h6514lnrGdf+4sanp+3tJVPRab3VS79Ykw4iEHNr3pvSfdXbku9dLCph35mMJTjTiY 5kEJsE7r33CejZRBlDLL5FV9v7dg6KxvzTzYmJjSrWX2HMtO9Tyjf49Mlb51ELnlJcCV cb418Xj9twE6b2hWpjV48ybbaGCKbSg9allS5EhpfRERzfUE6Kol2Pk6IeN2op6XuQXa mdNkbCVxbcTnnrb4jzmRS3dy4qrxJiFHejfOzS6Argqs59cJGD6x2hTekHSd90DFu8db gV4MGQYrFE/FRccVJxGUu95oeDPyJyrsmObhIn51z2hRDw15xLdUAA9GYb0PfW/M4AfN SyLA== X-Forwarded-Encrypted: i=1; AJvYcCVFCYUo2HUaeeeVitNCfEhH/UX5fY7jSZirUUggrRYflauPOgE7Bd3sEDILbk5Y/X6PSgEnQAZ84wT1AtHv@postgresql.org X-Gm-Message-State: AOJu0YxiQo3bTPZnGOdEMrQNB513iXTKjtYBrAQHt2QbRlpA0JRDtZa1 Nki5hXWZa2CdgYBWo9cUxELqzC5pfSqk0qQQOiLn/DDZm/FxzggRTerv11tTleUAVx26I+KX7ZZ LzmgnXQQRlmf0LUmqZ3MEXvIdH8MHQCg= X-Gm-Gg: AZuq6aJ4Q+5D7aop4eFrIVNCgEjeELNRfIPWgcEGr4dEXbUWfkrYEqVrp/GP45J9oCj 7q3OfMDO59rv4pZz9fgnxn5QSk+VXiaG5Uxdtr1LbIb4s4fCiI8hqTTe9yF/jlJZr94Qk8/ctFb +Lag5oPvm9RkbWgyTvnkSCQLNLlJzhdkywCDWi3bH+mRaV/+RlRgBPpKqQeemEwMoWcqeUujh7t gBRMOmQuysNK83pS+ncEt2i5t5hqsZmYQPy4+wWBAflbb4/uq1F2tR3XSrYmzvv2mwoP9PwSabk 2kzdXOb0zqax5WN/kN7uHOrIo4AfnuXnqcTP3DxshATjGQKQdss= X-Received: by 2002:a17:90b:1f8b:b0:356:41c2:897d with SMTP id 98e67ed59e1d1-35693cbd055mr1914667a91.8.1770897904319; Thu, 12 Feb 2026 04:05:04 -0800 (PST) MIME-Version: 1.0 References: <20260209.190209.470246357440525054.ishii@postgresql.org> <20260211.125032.1207789314761104094.ishii@postgresql.org> <20260212.101701.1434868071304923886.ishii@postgresql.org> In-Reply-To: <20260212.101701.1434868071304923886.ishii@postgresql.org> Reply-To: assam258@gmail.com From: Henson Choi Date: Thu, 12 Feb 2026 21:04:52 +0900 X-Gm-Features: AZwV_QiQipFZFQxl6o2lYj_Se_N2u4rEFoNXm69LW6kW9xr9cet7jL_ZZkVy4U8 Message-ID: Subject: Re: Row pattern recognition To: Tatsuo Ishii Cc: ssam258@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="00000000000085404e064a9f4c07" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000085404e064a9f4c07 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Tatsuo, Thank you for the detailed analysis and references to the standard. However in my uderstanding the SQL standard allows A{0}. > > PATTERN (A{0} B) > is equivalant to: > PATTERN (B) > I agree. We should support A{0} to comply with the standard. > BTW, after studied this more, I found that A{0,0} is not allowed. In > this form the right hand side number shall be greater than 0. From > ISO/IEC 9075-2 7.9 "Syntax Rules 20) > > "If brace> is specified, then let VUI1 and VUI2 be the values of the first > and second 's, respectively. VUI1 shall be less than > or equal to VUI2, and VUI2 shall be greater than 0 (zero)." > Good catch. I agree we should follow the standard strictly. Since I don't have direct access to the ISO/IEC 9075-2 document, I trust your interpretation that A{0,0} should be rejected per SR 20. However, this raises interesting questions: should we optimize patterns by removing {0} quantifiers or simplifying them? And if so, how should we handle patterns that become empty after such optimization? For example: - PATTERN (A{0}) =E2=86=92 empty pattern - PATTERN (A{0} B{0}) =E2=86=92 empty pattern - PATTERN (A{0} B) =E2=86=92 PATTERN (B) after optimization Empty patterns would result in zero-length matches, which our current implementation explicitly treats as invalid (see initialAdvance flag logic in nodeWindowAgg.c). More importantly, I recall that zero-length matches caused serious issues during development, which is why we added logic to explicitly avoid them. The reason I cannot immediately provide a concrete plan for A{0} support is that I need to deeply understand the semantic meaning of zero-length matches in the SQL standard first. Without this understanding, any implementation approach could be fundamentally flawed. Specifically, I need to investigate: - What zero-length matches mean semantically in RPR - How to handle empty patterns according to the standard - The correct behavior when a pattern optimizes to nothing After the current code review phase is complete, I'm also considering setting up an Oracle test environment to observe how it handles these edge cases. This could provide valuable insights into the expected behavior, especially for zero-length matches and empty patterns. Do you have insights on how the standard handles empty patterns or zero-length matches? Best regards, Henson --00000000000085404e064a9f4c07 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Tatsuo,

Thank = you for the detailed analysis and references to the standard.

However in my uderstanding the SQL standard allows A{0}.

PATTERN (A{0} B)
is equivalant to:
PATTERN (B)

I agree. We should support = A{0} to comply with the standard.
=C2=A0
BTW, after studied this more, I found that A{0,0} is not allowed. In
this form the right hand side number shall be greater than 0. From
ISO/IEC 9075-2 7.9 <row pattern syntax> "Syntax Rules 20)

"If <left brace> <unsigned integer> <comma> <unsi= gned integer> <right
brace> is specified, then let VUI1 and VUI2 be the values of the first and second <unsigned integer>'s, respectively. VUI1 shall be less= than
or equal to VUI2, and VUI2 shall be greater than 0 (zero)."


Good catch. I agree we should foll= ow the standard strictly. Since I
don't have direct access to the IS= O/IEC 9075-2 document, I trust your
interpretation that A{0,0} should be= rejected per SR 20.

However, this raises interesting questions: sho= uld we optimize patterns
by removing {0} quantifiers or simplifying them= ? And if so, how should
we handle patterns that become empty after such = optimization?

For example:
- PATTERN (A{0}) =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0=E2=86=92 empty pattern
- PATTERN (A{0} B{0}) =C2=A0 =C2=A0= =E2=86=92 empty pattern
- PATTERN (A{0} B) =C2=A0 =C2=A0 =C2=A0 =C2=A0= =E2=86=92 PATTERN (B) after optimization

Empty patterns would result= in zero-length matches, which our current
implementation explicitly tre= ats as invalid (see initialAdvance flag
logic in nodeWindowAgg.c).
More importantly, I recall that zero-length matches caused serious
iss= ues during development, which is why we added logic to explicitly
avoid = them.

The reason I cannot immediately provide a concrete plan for A{= 0}
support is that I need to deeply understand the semantic meaning ofzero-length matches in the SQL standard first. Without this
understand= ing, any implementation approach could be fundamentally
flawed.

S= pecifically, I need to investigate:
- What zero-length matches mean sema= ntically in RPR
- How to handle empty patterns according to the standard=
- The correct behavior when a pattern optimizes to nothing

After= the current code review phase is complete, I'm also considering
set= ting up an Oracle test environment to observe how it handles these
edge = cases. This could provide valuable insights into the expected
behavior, = especially for zero-length matches and empty patterns.

Do= you have insights on how the standard handles empty patterns or
zero-le= ngth matches?

Best regards,
Henson

--00000000000085404e064a9f4c07--