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 1wG9xd-005weR-0V for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Apr 2026 06:24: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 1wG9xc-004nl0-0u for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Apr 2026 06:24:20 +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 1wG9xb-004nkr-0y for pgsql-hackers@lists.postgresql.org; Fri, 24 Apr 2026 06:24:19 +0000 Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wG9xZ-00000002X78-04qj for pgsql-hackers@lists.postgresql.org; Fri, 24 Apr 2026 06:24:18 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id 165F1140008F; Fri, 24 Apr 2026 02:24:16 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Fri, 24 Apr 2026 02:24:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm1; t=1777011856; x=1777098256; bh=uX+qHwBORUuEACUBHFoK2hESANp2dBU0 0nD7+byZav4=; b=S1kjKT1SfMZ50u1UvmOuOHvxY2OHqk5NBOjnU7fpe0vWBxnh gN9Rwr1XQjEBTC+eY0oCmFcLMs0sHkPKV9np0O6iiFzEwoqBQvZ0R9oC7GZx0XqB UmtFTYb2Lj12kJneFhwq3/Tpciqe6yDyVS/nNPyac6BJG2uvIJ/3hKNUtfWrcypl 8wHQubAzuTI8Gv4OeuF9tZglzhwbxhaPUevHGuRyKIzQVbWwZwLbahtc7pd9tmR4 WrSfHr7+bKel9woJFY+BwnD0aT2DtznJJ2itAZ3lolWA/OJVa2IC4UfHkNb9F9DE BqB/69gFZjN565tlPIj0HOoRtmBRZJDMlTjNoA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1777011856; x= 1777098256; bh=uX+qHwBORUuEACUBHFoK2hESANp2dBU00nD7+byZav4=; b=s vbJw2Sw7aBpUw1WqBNBS6zXlvJAK6BmgyEs5BQPRvK044WL+/+5qX0ktq08P9oIA BvM6vo08o0GN1Goj4RO3CnWU13gIBrzdxJvXhx7raz3nRopw06vVckBz1efn2YGk eGT3ThIhTLrlKLhTpa5N6z9a28jmIw4lPPQsa+Q4+uTDySN3f066/Vkmus9hTXZe 1+CO3XYr5jfRQC4mS4Qh27TPK/Ra/W+gTKRXH4wk8iT9u/+lk+Gc6fAOGdlDF3G8 g5HsXIsgUr8yCmuIc9N5zZLbHWE6tNUo5HlYYaL7n2qSzSOVypXfqBT2VKNhny4z NlkMcUvofJA23zrADtOKA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeileeftdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeenucfhrhhomheprfgvthgvrhcu gfhishgvnhhtrhgruhhtuceophgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgqeenuc ggtffrrghtthgvrhhnpefgjedthfekfedtuefgieelheetleejgefhueeltdfhueetvdff udekfeejhfegheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehpvghtvghrsegvihhsvghnthhrrghuthdrohhrghdpnhgspghrtghpthhtohep fedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprghshhhuthhoshhhrdgsrghprg htrdhoshhssehgmhgrihhlrdgtohhmpdhrtghpthhtohepshgrthihrghnrghrlhgrphhu rhgrmhesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhsse hlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 24 Apr 2026 02:24:15 -0400 (EDT) Message-ID: Date: Fri, 24 Apr 2026 08:24:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Bug: Missing check_stack_depth() in GRAPH_TABLE rewriter To: Ashutosh Bapat , SATYANARAYANA NARLAPURAM Cc: PostgreSQL Hackers References: Content-Language: en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 (I moved the #include "miscadmin.h" to a more alphabetical position.)