pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: luy70@psu.edu
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18878: PostgreSQL triggers Assertion Failure in Debug build
Date: Sat, 05 Apr 2025 15:07:28 -0400
Message-ID: <2715647.1743880048@sss.pgh.pa.us> (raw)
In-Reply-To: <18878-a26fa5ab6be2f2cf@postgresql.org>
References: <18878-a26fa5ab6be2f2cf@postgresql.org>

PG Bug reporting form <noreply@postgresql.org> writes:
> In the debug build of PostgreSQL 17.4, compiled with `configure
> --enable-debug --prefix=$(pwd) --exec-prefix=$(pwd) --enable-cassert`,
> triggered Assertion Failure when executing the following statement: 

> ```sql
> WITH RECURSIVE ta01 AS NOT MATERIALIZED ( WITH RECURSIVE any_cte_name AS
> MATERIALIZED ( TABLE ta01 ) DELETE FROM v00 RETURNING *, CASE WHEN FALSE
> THEN TRUE WHEN FALSE THEN TRUE ELSE TRUE END IDENT ) SELECT FROM JSON_ARRAY
> ( TABLE v00 ORDER BY CASE WHEN FALSE THEN TRUE END NULLS FIRST FOR READ
> ONLY) GROUP BY ROLLUP ( CASE WHEN FALSE NOT BETWEEN ASYMMETRIC CASE WHEN
> FALSE THEN TRUE END AND FALSE <> CASE WHEN EXISTS ( SELECT GROUP BY ALL ( )
> FOR READ ONLY ) > CASE WHEN FALSE THEN TRUE END THEN FALSE END IS NULL THEN
> ARRAY ( ( TABLE ta01 ) ) ELSE CASE WHEN TRUE BETWEEN EXISTS ( SELECT GROUP
> BY ALL ( ) FOR READ ONLY ) AND TRUE IS NOT FALSE > EXISTS ( SELECT ALL GROUP
> BY ( ) FOR READ ONLY ) THEN TRUE END > CASE WHEN FALSE THEN TRUE END END )
> FOR READ ONLY;
> ```

This can be reduced to

WITH RECURSIVE ta01 AS (
  WITH any_cte_name AS ( TABLE ta01 )
  DELETE FROM v00 RETURNING * )
TABLE ta01;

That should be rejected, because ta01 has a self-reference and is not
in the allowed form "base-case UNION query-with-self-reference".
However, we managed to miss the appearance of the self-reference
because the code in charge of detecting it hadn't been taught that
WITH is now allowed in INSERT/UPDATE/DELETE.  (Which is a bit
disheartening, but there you have it.)

Fixed, thanks for the report!

			regards, tom lane





view thread (2+ messages)

Message-ID: <2715647.1743880048@sss.pgh.pa.us>
Permalink:  ../2715647.1743880048@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2715647.1743880048@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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, luy70@psu.edu, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18878: PostgreSQL triggers Assertion Failure in Debug build
  In-Reply-To: <2715647.1743880048@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