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 1vy08d-00HKut-1h for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2026 04:16:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vy08b-00FpoS-30 for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2026 04:16:38 +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 1vy08b-00FpoJ-1h for pgsql-hackers@lists.postgresql.org; Thu, 05 Mar 2026 04:16:38 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vy08a-00000000TmZ-0WCW for pgsql-hackers@postgresql.org; Thu, 05 Mar 2026 04:16:37 +0000 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-c7381c4345cso450890a12.1 for ; Wed, 04 Mar 2026 20:16:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772684194; cv=none; d=google.com; s=arc-20240605; b=Ps3UTJPw3G5KXRiNezclgfmnzFLyUVBEcKJf7y9Sjwyv3JGv3t/+e67bEb8VUscBYg yb20uo7J11MtUqHRyZwjVFTZjT6X9HPtOgAly/NPLMWTiujv4C2n0ilCLeLMGxNX0wQX n07L7g0DDFNZvUUVB5MUceAlebinHrslvS3MxJKQvNMsbQBsm+DTYECFd9OiWrNGH2tY iIdMAgIMpWm+Imvne52S95Ncy6jlUmhmnAiS1Bsj+V0qrUE7Mk7yhTufF5uNPcXxQj2T Ws6BMSOQ/zAYwEu3VnaYtEyT35a0K+U9oVgNZeRMSX9fGf6exH/GU5oPeVA/i3Ed6N7Z 7HYQ== 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:in-reply-to:references :mime-version:dkim-signature; bh=/BeWCrsxBqSHClnMou7fEmRJFOv+tij2R+zIG49HVRY=; fh=Ah4v6hNXzYom7Vm62xHWwA/HnMqMpa9LxYMPPmUO/cU=; b=JtrLS7BbaaRyOtQH2gmV7cQLlzfdlYCaIhmgLcgDbum4bOEPyi1/sreye7FeZtqvf6 HHPazh5YNsTWSJIxwGhti2mHddJVLeEDdWQE+3pr7dLbr8kmyho9t33qX4T7UMj8ee4u febpA5WcEY4KWH99im70RpCM3hbeYsH3mLx95h1IknZ+MZ2cOZ8+CtTxB3XVEnGl5UR8 qSicCg/n+EATl3+gFTqLm873w5fioi/mjvJoXr3Hw1FQeuT2LwsOIfFNR+cEIY//TOi2 h98a0wct5/oGoc8/qHkxOwcQi6SwuIkvBbjrzGf7A+Krf/JqZ8KJTaTBcAht8OPN/iBs 7Z6g==; 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=1772684194; x=1773288994; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/BeWCrsxBqSHClnMou7fEmRJFOv+tij2R+zIG49HVRY=; b=MmWslAbyehRvbwJfRzFxbYmzXaKDsSdyAH/4agXKQ4u+Iictwdo8JSzEoyxNu5dB6j QknUmK2A1MgjCcW/rEZUbvJVKZo92BDXJsW9KxvNudnv7oniKvzTDemgQAyrzUfR0FJr e281Q5HJwg0QweSVJ2s55QjbV7SVTdlNTil6nCSZQtwkB1V28KBh3MwBdV06yafiwoPo csb8w5pA72+FH2yKgTf8NJ8c29dyd4tXYrupmizwXLJpSZk94KnIj9ka2r07wg6abtLB lVTMkkIV1qUooQQT5AmZYxPU5+wO9FTOL9dgjo1Lj6Ycf8XC+4zaMIiLIIjH+dgdTtZt nWaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772684194; x=1773288994; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/BeWCrsxBqSHClnMou7fEmRJFOv+tij2R+zIG49HVRY=; b=Hjo4E32GXf8hvYLg+GOEHE4DsJf8kfkMqXhA7/3oWT+QURyQepdUcKQune/J7Z3jH/ GdyVenBXZei791hphY4wfJg+w1J008XJ2LCaMhzQMpckOUd+34ZDO7fOEPzFAK4l5Lds h1cyJkPNK2VvFGp7kH+iU0U9594HxG1q5RY9zOKHgLogvKfIcKaWVHKVbPsosnSY6uhU 5bKmzfIxbj3SUbGMc85YJePJb2HukJV3pmVxaf61AgZrreCkktvvLvqlIHmIiK4BQcr+ ZqBorHv7v6nCUfdV3rizdkY/2JPIQotCaba872p/C1CAVbAJWOfgKXxGerwLdcsjoXRu u7Zg== X-Forwarded-Encrypted: i=1; AJvYcCUppjIJepZ+4gGUfyrM/OsrtiEyUAWn/Dlkp5F2AEsqpD7eEPGadEU8dJrPEmVA+WNymvBzUVmf2wH8FFzV@postgresql.org X-Gm-Message-State: AOJu0YwYXTpeqp56RquSo5xPN9mwx+uUnHv0HPfTdinfjHXlAMVGL3/8 fLgmYIO05Oxq4Xsla2FOfXBK0+WBwSZ8NuYB5AsUGk+c2HNZbu8AnTdad06OGJiSkh50juVsnWb J73gUaGd6aSnNDCBctZMTuGwg3XpIxJk= X-Gm-Gg: ATEYQzyA25odTFiSrlnzQMMDp+50xgbpxVsbFc0ZEPztP3hNLe82o7R3oeEw27wWh4R B6HSqpF5nmCz/Z8g3EXcSxOYws1FykMjNNiBNDE/GgfV7DAE1m481dgT6bifRqMsmPvmoVg5R38 SUBw79+k9S/vvmVJF1Hne93h7Bg9XdKqAX4WNlPpnOsxeDyl/GrPCEESKcwbD2lP1hYaj52jVlp vZgEb3/sT9AZLUS4N0l6tnNxbRpyNJhhBm/bRYHfA5SbjU+v9dGWC73Apm23uu400sA4wQDw0yB 0Fy6DJnt X-Received: by 2002:a17:90b:4b86:b0:359:8c5a:a564 with SMTP id 98e67ed59e1d1-359b1beeac4mr892723a91.13.1772684193965; Wed, 04 Mar 2026 20:16:33 -0800 (PST) MIME-Version: 1.0 References: <20260302.141823.129040280886273031.ishii@postgresql.org> <20260304.162450.1463961082114305353.ishii@postgresql.org> <20260304.171203.445020956605509539.ishii@postgresql.org> In-Reply-To: <20260304.171203.445020956605509539.ishii@postgresql.org> From: =?UTF-8?B?7J6l7ISx7KSA?= Date: Thu, 5 Mar 2026 13:16:21 +0900 X-Gm-Features: AaiRm52-gpha7RZG89kBGITGPZKvb-KSB50YoVQpMrzfKBa81KXjrUuM3KKrD4U Message-ID: Subject: Re: Row pattern recognition To: Tatsuo Ishii , assam258@gmail.com Cc: 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="000000000000ae2ba1064c3f337e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ae2ba1064c3f337e Content-Type: text/plain; charset="UTF-8" Hi hackers I converted PostgreSQL RPR regression test queries to Oracle MATCH_RECOGNIZE syntax and executed them on both systems to perform cross-validation. The tests were based on the following PostgreSQL regression test files: rpr_base.sql rpr_nfa.sql PostgreSQL bug: zero-min reluctant quantifier During cross-validation a PostgreSQL bug was discovered involving reluctant quantifiers whose minimum repetition is 0. Example pattern: PATTERN (A*?) DEFINE A AS val > 0 Result comparison: pattern PostgreSQL (cnt) Oracle (cnt) A*? 1,1,1 0,0,0 A?? 1,1,1 0,0,0 A+? 1,1,1 1,1,1 For reluctant quantifiers with min=0 (such as *? and ??), PostgreSQL always consumes at least one row, while Oracle allows a zero-length match. When min>=1 (e.g., A+?), both systems behave the same. This behavior was consistently observed across the converted tests. Design difference: unused DEFINE variables Example: PATTERN (A+) DEFINE A AS id > 0, B AS id > 5 PostgreSQL executes the query successfully and ignores the unused variable B. Oracle raises: ORA-62503: illegal variable definition Oracle limitations observed Bounded quantifier limit A{200} -> works A{201} -> ORA-62518 Oracle appears to limit the upper bound of bounded quantifiers to 200, while PostgreSQL does not impose this restriction. Nested nullable quantifiers Examples: (A*)* (A*)+ (((A)*)*)* (A?|B){1,2} ((A?){2,3}){2,3} (A?){n,m} (A? B?){2,3} Oracle raises: ORA-62513 when a nullable subpattern is wrapped by an outer quantifier, while PostgreSQL executes these patterns successfully. These results come from running the converted PostgreSQL RPR regression tests on Oracle for comparison. Best regards, SugJun --000000000000ae2ba1064c3f337e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi hackers

