Re: BUG #18877: PostgreSQL triggers assertion failure

From: "Liang, Yu" <yuliang(at)psu(dot)edu>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Cc: "Liang, Yu" <luy70(at)psu(dot)edu>
Subject: Re: BUG #18877: PostgreSQL triggers assertion failure
Date: 2025-04-04 19:26:17
Message-ID: BL0PR02MB46274580035A781426129C70B7A92@BL0PR02MB4627.namprd02.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Sorry it seems I didn’t provide the full PoC.

After launching the debug postgresql server, in psql, run the following queries.

```sql
DROP DATABASE test123;
CREATE DATABASE test123;
\c test123;
CREATE TABLE v00 (c01 INT, c02 TEXT);
SELECT ALL GROUP BY ALL ( ), CUBE ( CASE WHEN FALSE THEN TRUE END ) INTERSECT ALL SELECT ALL FROM JSON_ARRAY ( WITH any_cte_name AS ( ( TABLE v00 ) ) VALUES ( FALSE ) ), any_table_name GROUP BY CUBE ( CASE WHEN TRUE THEN FALSE END );
```

The original PoC misses the `CREATE TABLE` statement.

Best Regards,
Yu Liang

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
Date: Friday, April 4, 2025 at 2:49 PM
To: pgsql-bugs(at)lists(dot)postgresql(dot)org <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Cc: Liang, Yu <luy70(at)psu(dot)edu>
Subject: BUG #18877: PostgreSQL triggers assertion failure
[You don't often get email from noreply(at)postgresql(dot)org(dot) Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

The following bug has been logged on the website:

Bug reference: 18877
Logged by: Yu Liang
Email address: luy70(at)psu(dot)edu
PostgreSQL version: 17.4
Operating system: Ubuntu 24.04 LTS ARM64 VM
Description:

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
SELECT ALL GROUP BY ALL ( ), CUBE ( CASE WHEN FALSE THEN TRUE END )
INTERSECT ALL SELECT ALL FROM JSON_ARRAY ( WITH any_cte_name AS ( ( TABLE
v00 ) ) VALUES ( FALSE ) ), any_table_name GROUP BY CUBE ( CASE WHEN TRUE
THEN FALSE END );
```

The assertion triggered is: Assert("IsA(cte->ctequery, InsertStmt) ||
IsA(cte->ctequery, UpdateStmt) || IsA(cte->ctequery, DeleteStmt) ||
IsA(cte->ctequery, MergeStmt)").
File: "/home/postgresql/postgres/bld/../src/backend/parser/parse_cte.c",
Line: 150.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2025-04-04 19:33:44 BUG #18879: PostgreSQL returns memory error.
Previous Message PG Bug reporting form 2025-04-04 19:15:14 BUG #18878: PostgreSQL triggers Assertion Failure in Debug build