public inbox for [email protected]  
help / color / mirror / Atom feed
From: surya poondla <[email protected]>
To: [email protected]
To: [email protected]
Subject: Re: BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE
Date: Mon, 27 Apr 2026 15:31:27 -0700
Message-ID: <CAOVWO5pvxWGTr_YTFd6=kvCLk_4Jpaj13gNBY=NJZ9BTh+ounw@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

Hi Chunling,

Thank you for reporting the issue.

I tried to reproduce the issue on postgres19 and I don't see any crash.

psql (19devel)
Type "help" for help.

postgres=#
postgres=#
postgres=#
postgres=# CREATE TABLE target (col_int INT, col_varchar VARCHAR(2000));
CREATE TABLE
postgres=# CREATE TABLE source (col_int INT, col_varchar VARCHAR(2000));
CREATE TABLE
postgres=# INSERT INTO source VALUES (1, 'test');
INSERT 0 1
postgres=#
postgres=#
postgres=# WITH merge_cte AS (
postgres(#     MERGE INTO target t
postgres(#     USING source s ON t.col_int = s.col_int
postgres(#     WHEN NOT MATCHED THEN INSERT (col_int, col_varchar) VALUES
 WHEN NOT MATCHED THEN INSERT (col_int, col_varchar) VALUES (s.col_int,
postgres(# s.col_varchar)
postgres(# )
postgres-# SELECT col_int FROM merge_cte;
ERROR:  WITH query "merge_cte" does not have a RETURNING clause
LINE 7: SELECT col_int FROM merge_cte;
                            ^
postgres=# WITH merge_cte AS (
postgres(# MERGE INTO target t
postgres(# USING source s ON t.col_int = s.col_int
postgres(# WHEN NOT MATCHED THEN INSERT (col_int, col_varchar) VALUES
(s.col_int, s.col_varchar) RETURNING t.col_int
postgres(# )
postgres-# SELECT col_int FROM merge_cte;
 col_int
---------
       1
(1 row)

I tried to reproduce the issue on postgres15 too, but i see ERROR:  MERGE
not supported in WITH query.


Regards,
Surya Poondla


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: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE
  In-Reply-To: <CAOVWO5pvxWGTr_YTFd6=kvCLk_4Jpaj13gNBY=NJZ9BTh+ounw@mail.gmail.com>

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

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