nocfbot-0001-DEFINE-non-volatile-baseline.txt
text/plain
Filename: nocfbot-0001-DEFINE-non-volatile-baseline.txt
Type: text/plain
Part: 0
Message:
Re: Row pattern recognition
From e29920bfc2c9beec4f0f85e8547d21e19ca23526 Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Mon, 4 May 2026 19:09:34 +0900
Subject: [PATCH 1/9] Add DEFINE non-volatile baseline to rpr_integration B9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
B9 in src/test/regress/sql/rpr_integration.sql today only exercises a
volatile callee (random()) inside DEFINE. Add a baseline query in the
same section that uses STABLE (to_char) and IMMUTABLE (length) callees,
which must remain accepted when the upcoming volatile-only prohibition
lands. This guards against the prohibition being broadened by accident
(e.g. contain_volatile_functions → contain_mutable_functions); the
volatile case alone would not catch over-rejection.
Ordered baseline-first then volatile, matching other B sections.
---
src/test/regress/expected/rpr_integration.out | 26 +++++++++++++++++++
src/test/regress/sql/rpr_integration.sql | 13 ++++++++++
2 files changed, 39 insertions(+)
diff --git a/src/test/regress/expected/rpr_integration.out b/src/test/regress/expected/rpr_integration.out
index 0cc79b75601..ef6a157f45d 100644
--- a/src/test/regress/expected/rpr_integration.out
+++ b/src/test/regress/expected/rpr_integration.out
@@ -1421,6 +1421,32 @@ DROP INDEX rpr_integ_id_idx;
-- pattern matching non-deterministic. When the prohibition lands,
-- this test must be replaced with an error-case test that expects
-- random() in DEFINE to be rejected.
+-- Baseline: STABLE (to_char) and IMMUTABLE (length) callees are accepted.
+-- This locks the boundary of the volatile-only prohibition.
+SELECT id, val, count(*) OVER w AS cnt
+FROM rpr_integ
+WINDOW w AS (ORDER BY id
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ PATTERN (A B+)
+ DEFINE B AS val > PREV(val)
+ AND length('x') = 1
+ AND to_char(date '2026-01-01', 'YYYY') = '2026')
+ORDER BY id;
+ id | val | cnt
+----+-----+-----
+ 1 | 10 | 2
+ 2 | 20 | 0
+ 3 | 15 | 2
+ 4 | 25 | 0
+ 5 | 5 | 3
+ 6 | 30 | 0
+ 7 | 35 | 0
+ 8 | 20 | 3
+ 9 | 40 | 0
+ 10 | 45 | 0
+(10 rows)
+
+-- Volatile (random) is the prohibition target; today still accepted.
SELECT id, val, count(*) OVER w AS cnt
FROM rpr_integ
WINDOW w AS (ORDER BY id
diff --git a/src/test/regress/sql/rpr_integration.sql b/src/test/regress/sql/rpr_integration.sql
index 6d47728e911..d9748979d54 100644
--- a/src/test/regress/sql/rpr_integration.sql
+++ b/src/test/regress/sql/rpr_integration.sql
@@ -884,6 +884,19 @@ DROP INDEX rpr_integ_id_idx;
-- this test must be replaced with an error-case test that expects
-- random() in DEFINE to be rejected.
+-- Baseline: STABLE (to_char) and IMMUTABLE (length) callees are accepted.
+-- This locks the boundary of the volatile-only prohibition.
+SELECT id, val, count(*) OVER w AS cnt
+FROM rpr_integ
+WINDOW w AS (ORDER BY id
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ PATTERN (A B+)
+ DEFINE B AS val > PREV(val)
+ AND length('x') = 1
+ AND to_char(date '2026-01-01', 'YYYY') = '2026')
+ORDER BY id;
+
+-- Volatile (random) is the prohibition target; today still accepted.
SELECT id, val, count(*) OVER w AS cnt
FROM rpr_integ
WINDOW w AS (ORDER BY id
--
2.50.1 (Apple Git-155)