Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdbXu-0002A3-CA for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Nov 2020 16:03:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kdbXt-0004jk-3N for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Nov 2020 16:03:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdbXs-0004jX-Tk for pgsql-bugs@lists.postgresql.org; Fri, 13 Nov 2020 16:03:28 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdbXl-0006IW-2E for pgsql-bugs@lists.postgresql.org; Fri, 13 Nov 2020 16:03:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0ADG3HR4288079; Fri, 13 Nov 2020 11:03:17 -0500 From: Tom Lane To: gatekeeper.mail@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16714: INSERT ON CONFLICT DO UPDATE fails to infer constraint if it's not at top-level partition In-reply-to: <16714-dbf5759eba70bfe4@postgresql.org> References: <16714-dbf5759eba70bfe4@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 13 Nov 2020 03:23:43 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <288077.1605283397.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 13 Nov 2020 11:03:17 -0500 Message-ID: <288078.1605283397@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > insert into tbl values (1, 1, 1, 1, 'b') on conflict (part_key4) do upda= te > set values_columns =3D excluded.values_columns; > -- ERROR: there is no unique or exclusion constraint matching the ON > CONFLICT specification I see no bug here. The partitioned table indeed does not have any such index. Moreover, if you had tried to make one, you would have gotten ERROR: unique constraint on partitioned table must include all partitioni= ng columns DETAIL: PRIMARY KEY constraint on table "tbl" lacks column "part_key1" wh= ich is part of the partition key. The short answer here is that uniqueness constraints on the individual partitions are not a substitute for a constraint on the whole partitioned table. regards, tom lane