pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: gzh <gzhcoder@126.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: ERROR: stack depth limit exceeded
Date: Fri, 08 Sep 2023 09:53:33 -0400
Message-ID: <1871319.1694181213@sss.pgh.pa.us> (raw)
In-Reply-To: <1211c4ba.2822.18a72d975fc.Coremail.gzhcoder@126.com>
References: <1e6b9056.492e.18a6e9a1798.Coremail.gzhcoder@126.com>
	<1694898.1694093396@sss.pgh.pa.us>
	<1211c4ba.2822.18a72d975fc.Coremail.gzhcoder@126.com>

gzh  <gzhcoder@126.com> writes:
> In the Release Notes for PostgreSQL 12.14, we saw the following change:
> https://www.postgresql.org/docs/release/12.14/

>> Add recursion and looping defenses in subquery pullup (Tom Lane)
>> A contrived query can result in deep recursion and unreasonable amounts of time spent trying to flatten subqueries. A proper fix for that seems unduly invasive for a back-patch, but we can at least add stack depth checks and an interrupt check to allow the query to be cancelled.


> Our understanding is that this change will cause some complex SQL statements 
> that were previously not reporting errors to report errors in the new version. 

The key word there is "contrived".  You are not going to hit this limit
without intentionally trying.  The example that led to adding this check
was a synthetic query with 10000 UNION ALL branches:

https://www.postgresql.org/message-id/flat/703c09a2-08f3-d2ec-b33d-dbecd62428b8%40postgrespro.ru

Also notice that the query misbehaved before this patch, too, by consuming
excessive RAM.

			regards, tom lane





view thread (14+ messages)  latest in thread

Message-ID: <1871319.1694181213@sss.pgh.pa.us>
Permalink:  ../1871319.1694181213@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1871319.1694181213@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, gzhcoder@126.com, pgsql-general@lists.postgresql.org
  Subject: Re: ERROR: stack depth limit exceeded
  In-Reply-To: <1871319.1694181213@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox