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 1wa7V2-001Xpc-2r for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jun 2026 07:49:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wa7V0-00AM2r-1F for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jun 2026 07:49:18 +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 1wa7V0-00AM2h-09 for pgsql-hackers@lists.postgresql.org; Thu, 18 Jun 2026 07:49:18 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wa7Ut-000000013b6-0Qdu for pgsql-hackers@postgresql.org; Thu, 18 Jun 2026 07:49:12 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-c074142cf6dso104320566b.0 for ; Thu, 18 Jun 2026 00:49:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781768949; cv=none; d=google.com; s=arc-20240605; b=TzD7dwwctjNnAzrTI3swHMXcRfuwZVB8LyXVMzV32Oxq5HGhHe5jDwU2W1LF7pZ/C5 ShtCi2jvoae4xZCZMfXQrSDADvXOBKOz98XpkBnVxT5PlXyqp2kAXwZ+RW2+8S6pz31S I5dnHC/zBhaI1TyH8xKxyLX6ftCcAka1G+ydZDw2ggnJdXxLHjXdKzZW91Q1Ee0LrY6c czHj+fK64iA1Zk7VkiR5J9WJaDz8GAOhLqA8zEqz2d+Ljn5/uGkpb8jU5eCZtsiVyICg MlK2okTr6qmIOGlIKqj7MYeMC0A/xdVQNPiHrKCSFSIX2YElSNr+Fl/VjdRU9BEGeB04 tl+A== 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=F46+p9GJKjkxizhnQZsCxfF+FWhcFhtJUHuKOrV2ZOo=; fh=tuKSgirjMXOdiBgNmxRGanSGXXGcT43BCisOUYRspWE=; b=fTUxbkYpH2rZn/T4DuRkW9BioeFyQvx6zAoTVjcflX6/bb06usbGRq3dsjtiv+ntHs J9rarVpD2nKLrAWQG3ISquGeDr+V1H08s8YZmUkwaVoyEiVPfmxGvd7i8i4y5D5U3Kq9 8DH7IZOzHGOWdpXfMXJtKer8lEb518ibLxLS6bfxAulHlB76qWd2bFTxqQOWADZ00HOh /LHwfTwrrUzM/dVKGmL3q/gzPFbaE/DxkPmyGbZt2PiPlvuSiVZoKvf5PBZqOn5uS+8M Iuv+5fOAoFVx8Oc0VJ7yg+pl7FH/xBvBygr42J9MFifn7jJyXpTFejBAsSFQsu4GdCQ5 I4fQ==; 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=1781768949; x=1782373749; 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=F46+p9GJKjkxizhnQZsCxfF+FWhcFhtJUHuKOrV2ZOo=; b=RSKXxJQRq6btin2vsGKcP6qMq9dehRQe/dT0Hv+p1xKqf6VwTBW76mg1eP93g/Mwct k3rK3UukwDbIswmhAXEcCqaY2QlZf+bRBUltgC6LMLUjnbzh0kGsh7xSztBCydFo926M fBofeglnpTSEBHLki3YE3T/2DndN5RhKVoMSdXJfpdGo8cvURjwgvvUrRkMpmOwg1Ag+ 6G/bcBo7RZ5nWHXnsD3yX3uB5e8taLxFIok8dzAg+uxA1+/HeK/oJ0SeuSKDmhtDQ0I/ Gu3TeQVmUmJKOd5UwuJCJ708pQ1QkIXh3O5RtzlcrjGvNPZ1gJFKImhT5T1budejiam9 h3Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781768949; x=1782373749; 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=F46+p9GJKjkxizhnQZsCxfF+FWhcFhtJUHuKOrV2ZOo=; b=W6zGmHUMhB6Ohle8xD1v0hR9mx58PcDbqVSfC39VYCu4YXUfKDpiq120HFclxxz/VD pHaTeBO1mB+mOV3e75OrXxMDzY6Cj9M9wluPlMuexGQZJqNPCTPY8q/civw6Q3xRdael tRgO9x9gz0amtD0t/WF2uckKt07xCMHtgM/GJeUa8YmTz08GgUcUTQxYKBWUnpio3oKv DqP1BKI3Y5nNTk38POO7SHArXE0aIFMdLowiuHipwIwTTJ+dtsQnanKDwcR7oezwcuAX UfvhwK9aJggvdXYqZ0Ofayc2NB2qgtB5vCYqqcrSAza70JOfmx8McfYjo5YAOTr/Viwj 838Q== X-Forwarded-Encrypted: i=1; AFNElJ/a4OFJ9beKt2yrSXnuFATOslvBdjS3kwK8jD0dpVi/+F3bIHIaYLuZg3Yc+QQ2Qf5jolm1o8D/QSu5k/0u@postgresql.org X-Gm-Message-State: AOJu0YxjRIQ9wM0sYr90dfAuoP+vk2s4d/V+/FiA480UQ0rOHPTro4Kf Xp7VVaIzNlGeVVwLUPPc5lJl6ra3Vm/Vb/Kfta2JoGcs2RhLLRjDKpYtyUpN0zfHVlvOIZUG6fA cYsKOPhkbO+wCxFz3/mvGwVgn7+iaXpQ= X-Gm-Gg: AfdE7ckoTcBLKHTOilESOrHrMCkCwmIHT3d4w863feCySifmqMsTA751pIv+4qdQM5s 2bQPuXnUeCpDGpWdPqarSc4hMRl9VGVTkfOlKdJ3sVC0IOVlUmtf+eWpqkE1p6CSwDdsXgxDIL/ aSfYY05h+9VHiIsvUUYuDc8pYtSYCUcCNcFYU5ageFhDmcWFYxuCez5m9r3murai66CLhbSrJO8 77nmA5/hL+DrqeGjzfUzfFxILleK1zbJ0BQndKnFRRx5Yl9D/yGnLUAgjG0TqZN9eoB5PqMUMzC MiXYEJ7eaqc9Fs+ZP687HSbmzfcaCkRsstZyzg1j78DH54bl+i4i30SmXEoBvFr30NnMQafG5mg +YCjyUsVEzw== X-Received: by 2002:a17:907:9d1a:b0:bee:723b:6a0 with SMTP id a640c23a62f3a-c073231831fmr142470466b.9.1781768948599; Thu, 18 Jun 2026 00:49:08 -0700 (PDT) MIME-Version: 1.0 References: <20260604.132108.405136284364833955.ishii@postgresql.org> <20260609.171307.1883356507067957349.ishii@postgresql.org> In-Reply-To: Reply-To: assam258@gmail.com From: Henson Choi Date: Thu, 18 Jun 2026 16:48:54 +0900 X-Gm-Features: AVVi8CePdJCBiLKrk80k92LnZxa8hiltTFkhnXpsI20nRxLrALWYLoJbdQVZbJ4 Message-ID: Subject: Re: Row pattern recognition To: jian he , Tatsuo Ishii Cc: 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, pgsql-hackers@postgresql.org Content-Type: multipart/alternative; boundary="00000000000040eda70654826954" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000040eda70654826954 Content-Type: text/plain; charset="UTF-8" Hi Jian, Thanks for the misc-refactoring patch (v48-0001-v48-misc-refactoring) and the whole-row Var note. As before, now that v48 is posted I'll rebase on it and send these as incremental patches on top (v49); per-item disposition below, with the per-commit breakdown to come with the patch. > RPRNavExpr->resulttype should also marked as pg_node_attr(query_jumble_ignore) Agreed -- every other derived result-type field in primnodes.h already carries it, and resulttype is derived from the (jumbled) arg type, so ignoring it loses nothing. I'll add it. > collectPatternVariables is not needed. > The parser already ensures every DEFINE variable appears in PATTERN ... > See nfa_evaluate_row the for loop break. Confirmed -- the parser already rejects a DEFINE variable not used in PATTERN, so every DEFINE var is in PATTERN; filtering is redundant and cost_windowagg can iterate defineClause directly, so I'll remove it. > buildDefineVariableList is trivial. No need to export it as an external function. Agreed -- I'll drop it and inline the list-building into create_windowagg_plan(). > Rename WindowAggState.defineClauseList to defineClauseExprs Agreed (the elements are ExprState, so it matches the ...Exprs convention) -- I'll do it, including the additional site the dormant-match fix touches. > Flatten a needlessly nested block in show_window_def(). > Replace a post-loop ListCell NULL check in remove_unused_subquery_outputs() > with a boolean flag. > Reduce the number of arguments in make_windowagg. > Minor refactoring of regress test comments. I'll do all of these. One exception: the parsenodes.h RPRPatternNode comment names the data structure, so rather than "clause" I'll change it to "parse tree node". > dvar, var both can be whole-row Vars, but this seems to work for whole-row vars. > We need some simple regress tests for cases where both are whole-row vars or one > of them is a whole-row var. Good catch -- I'll add regress coverage for the whole-row Var cases (both sides whole-row, and one side whole-row) in the needed_by_define check, in v49. I'll send the items above as a first incremental patch on top of v48, and take up the later reviews after that. Thanks, Henson --00000000000040eda70654826954 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Jian,

