Re: BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE - Mailing list pgsql-bugs

From surya poondla
Subject Re: BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE
Date
Msg-id CAOVWO5pvxWGTr_YTFd6=kvCLk_4Jpaj13gNBY=NJZ9BTh+ounw@mail.gmail.com
Whole thread
In response to BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #19467: Inconsistency in MOD() result involving POWER() and floating-point precision in PostgreSQL
Next
From: David Rowley
Date:
Subject: Re: BUG #19463: Server crash (Assertion failure) when using MERGE statement in CTE