Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEpIw-004S8z-2G for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Apr 2026 14:08:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEpIv-003Eqc-2w for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Apr 2026 14:08:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEl23-001pTk-29 for pgsql-bugs@lists.postgresql.org; Mon, 20 Apr 2026 09:35:07 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wEl21-000000026rf-2q8N for pgsql-bugs@lists.postgresql.org; Mon, 20 Apr 2026 09:35:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=d37iaUN7bGus2EZWMGH6FFjTM2qeGRsKUSk6+41f/lo=; b=zXMJ4iWDJAlCOHcTsyxTrlMKTG UEqGqdAtw3RNGXyYEzQdDcIWeYYxNBrfo0upwZ75ZZ2/K5fzS6tlou3nIPpM9GMPosP6yvIfY3n9C NBewCMcFl0bfzIEW1/aF9an5MZaGR8nT1jvI/Xv75Ei9h7M0i1Vxf5y5Ui1fqKccZbDz1GXri32Y7 7WEaoNQT5oju8vSZmNyDiJJ4u6QRvksv022ytYhmiLDWHthBI4XSNW6twDe74Uvh7/GP+A07Bdhvb 13yhyxpIYCAZwxCRrYhUvFOMvYkWkXqoy8XENDd/wcUopXMKfvycufUv2UPve03eDYSCHWKfgNNXl S4DjRDvA==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEl1z-005f1F-1v for pgsql-bugs@lists.postgresql.org; Mon, 20 Apr 2026 09:35:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEl1y-00CfTI-1T for pgsql-bugs@lists.postgresql.org; Mon, 20 Apr 2026 09:35:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19462: MERGE on partitioned table with INSERT DEFAULT VALUES fails with "unknown action in MERGE WHEN clau To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: 303677365@qq.com Reply-To: 303677365@qq.com, pgsql-bugs@lists.postgresql.org Date: Mon, 20 Apr 2026 09:34:09 +0000 Message-ID: <19462-563c85bec169995a@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19462 Logged by: chunling qin Email address: 303677365@qq.com PostgreSQL version: 15.0 Operating system: centos Description: =20 ## Summary A MERGE statement targeting a partitioned table fails with `ERROR: unknown action in MERGE WHEN clause` when the NOT MATCHED clause uses `INSERT DEFAULT VALUES`. ## 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 partitioned target table CREATE TABLE pmerge_tgt (id INT) PARTITION BY RANGE (id); CREATE TABLE pmerge_tgt_lo PARTITION OF pmerge_tgt FOR VALUES FROM (MINVALUE) TO (100); CREATE TABLE pmerge_tgt_hi PARTITION OF pmerge_tgt FOR VALUES FROM (100) TO (MAXVALUE); CREATE TABLE pmerge_tgt_def PARTITION OF pmerge_tgt DEFAULT; -- Create source table CREATE TABLE pmerge_src (id INT); -- Insert test data INSERT INTO pmerge_tgt VALUES (50); INSERT INTO pmerge_src VALUES (200); -- Bug reproduction MERGE INTO pmerge_tgt t USING pmerge_src s ON t.id > 1000 WHEN MATCHED THEN DO NOTHING WHEN NOT MATCHED THEN INSERT DEFAULT VALUES; ``` 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. -- Bug reproduction MERGE INTO pmerge_tgt t USING pmerge_src s ON t.id > 1000 WHEN MATCHED THEN DO NOTHING WHEN NOT MATCHED THEN INSERT DEFAULT VALUES;ERROR: relation "pmerge_tgt" already exists postgres=3D# ERROR: relation "pmerge_tgt_lo" already exists postgres=3D# ERROR: relation "pmerge_tgt_hi" already exists postgres=3D# ERROR: relation "pmerge_tgt_def" already exists postgres=3D# postgres=3D# postgres=3D# ERROR: relation "pmerge_src" already exists postgres=3D# postgres=3D# postgres=3D# INSERT 0 1 postgres=3D# INSERT 0 1 postgres=3D# postgres=3D# postgres=3D# postgres-# postgres-# ERROR: unknown action in MERGE WHEN clause