Thanks for the misc-refactoring patch (v48= -0001-v48-misc-refactoring) and the
whole-row Var note.=C2=A0 As before,= now that v48 is posted I'll rebase on it and send
these as incremen= tal patches on top (v49); per-item disposition below, with the
per-commi= t breakdown to come with the patch.


> RPRNavExpr->resultty= pe should also marked as pg_node_attr(query_jumble_ignore)

Agreed --= every other derived result-type field in primnodes.h already carries it,and resulttype is derived from the (jumbled) arg type, so ignoring it los= es nothing.
I'll add it.


> collectPatternVariables is = not needed.
> The parser already ensures every DEFINE variable appear= s in PATTERN ...
> See nfa_evaluate_row the for loop break.

Co= nfirmed -- the parser already rejects a DEFINE variable not used in PATTERN= , so
every DEFINE var is in PATTERN; filtering is redundant and cost_win= dowagg can
iterate defineClause directly, so I'll remove it.

=
> buildDefineVariableList is trivial. No need to export it as an ext= ernal function.

Agreed -- I'll drop it and inline the list-build= ing into create_windowagg_plan().


> Rename WindowAggState.def= ineClauseList to defineClauseExprs

Agreed (the elements are ExprStat= e, so it matches the ...Exprs convention) -- I'll
do it, including t= he additional site the dormant-match fix touches.


> Flatten a= needlessly nested block in show_window_def().
> Replace a post-loop = ListCell NULL check in remove_unused_subquery_outputs()
> with a bool= ean flag.
> Reduce the number of arguments in make_windowagg.
>= Minor refactoring of regress test comments.

I'll do all of thes= e.

One exception: the parsenodes.h RPRPatternNode comment names the = data structure, so
rather than "clause" I'll change it to = "parse tree node".


> dvar, var both can be whole-ro= w Vars, but this seems to work for whole-row vars.
> We need some sim= ple regress tests for cases where both are whole-row vars or one
> of= them is a whole-row var.

Good catch -- I'll add regress coverag= e for the whole-row Var cases (both sides
whole-row, and one side whole-= row) in the needed_by_define check, in v49.

I'll send the items = above as a first incremental patch on top of v48, and take up
the later = reviews after that.


Thanks,
Henson
--00000000000040eda70654826954--