public inbox for [email protected]  
help / color / mirror / Atom feed
BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE
2+ messages / 2 participants
[nested] [flat]

* BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE
@ 2026-04-20 09:42 PG Bug reporting form <[email protected]>
  2026-04-27 23:20 ` Re: BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE David Rowley <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2026-04-20 09:42 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

The following bug has been logged on the website:

Bug reference:      19463
Logged by:          chunling qin
Email address:      [email protected]
PostgreSQL version: 15.0
Operating system:   centos
Description:        

Using a MERGE statement as a Common Table Expression (CTE) causes the
PostgreSQL server to crash with an assertion failure. The assertion in
`transformWithClause` does not recognize `MergeStmt` as a valid
data-modifying statement type.

## PostgreSQL Version

```
PostgreSQL 15devel on x86_64-pc-linux-gnu, compiled by clang version 17.0.6,
64-bit
```

Tested on REL_15_STABLE branch.

## Steps to Reproduce

```sql
-- Setup
CREATE TABLE target (col_int INT, col_varchar VARCHAR(2000));
CREATE TABLE source (col_int INT, col_varchar VARCHAR(2000));
INSERT INTO source VALUES (1, 'test');

-- This query causes server crash
WITH merge_cte AS (
    MERGE INTO target t
    USING source s ON t.col_int = s.col_int
    WHEN NOT MATCHED THEN INSERT (col_int, col_varchar) VALUES (s.col_int,
s.col_varchar)
)
SELECT col_int FROM merge_cte;
```

## Actual Behavior

```
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
connection to server was lost
```


The server crashes with SIGABRT due to a failed assertion.

## Stack Trace

```
#0  0x00007fb27809d294 __pthread_kill_implementation (libc.so.6 + 0x91294)
#1  0x00007fb27804aaf6 raise (libc.so.6 + 0x3eaf6)
#2  0x00007fb278032897 abort (libc.so.6 + 0x26897)
#3  0x00005571eb6e064a ExceptionalCondition (postgres + 0xb3364a)
#4  0x00005571eae8f452 transformWithClause (postgres + 0x2e2452)
#5  0x00005571eae20ca1 transformSelectStmt (postgres + 0x273ca1)
#6  0x00005571eae1dd49 transformStmt (postgres + 0x270d49)
#7  0x00005571eae1e14c transformOptionalSelectInto (postgres + 0x27114c)
#8  0x00005571eae1d713 transformTopLevelStmt (postgres + 0x270713)
#9  0x00005571eae1d647 parse_analyze_fixedparams (postgres + 0x270647)
#10 0x00005571eb415471 pg_analyze_and_rewrite_fixedparams (postgres +
0x868471)
#11 0x00005571eb41a3db exec_simple_query (postgres + 0x86d3db)
#12 0x00005571eb419312 PostgresMain (postgres + 0x86c312)
```
This issue could not be reproduced with the latest version, but we can
easily reproduced  by  PostgreSQL 15devel. I am submitting this report for
official confirmation.








^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE
  2026-04-20 09:42 BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE PG Bug reporting form <[email protected]>
@ 2026-04-27 23:20 ` David Rowley <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: David Rowley @ 2026-04-27 23:20 UTC (permalink / raw)
  To: [email protected]; [email protected]

On Tue, 21 Apr 2026 at 02:05, PG Bug reporting form
<[email protected]> wrote:
> PostgreSQL version: 15.0

You're reporting a bug on a PostgreSQL version that's missing 3.5
years of bug fixes. 15.17 is the latest minor version for the
PostgreSQL 15 release. Please always test with the latest minor
version of the major release before submitting bug reports. If you can
reproduce in a previous minor version, but not on the latest, then
this is likely because the bug has already been fixed. You need not
report these.

> Using a MERGE statement as a Common Table Expression (CTE) causes the
> PostgreSQL server to crash with an assertion failure. The assertion in
> `transformWithClause` does not recognize `MergeStmt` as a valid
> data-modifying statement type.
>
> ## PostgreSQL Version
>
> ```
> PostgreSQL 15devel on x86_64-pc-linux-gnu, compiled by clang version 17.0.6,
> 64-bit
> ```
>
> Tested on REL_15_STABLE branch.

Looks like you must be trying that on a very outdated REL_15_STABLE.
If it's tagged as 15devel, then that's from before the 15.0 release.
Please update your git repo (git pull) and try with REL_15_17.

I tried on 15.0 and 15.17 and cannot reproduce the assert failure
you're seeing. So it looks like whatever you've found was fixed before
the 15.0 release.

David






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-04-27 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-04-20 09:42 BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE PG Bug reporting form <[email protected]>
2026-04-27 23:20 ` David Rowley <[email protected]>

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