I converted PostgreSQL RPR regression te= st queries to Oracle
MATCH_RECOGNIZE syntax and executed them on both sy= stems to perform
cross-validation.

The tests were based on the fo= llowing PostgreSQL regression test files:

=C2=A0 rpr_base.sql
=C2= =A0 rpr_nfa.sql


PostgreSQL bug: zero-min reluctant quantifier
During cross-validation a PostgreSQL bug was discovered involving
r= eluctant quantifiers whose minimum repetition is 0.

Example pattern:=

=C2=A0 PATTERN (A*?)
=C2=A0 DEFINE A AS val > 0

Result= comparison:

pattern =C2=A0 PostgreSQL (cnt) =C2=A0 Oracle (cnt)
= A*? =C2=A0 =C2=A0 =C2=A0 1,1,1 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A00,0,0
A?? =C2=A0 =C2=A0 =C2=A0 1,1,1 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A00,0,0
A+? =C2=A0 =C2=A0 =C2=A0 1,1,1 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A01,1,1

For reluctant quantifiers wi= th min=3D0 (such as *? and ??), PostgreSQL
always consumes at least one = row, while Oracle allows a zero-length
match. When min>=3D1 (e.g., A+= ?), both systems behave the same.

This behavior was consistently obs= erved across the converted tests.


Design difference: unused DEFI= NE variables

Example:

=C2=A0 PATTERN (A+)
=C2=A0 DEFINE A = AS id > 0, B AS id > 5

PostgreSQL executes the query successfu= lly and ignores the unused
variable B.

Oracle raises:

=C2= =A0 ORA-62503: illegal variable definition


Oracle limitations ob= served


Bounded quantifier limit

A{200} =C2=A0-> works<= br>A{201} =C2=A0-> ORA-62518

Oracle appears to limit the upper bo= und of bounded quantifiers to 200,
while PostgreSQL does not impose this= restriction.


Nested nullable quantifiers

Examples:
=C2=A0 (A*)*
=C2=A0 (A*)+
=C2=A0 (((A)*)*)*

=C2=A0 (A?|B){1,= 2}
=C2=A0 ((A?){2,3}){2,3}
=C2=A0 (A?){n,m}
=C2=A0 (A? B?){2,3}
Oracle raises:

=C2=A0 ORA-62513

when a nullable subpatte= rn is wrapped by an outer quantifier, while
PostgreSQL executes these pa= tterns successfully.


These results come from running the convert= ed PostgreSQL RPR regression
tests on Oracle for comparison.

Best= regards,
SugJun
--000000000000ae2ba1064c3f337e--