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 1wf5DZ-005Fc9-15 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jul 2026 00:23:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wf5DW-00GH84-2v for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jul 2026 00:23:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wf5DW-00GH7w-1r for pgsql-hackers@lists.postgresql.org; Thu, 02 Jul 2026 00:23:46 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wf5DU-00000001Hwq-0hAf for pgsql-hackers@postgresql.org; Thu, 02 Jul 2026 00:23:45 +0000 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-6989c0ec3c5so2131006a12.2 for ; Wed, 01 Jul 2026 17:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782951823; cv=none; d=google.com; s=arc-20260327; b=mjwHUh/7ERgaoI4Udw1sqYDcWVriiVeyzuIRbaszwtYj/UuvBodfFL47vdrTlrUxC3 8MyF3oQs9DW52yHCZKy7lIoB5LZ8QuL3icJDRdw+Pqaft0RMNmtAArnMUGlGoVKmJGUx tF4nfrvWleon3CStuwy8PdX2xB77FzVnCqeLUmb2l3ZyInw79SiUGd1Ok0ijyqXZm3Kj yrQoyE0vHNaj/CLWVfY2v1fWT2i3WwTw0DNeZPRYL3twFIuTVVyzHxbql1qs/BT3mY3q 7Gtj/Sh5O1aRHh+FTsSq933dngxXE9XCWRsmKIxN7+dFZ2s+n187b+NF9GaVGlQcaX8Z +O/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:dkim-signature; bh=g6dBDhxqVfGi8iI0rmcMdHkwYVXOPRWsP6mP2IfAr/4=; fh=03zUsQOOKaS+o6EgVNVzZkkI4ctqciAz4zndCwV/H9E=; b=BrxNf9vfA3NEwXXyFz+pksAaZg37rCj2YI14BSD9uH/sCXOw6AfNRJbFw149mSyRau qxmMhpNJNkqEn1XO6lBD6Z2MXHdcorFCN7ohmmiOGungvRxcHM48zOawwGg1uSA1OGyq n3XYjEyaXQRgbyijnUPFeJxlHxd0zvEAv8HBZdlDhllE4VsuCRw53kXJVKUfTRiKw96G t32SpPlvmtgknjY7Sihol02jmlgMXwZZMOazeWJuKryJMAwTOqIXlD/dBNzCTBmA/V7P qsl9D4RFIeR7ZcfZgD649ITM787ElX0NL8E++wZLopfm+V5zt/0RU1ojwga7QzucEMXb ZtNg==; 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=20251104; t=1782951823; x=1783556623; 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=g6dBDhxqVfGi8iI0rmcMdHkwYVXOPRWsP6mP2IfAr/4=; b=cfgNt1wUeoCi9a7J/8zRDTdUSvU5TvVk7AL75mJjK7jD3RabhxYJ8JexLwEtyW6Phh hfx/Z/bbJyky4XeocQkMCBvrssR9fdAd2joNyzkaBuDeV4uEUBPilCgmypkDljMv8KKT +X6033XDvqGOenwQ4famfh9Yv1lCks6WN+H8iD1BpPDYA5NOw9oDuceJg4tqw81MbrKB OU/V+ujecBk20mE64poJEiJE7ts7n4q9990VTTlTvgnz+6j/4sNDN/dgQPtkfuBfK9HX F26RcDkSa/ytOLY4zzT82CCwyA9EwKh2DVJlzj/F/rTEmzXGcGeZ3zrEglo7d1BZH/nn ML5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782951823; x=1783556623; 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=g6dBDhxqVfGi8iI0rmcMdHkwYVXOPRWsP6mP2IfAr/4=; b=P6uuOMrYVhBBPdmNXYWgPBmneyJim5gDvJNqT242W3dMeECCv/7BYJTTx/a5zeINhz /Z0Q5l869N2q2Fl7n696qKmnAVek2aISr7D6V2ydfJEOCa37DStm8RjJRKcvA1iQUFMI GUKoFt6Oz6RDyrZhAnjin7kAdZWO3wOPrNC5AfSLlDcg2U/MJXRrsJg3YHqVu7eQfigc aMq/5JTpElIt1ctGhCYeCSHrPyMIsLP5hedgKYviJicRAx+kcU1usQ/QhKPchNkufjFJ QxHHyKMRdGhzxCJtzOJ9jVGn0ofl6pzEh40jxJgb6fro6couODCjfouz0RGFaZRbE8jP Q09Q== X-Forwarded-Encrypted: i=1; AFNElJ/nicBocPiIBtkIcfpg7zJan9mqbtyIkUQllQCknXdErEdtwr4Dz+ZoXDAfILxJV0jUUqFNQHfmKjHNiwQw@postgresql.org X-Gm-Message-State: AOJu0YxSI3U/Nj7l9Y6P1IlNJ9YT46puLL5hfk4YBcXMs8GbCcCe1ETP Q7WWqMLaCvomQ+ItsXuDRkMx1oSIHZvt4az8OwxskagvElE35GlHGCybPKbSOaKtIa0ydvtKJ31 b35BXCZaZPI0hC1U1LiA3k7CuZX1tGb8= X-Gm-Gg: AfdE7cm3z9lzUms/EVn9KNDpNmj+osGdaUsdg7tOIlLdRNI6zzFYmYw17N1goIgSzqu n8ItYBwhMQgf5isLWp3vhhGJQsPgwnKkTmS5vbWvRW2IhzV6rb1yZn25ucvS3UEdSNdtAQTEuat PlZAf/5zuuoRPKvky+wiLizt5LEVK4ib6HGzLviLEKKsqnrjL5nCsygDRbKjcux449Asuljt+tn rJZghkKLBQ/JHvVWPcr0OKsu0Llu/bA7vs4yM4N6MCXjqWJYwVWzLtUXrIiW/FhZVd3iwK9gTzx 5KG9KwBs+lEaoA7sJGWq98vcwpjsCYJIGZ5Qkm1a1WICggmFgf736/0TkBKnVcWvcLrD3wjP5+6 tModYVeIDOg== X-Received: by 2002:a17:906:934a:b0:c12:701b:e531 with SMTP id a640c23a62f3a-c12aa140da1mr127365166b.36.1782951822664; Wed, 01 Jul 2026 17:23:42 -0700 (PDT) MIME-Version: 1.0 References: <20260622.215536.1729984032454200237.ishii@postgresql.org> <20260629.183730.1799088184925453299.ishii@postgresql.org> In-Reply-To: Reply-To: assam258@gmail.com From: Henson Choi Date: Thu, 2 Jul 2026 09:23:28 +0900 X-Gm-Features: AVVi8CdiEiBV9y6Hqym5MPn4AuLBI8g1mxRyBkr7dxwkNfvZyJuUsLKhe0VfoUc Message-ID: Subject: Re: Row pattern recognition To: jian.universality@gmail.com Cc: ishii@postgresql.org, pgsql-hackers@postgresql.org, zsolt.parragi@percona.com, sjjang112233@gmail.com, vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, li.evan.chao@gmail.com Content-Type: multipart/alternative; boundary="0000000000000aa767065595d230" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000aa767065595d230 Content-Type: text/plain; charset="UTF-8" Hi Jian, Thanks for the review, and for basing it on the RPR branch. Responses inline. > ``(only possible during early development/testing).`` comment is not necessary? Agreed, and it is actually misleading: varMatched == NULL is a live signal, not a dev-only artifact. nfa_match() is called with NULL to force every VAR to not-match at a frame boundary (execRPR.c, "Frame boundary reached: force mismatch"). I will rewrite the comment to describe that meaning instead of the "early development/testing" note. > nfa_match desperately needs an extra i(nt64 currentPos) argument. [...] > adding currentPos makes it much easier to understand the current > execution state when debugging with GDB. Makes sense -- nfa_match() has only the state list in scope, no row index, which is exactly the thing that is hard to place in GDB. I will thread currentPos through. > The comments above in nfa_match are unnecessary because in ``if > (RPRElemIsAbsorbableBranch(elem)`` we already have many comments, and > the meaning seems the same. Agreed -- the loop-top overview's second sentence restates the inline END-chain block. I will drop it and keep "Evaluate VAR elements against current row" as a one-line lead. > Similar to REG_DEBUG, we really need an RPR_DEBUG option. [...] verify > that ctx->states is not a circular linked list [...] without affecting > release builds. Fair point, and there is some history: RPR_DEBUG did exist earlier as debug logging, and I am the one who proposed removing it. My reason was narrow, though. I lean on the debugger, and with AI assistance the cost of inserting, watching, and then removing ad-hoc logs has dropped sharply -- so I treated those logs as ephemeral and optimized for a clean committed tree rather than for someone reading execRPR.c cold. For a new contributor that trade-off is the wrong one, and you have convinced me: a retained set of observation points, plus the Assert-style sanity checks you describe (non-circular state list, count and context-ordering invariants), would genuinely lower the barrier to this code. So I agree with the direction. Rather than settle on a shape now, I would leave it open: which observation points and checks are actually worth retaining behind #ifdef RPR_DEBUG can be picked out later as a separate follow-up, and it is really Tatsuo's call since he suggested the first version. > The SQL standard defines more subclauses: MEASURES and SUBSET > [...] more variations in AFTER MATCH clause. > This part should stay in the Compatibility section. Agreed. It is a standard-deviation note, and the SELECT Compatibility section currently has no row-pattern text, so I will move this paragraph there. Unless Tatsuo has a different view by the weekend, I will proceed with the concrete changes above, leaving the RPR_DEBUG shape open as noted. Best regards, Henson --0000000000000aa767065595d230 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Jian,

Thanks for the review, and for basing it on the RPR branc= h. Responses
inline.

> ``(only possible during early developme= nt/testing).`` comment is not necessary?

Agreed, and it is actually = misleading: varMatched =3D=3D NULL is a live
signal, not a dev-only arti= fact. nfa_match() is called with NULL to force
every VAR to not-match at= a frame boundary (execRPR.c, "Frame boundary
reached: force mismat= ch"). I will rewrite the comment to describe that
meaning instead o= f the "early development/testing" note.

> nfa_match des= perately needs an extra i(nt64 currentPos) argument. [...]
> adding c= urrentPos makes it much easier to understand the current
> execution = state when debugging with GDB.

Makes sense -- nfa_match() has only t= he state list in scope, no row
index, which is exactly the thing that is= hard to place in GDB. I will
thread currentPos through.

> The= comments above in nfa_match are unnecessary because in ``if
> (RPREl= emIsAbsorbableBranch(elem)`` we already have many comments, and
> the= meaning seems the same.

Agreed -- the loop-top overview's secon= d sentence restates the inline
END-chain block. I will drop it and keep = "Evaluate VAR elements against
current row" as a one-line lead= .

> Similar to REG_DEBUG, we really need an RPR_DEBUG option. [..= .] verify
> that ctx->states is not a circular linked list [...] w= ithout affecting
> release builds.

Fair point, and there is so= me history: RPR_DEBUG did exist earlier as
debug logging, and I am the o= ne who proposed removing it. My reason was
narrow, though. I lean on the= debugger, and with AI assistance the cost of
inserting, watching, and t= hen removing ad-hoc logs has dropped sharply --
so I treated those logs = as ephemeral and optimized for a clean committed
tree rather than for so= meone reading execRPR.c cold.

For a new contributor that trade-off i= s the wrong one, and you have
convinced me: a retained set of observatio= n points, plus the Assert-style
sanity checks you describe (non-circular= state list, count and
context-ordering invariants), would genuinely low= er the barrier to this
code. So I agree with the direction. Rather than = settle on a shape now, I
would leave it open: which observation points a= nd checks are actually
worth retaining behind #ifdef RPR_DEBUG can be pi= cked out later as a
separate follow-up, and it is really Tatsuo's ca= ll since he suggested the
first version.

> <para> The SQ= L standard defines more subclauses: MEASURES and SUBSET
> [...] more = variations in AFTER MATCH clause. </para>
> This part should st= ay in the Compatibility section.

Agreed. It is a standard-deviation = note, and the SELECT Compatibility
section currently has no row-pattern = text, so I will move this paragraph
there.

Unless Tatsuo has a di= fferent view by the weekend, I will proceed with the
concrete changes ab= ove, leaving the RPR_DEBUG shape open as noted.

Best regards,
Hen= son

--0000000000000aa767065595d230--