nocfbot-0009-Clarify-RPR-documentation-advanced-sgml.txt
text/plain
Filename: nocfbot-0009-Clarify-RPR-documentation-advanced-sgml.txt
Type: text/plain
Part: 8
Message:
Re: Row pattern recognition
From c4943f2f4fbe264238b806e49e3ab486e15534dc Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Fri, 20 Mar 2026 20:45:20 +0900
Subject: [PATCH] Clarify RPR documentation in advanced.sgml
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Make the absorption optimization paragraph explicitly reference the
O(n²) complexity it mitigates, rather than using an ambiguous "this"
that could be misread as referring to the pattern simplification
paragraph immediately above.
Also clarify the aggregate behavior description for non-starting rows:
replace the vague "NULL or 0 depending on its aggregation definition"
with concrete examples (count() returns 0, sum() returns NULL).
---
doc/src/sgml/advanced.sgml | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/doc/src/sgml/advanced.sgml b/doc/src/sgml/advanced.sgml
index 3e696eefc66..1336f2daa14 100644
--- a/doc/src/sgml/advanced.sgml
+++ b/doc/src/sgml/advanced.sgml
@@ -585,10 +585,11 @@ DEFINE
rows which satisfies the PATTERN is found, in the starting row all columns
or functions are shown in the target list. Note that aggregations only
look into the matched rows, rather than the whole frame. On the second or
- subsequent rows all window functions are shown as NULL. Aggregates are
- NULL or 0 depending on its aggregation definition. A count() aggregate
- shows 0. For rows that do not match on the PATTERN, columns are shown AS
- NULL too. Example of a <literal>SELECT</literal> using
+ subsequent rows all window functions are shown as NULL. Aggregates on
+ non-starting rows return their initial value: for example,
+ <function>count()</function> returns 0 and <function>sum()</function>
+ returns NULL. For rows that do not match the PATTERN, columns are shown
+ as NULL too. Example of a <literal>SELECT</literal> using
the <literal>DEFINE</literal> and <literal>PATTERN</literal> clause is as
follows.
@@ -653,7 +654,8 @@ FROM stock
</para>
<para>
- To mitigate this, <productname>PostgreSQL</productname> employs
+ To mitigate the O(n<superscript>2</superscript>) complexity described
+ above, <productname>PostgreSQL</productname> also employs
a context absorption optimization. When a pattern starts with a greedy
unbounded element, newer matching contexts cannot produce longer matches
than older contexts. By detecting and eliminating these redundant
--
2.50.1 (Apple Git-155)