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 1wGCrN-005zbv-04 for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Apr 2026 09:30:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wGCrM-005kRP-0L for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Apr 2026 09:30:04 +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 1wGCrL-005kRG-2h for pgsql-hackers@lists.postgresql.org; Fri, 24 Apr 2026 09:30:03 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wGCrJ-00000002YTH-3gQ3 for pgsql-hackers@lists.postgresql.org; Fri, 24 Apr 2026 09:30:02 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-43d7645adbdso4115978f8f.1 for ; Fri, 24 Apr 2026 02:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777023000; cv=none; d=google.com; s=arc-20240605; b=Y3UBkTInfC67LP0s/kdfdKYQNMN+8WcBAKm5+Dn4tu72EChU5u/p/VeW3MOJ47+BUZ ZEY7rboMRxeZkQDbHO0dE6gRl+tODAX6bpL7+4BF7NyB6LW6BCiuh0zIiAm6Avyt02cd KuHsmj299BRqO3oRolztE3abkliae9o+DnucmKcUoEuHf71t3VuFpQdW4vsjwtT/nToS EUzoQL41+cGRFHGCGJvyayd0xHIrYhEzgMbCbNeRWbBRyitzVvrVHdv9/tPrCopD98z7 nkgAwlioXUe04uE4G//k8xfZSNHBUTxPeR4H24xXTat1SmCzlGx4Z7TmS9jNHI+cAZ72 hdrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=NYe6ywYnWtUlaZ1oRxk3eSoCi7ctg+HCkXDmNPSLnEY=; fh=pgaxs2WdOku/Gbt9Qa0QeDFEXWUyO2b96MzaHLexcXI=; b=SRBqBgecrYYDV+5mLBF8YGqTkEjs7OPQgwCOfCf/QNDd6gdUmYZWCfGVH8wwV+MGs8 +FYaHSEYxX/JPUg+oL/98uUYrfEkn6sOC1GoqTSXHxjXN2mwj0yH0XICrmoQGlOnfdBX NTa1RVY62dkSdiSwxpKFm6047E6p8qNh31xNgT+iaEjaLATixPg8hJ44p5ITlsH7/n2+ DVaDcBeIuBT3fB2BglN3nFNyhnhqAGFm3Yqle5/h7XU/tVh7Y9/TUS0uq9CmDQDy//vv wo5N5j1JbMLvZBOpHZ9MXXuWuEftCmanZ0zsKqep+pfOQc3h2JrUPtoKwOFbEmrU0FDe 9xmQ==; darn=lists.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=1777023000; x=1777627800; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NYe6ywYnWtUlaZ1oRxk3eSoCi7ctg+HCkXDmNPSLnEY=; b=gmq9XH1xbh//k+wlTEvbgdXoxlAl5Rmikz7wwlYX17a2hhWGlie8t6vVaWuqMzW+lW gT9bg9IS6FKObJ/ez7ZA7ZQp0mjPXKcIIVJQBd0gXL3e7NCO5Kh8v2LKxS8Aia+nbWK+ AseWQQgnuPxY55KRXDX5AZL9KBN9JTeSeLdPMlg1ExChqTvgDr7avnf1T8x0A/UgYrMu y+L4GpUT49B/rGTV6uR7HhYl2jIYUGGEE71QtCLdXknxhw4NXUww+cvb2bhde1FRJQYK didmYfFzXe8isOpaWNCTSVqd4L4YnMGA0kl37Xz+Ub0SSouXH5ZhjDOXU1vXnSdwxMgS VumQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777023000; x=1777627800; h=content-transfer-encoding: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=NYe6ywYnWtUlaZ1oRxk3eSoCi7ctg+HCkXDmNPSLnEY=; b=WXxOR2Pt5iZfk/lOpbikdkMN+q8lYzGe/uRg8e28HOz6ot8znKNEfRTFXcuKaDgBaO PczPZzdfyhUN1boxdq/Yg7Im4eYLFBv3VZ1uFUihq0y/l4knhDTvxwVNu3HQDtQ9gFqq zpurOd3iE0ItPqzMxYfIYwh2SD8y0+mdNCSgGcxk134+JpFYbv5kPkUy/lMTrS1xMoCh uQMCbTMti0XuWEH9m4pDhfN5YChwWySVaDo+mDoiSZhtFryHdSfZscp10ZCLSIppA2zT 2IUWJHJpVACEk+Hnzz06gxrIyj34vEvawZO3flabeD4UxoTYNyV2jTwDPNC5iYeaEKic C+wg== X-Forwarded-Encrypted: i=1; AFNElJ/OtB7coKRMK+NQOxajQHER7NTpXQ2SNHrKM9pY5F2iZ2Ucx3MBpoSIxnL+zodOstCxFfGbiy8YocVeiFhv@lists.postgresql.org X-Gm-Message-State: AOJu0YzxqoiRk4CUrJstqUsFmab5a5/T7ntAsQNSQrCptcOwnFd1gB8C 6dGlWB0LJsMszc7NXZlusmpSvMSMT8SDjODjRNvUm3zgqogZoObizIdqJFpDO47u3u1LM3xzuc4 Rlr/GLLpYE8WludxVnhuvSq/jkcog81M= X-Gm-Gg: AeBDies+JlsSU+A0qdTZgBFCFRJOgFpP1z8tPkvCdmtAH+ukcdE03Y6dS0JUhzHlAbn dVhfg70kj8yD7uWpzykD8t8HQT3mtntcaOIiyVrxHIX7+5WKnQ6Fkr0R2P6q2pA2zSlfC5aM77Y 4Fv08miK24Fos4VzAcYxpSbDuQPHf2Y46r6a4cwnE1lfFet0AJhuYaVYWflcmUXdE1w4ShJHM42 AoHcGQfDwdnS0IJ/JbJ2cv4NlwkAEDjgX7wRmw7PV3Dp18cfQ+fOM7kVIAH1TFxDXs/LZTVtJZC uID1VqsXy3R/d9mOG8fHrrmmF1EQPVwWhrkuLHvjnlNB4J2m3Sy7q40YKKUdCNQ= X-Received: by 2002:a5d:584c:0:b0:43f:dc86:d61f with SMTP id ffacd0b85a97d-43fe3db30c8mr49920733f8f.14.1777022999802; Fri, 24 Apr 2026 02:29:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ashutosh Bapat Date: Fri, 24 Apr 2026 14:59:45 +0530 X-Gm-Features: AQROBzBpcmEJUKxsLJEv0hSLr7Vt-EUeDB0plUAdE-14_7XKusNL1boiYROHil4 Message-ID: Subject: Re: Bug: Missing check_stack_depth() in GRAPH_TABLE rewriter To: Peter Eisentraut Cc: SATYANARAYANA NARLAPURAM , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Apr 24, 2026 at 11:54=E2=80=AFAM Peter Eisentraut wrote: > > On 15.04.26 17:07, Ashutosh Bapat wrote: > > Thanks for the report. I could reproduce the segfault on my laptop. > > The attached patch fixes it and gives ERROR: stack depth limit > > exceeded. > > > > generate_queries_for_path_pattern_recurse() - has to work in a linear > > fashion since the elements need to be processed in an order. Each > > permutation of elements produces one query. These queries can be > > arranged in a balanced tree as you suggest OR when constructing the > > setop tree we could generate it in divide-and-conquer manner. However, > > the tree will be flattened in the planner anyway (See > > flatten_simple_union_all() and pull_up_simple_union_all()). Thus the > > final planning will require a deeper stack anyway. The code complexity > > doesn't seem to be worth it. > > > > I also looked at a few commits that add check_stack_depth() to see if > > we add tests for these scenarios. But I didn't find any. So no tests > > added with this commit. > > committed > Thanks a lot for committing this and other fixes. > (I moved the #include "miscadmin.h" to a more alphabetical position.) > Didn't notice this. Sorry. --=20 Best Wishes, Ashutosh Bapat