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 1wTrHE-000nLv-0R for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jun 2026 01:17:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wTrHC-008HuN-1B for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jun 2026 01:17:10 +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 1wTrHC-008HuF-08 for pgsql-hackers@lists.postgresql.org; Mon, 01 Jun 2026 01:17:10 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wTrHA-00000000ZFW-0LFY for pgsql-hackers@postgresql.org; Mon, 01 Jun 2026 01:17:09 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-68d2342c5e6so1073314a12.3 for ; Sun, 31 May 2026 18:17:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780276626; cv=none; d=google.com; s=arc-20240605; b=hz5IAbxcXGMt+6n/KUFKeojdCxnfOugRKGU/etViGvS7YD7mEzoIFv3FGF29gzW00C VAV2KJ+fnA78Tn8730JPrykJM+sRN3TgwNrzkhtbIJPZNVW2umFfplGt+q8zW0AiQz7t kNNOBkFwrKA7EWRrKGZUH48fc+6I3AtpNbivcq28KEzjBaNQuNheXDnIHQfMUEn/mmQj PttP1zKmJWK3X0I85YeMgKawSIUKvUYuBXDlqLvHudo8Vff6QHSEOYE77PTf2yNgsRLf 1ygj07+OUly1uecNjbpfmZ6g28YQJYxvDSj5OyvZtrYY+9oQT2nMglw59G4v78OP18xB 6nnA== 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=mwLMWrmbR91BhNPmlLHfTLHqptHAl2wGREaSGS+VQ4o=; fh=VxFeL+z+nGECutueOr/5Oi9LXhs+Q1lruP1AN4sCxPo=; b=L9Nm4toUGjsptpmGh5mjYksWeQlOv/nPtIyKK9h/q3yp//ZGMgsQst42dWOEAblbmF vwBoIl6aN3gepAIr7tRa3ZD8AtV026DRBIoPg8Sgi6En59yAOnUDEkBmRanQYD9JYtvt RE4KGFKLJqTTwA+8rSIXQmbiYoibY018AvxKC4NBIJaq8DqvO6jztfooQqaYmzqkGVec RmJKIXnFnCNzGQHONPWp1ESI9vfpkrV/K61W7/g3y6r4EVXEBUYTV9kvoDwUb6eJFqbi lT1BuPPyseyysZ/8ZwkazNGacwc1DoskaQJxVkyA4mmEGhQlDbQBVAW6BFEMpYrvhxGf oqoA==; 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=1780276626; x=1780881426; 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=mwLMWrmbR91BhNPmlLHfTLHqptHAl2wGREaSGS+VQ4o=; b=jFu6mNfQU++moCPZtbq5vv4wEO+6JsoE+UNX5jNcQrTJfT7P49f722l+OE8m7gN8Ea j14z+XBXjoEg+hcVe6GCChVVs3f3wd9GXDIuO/JoQgUgc07x91uLr8a8KQkMXuVla2bu VBgVQRAhgeDrEfirL8RpsFKHxakO+9Ss1NqrY5NVwGECQSTzeBQW+LjDf5Wu6/EeGDAd kCqj2PobM63I0JGmCyC18ynpv6hcdNRy3/B41m/OUtyIeYzoP8c+OovY1Hsvp8ZqYODI scBDuWQPX4JInQeRLh86xvXMwKJQIVZhPN5RBMQgVkbLj+GI/yMnWlFwws2DOENKQfKj U7qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780276626; x=1780881426; 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=mwLMWrmbR91BhNPmlLHfTLHqptHAl2wGREaSGS+VQ4o=; b=iUac3kULF6Owhae3PkjvuD4EyHfZiGwCwG23o05/pwe4Mz34q7fZkCMfaPlW/B5oU8 B3kKKwNefv8goYVdrRT+gKdX47EWs2gNmF7JPwUpuaA1jvjg3VwRLnQa7LxA3NmA7Npa hQ/kd0L/LGl5UymKaJixAhm+bVu5jlWX1+C0nO1M68JCnh5HmVw+WrcFzebyJ48+8Y4D basWRo0kwAxO9w6j4emVXWB5rdQi2l/zV+HsyXGIYglJLuQrfxBTwvhYAnKDO9QzZabM 4QBfxXg6Nx7TmrWNsLLdlpkVSJlkWpVBZuWM2n487jKTY5AlrwoQZWlP8iYeU8GbFIPC EfdA== X-Forwarded-Encrypted: i=1; AFNElJ/3qvLwcrjYSwnQsQPj0fJJK4mnnTF9uD7/PP4QXcODN4oBvMBkSp/KLzentDNoscj1eWAA42dHqXvI+3C8@postgresql.org X-Gm-Message-State: AOJu0Yxb6755DmrBVJQ8bEukUP9AZU/D0bAALUOUialrCS/Mn+YIxybY HWwif/eK/PvB1QjMAndFJJLry2kEZ20IULl7UB9n4SRMplix+B8GOjr3+h+T6kwIQRsnR86d4Hc WOoq7ExLkVMiDJ4dUqk6Obtaijglrr0U= X-Gm-Gg: Acq92OHzofyOtAvv2kchZVRbONbl4Z69SHd/ZJIRXbvJBPIoI/XGef9YexPKWr2Ag3d rRLvyUWqYZ+chae/0d82Mx2TJcUSx8xh8QQW8q0o8F/2QuGPtiAPE8foky3n6SM7pTobQg2tmWF I3IVPjcAL29TDVfva7ERFWx7cHik4RMTc2qGn+ghZCi55rDbkE0gK7L6k8g0auib7hCVz91oQYc 1RLnFKIwu0OmnfPY1xZLG3xf+NlQDyb4QDj5HYgFcyLovr4tmG7lCfmUO2JPUVWUqfplIH3zIyW tYU5sZ3MehL4ko7I+/nA8lgKmA5YeWsU2aIGbkxaiMj3eFV6jbH27CJN3fdJ X-Received: by 2002:a17:906:cc4d:b0:be8:c30e:6137 with SMTP id a640c23a62f3a-beab17ab996mr284830266b.28.1780276626300; Sun, 31 May 2026 18:17:06 -0700 (PDT) MIME-Version: 1.0 References: <20260427.174220.1939160662649810289.ishii@postgresql.org> <20260502.140304.670813149418899420.ishii@postgresql.org> <20260531.213313.1224322053367141508.ishii@postgresql.org> In-Reply-To: <20260531.213313.1224322053367141508.ishii@postgresql.org> Reply-To: assam258@gmail.com From: Henson Choi Date: Mon, 1 Jun 2026 10:16:54 +0900 X-Gm-Features: AVHnY4IEUSn8vAFYvMYsNHzbfu_tMP1T-KImUxKy7SBDnggKhzWwod3RGiM9MEk Message-ID: Subject: Re: Row pattern recognition To: Tatsuo Ishii , jian he 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="000000000000e9a1ee065326f341" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000e9a1ee065326f341 Content-Type: text/plain; charset="UTF-8" Hi Tatsuo, > I accidentaly noticed that v47-0002 changes findTargetlistEntrySQL99 > from static to extern. > [...] > I think this is not necessary anymore since findTargetlistEntrySQL99 > is not used outside parse_clause.c. Good catch -- you're right, and I'll revert it to static in v48. I double-checked the current tree: the only callers left are inside parse_clause.c (the findTargetlistEntry wrapper, plus the GROUP BY and ORDER BY paths), so the extern prototype in parse_clause.h is now unused. The revert is just dropping that prototype and restoring the static qualifier with the in-file forward declaration it used to have. It's worth saying why it went extern in the first place, since the reason is no longer visible in the tree: The DEFINE clause needs its referenced columns present in the plan's targetlist to be evaluable at run time. The original implementation did that from the RPR side, in parse_rpr.c, by calling findTargetlistEntrySQL99() with resjunk = true to add the missing entry -- and since that function was static in parse_clause.c, reaching it across files is what required exposing it as extern. That approach added the whole DEFINE expression to the targetlist, and that turned out to be the source of a SIGSEGV: when an RPR window and a plain window coexist, the non-RPR WindowAgg inherited targetlist entries carrying RPRNavExpr nodes it has no way to evaluate. The fix was to add only the Vars a DEFINE references (with a guard in allpaths.c to keep those columns from being pruned), and that is what removed the cross-file call. So the extern has simply outlived its caller -- exactly as you spotted. The one loose end there is an optimization, not a correctness issue: the allpaths.c guard is deliberately coarse, so it also blocks removing a WindowAgg whose RPR WindowFuncs are all unused. Doing that precisely means restructuring remove_unused_subquery_outputs(), which runs for every subquery and not just RPR -- broad enough that I'm treating it as a longer-term item rather than part of this work. It doesn't bring the external call back -- the Var-only path stays -- so the revert to static is safe independently of it. I'll fold the static revert into v48. Thanks, Henson --000000000000e9a1ee065326f341 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Tatsuo,

> I accidentaly noticed that v47-0002= changes findTargetlistEntrySQL99
> from static to extern.
> [.= ..]
> I think this is not necessary anymore since findTargetlistEntry= SQL99
> is not used outside parse_clause.c.

Good catch -- you&= #39;re right, and I'll revert it to static in v48. I
double-checked = the current tree: the only callers left are inside
parse_clause.c (the f= indTargetlistEntry wrapper, plus the GROUP BY and ORDER
BY paths), so th= e extern prototype in parse_clause.h is now unused. The
revert is just d= ropping that prototype and restoring the static qualifier
with the in-fi= le forward declaration it used to have.

It's worth saying why it= went extern in the first place, since the reason is
no longer visible i= n the tree:

The DEFINE clause needs its referenced columns present i= n the plan's
targetlist to be evaluable at run time. The original im= plementation did
that from the RPR side, in parse_rpr.c, by calling find= TargetlistEntrySQL99()
with resjunk =3D true to add the missing entry --= and since that function was
static in parse_clause.c, reaching it acros= s files is what required exposing
it as extern.

That approach add= ed the whole DEFINE expression to the targetlist, and that
turned out to= be the source of a SIGSEGV: when an RPR window and a plain
window coexi= st, the non-RPR WindowAgg inherited targetlist entries carrying
RPRNavEx= pr nodes it has no way to evaluate. The fix was to add only the Vars
a D= EFINE references (with a guard in allpaths.c to keep those columns from
= being pruned), and that is what removed the cross-file call. So the extern<= br>has simply outlived its caller -- exactly as you spotted.

The one= loose end there is an optimization, not a correctness issue: the
allpat= hs.c guard is deliberately coarse, so it also blocks removing a
WindowAg= g whose RPR WindowFuncs are all unused. Doing that precisely means
restr= ucturing remove_unused_subquery_outputs(), which runs for every
subquery= and not just RPR -- broad enough that I'm treating it as a
longer-t= erm item rather than part of this work. It doesn't bring the
externa= l call back -- the Var-only path stays -- so the revert to static is
saf= e independently of it.

I'll fold the static revert into v48.
=
Thanks,
Henson
--000000000000e9a1ee065326f341--