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 1obJcd-00012R-Pt for pgsql-sql@arkaria.postgresql.org; Thu, 22 Sep 2022 10:39:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1obJcc-0001U0-B8 for pgsql-sql@arkaria.postgresql.org; Thu, 22 Sep 2022 10:39:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1obJcc-0001Tl-08 for pgsql-sql@lists.postgresql.org; Thu, 22 Sep 2022 10:39:58 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1obJcV-0004Bu-CJ for pgsql-sql@lists.postgresql.org; Thu, 22 Sep 2022 10:39:56 +0000 Received: by mail-ej1-x636.google.com with SMTP id bj12so19968992ejb.13 for ; Thu, 22 Sep 2022 03:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=i21WMriJIYmSypJzbswTkk1mihoe5RdX0SMwlGiSN6o=; b=PAVu7cr2D2Rn4I1L5kBg58dyAc2/qBGkLP1Mxzh8o6Uaqq3LbdB/aJSVvTITH42F+o 3UnTbn3yigB+UWC8qiZTSSmqxBcT7T5/Gsu0kIiCNv7ebcKRRbwQuDJFUuD6tBmHFrGj oRHf14QKkFsIzr1yUut+QTKeEZkgrx4Q/RqwrzWnynMAcLdBDbWRGyeZ54VWUB0jFBiw SxYIZ7BONp9eIT6TNd6uRP7ml/mNidgytLiRQcLh7YTftrXhJh1+XJNwVw96Fp0h6dCy 79r4L0hqEWHjw4cQafAm3wEYz7FG1AwDcjxD+qmEFtKtX6gjz26lAR0jsqnPQI7/OHvr kcRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=i21WMriJIYmSypJzbswTkk1mihoe5RdX0SMwlGiSN6o=; b=jgZl+uGd8TXEQhXEgwS2FT6tG5+d6h7GWoyOUYGpLk2RjQ/YP+OKFK8GFNcr+KrBqT iibKXFmxBDPtvp2Rvo5LdW9z/0+X5trpVeKUJMVUOF/KAdzxH3c19clny5iDm+8iMeu3 w1gVxbOJ4/eJf+nKmO2d7vIFTGVu8158niYnxQ/s7o+QDHMyOsJ73rvXePxl94UmF9zV t4pm325Bgxj81H9r8+Vddo3GO04gVyWoej9vqjwY0E9yd0IahkcAxc5HY41YJxAbEoJ5 xzU7ZBIF2v3ZjA1UMsS4duSS2HvQE6BvSi+lyodxw/eWmxlXbDqvWCcLuC59Tx6Ym//n bFng== X-Gm-Message-State: ACrzQf3vEIZP0BCq10XELb0DXHJ5wylhUbRimOAhTTmxDfoLzABPLezt V2KrWxRv06I97Z+B2a+DZka22YWmIW6llPxKGkw= X-Google-Smtp-Source: AMsMyM4ZKrdnas4aPAn21HMDexctfA5dRt9bg1/iP1HzmX/dAEtHlPTIGM6+jResVQlvWatNmv+M5KqdYoYu1Rsu+Fc= X-Received: by 2002:a17:907:7b95:b0:72f:9c64:4061 with SMTP id ne21-20020a1709077b9500b0072f9c644061mr2227660ejc.351.1663843188663; Thu, 22 Sep 2022 03:39:48 -0700 (PDT) MIME-Version: 1.0 References: <3585170.1663310489@sss.pgh.pa.us> In-Reply-To: From: Geri Wright Date: Thu, 22 Sep 2022 06:39:27 -0400 Message-ID: Subject: Re: ON CONFLICT clause NOT working on Partition Table PostgreSQL 12 To: David Rowley Cc: Inzamam Shafiq , Tom Lane , Steve Midgley , pgsql-sql@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000038eaad05e941aef2" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000038eaad05e941aef2 Content-Type: text/plain; charset="UTF-8" You can create a Constraint trigger to check the new values of the desired columns when updating or insering them. This trigger will fire for each partition but checks the data in the entire table. The trigger should obtain an advisory lock for the unique columns . Here is a blog for more information. https://blog.ioguix.net/postgresql/2015/02/05/Partitionning-and-constraints-part-1.html On Tue, Sep 20, 2022, 5:46 AM David Rowley wrote: > On Fri, 16 Sept 2022 at 19:52, Inzamam Shafiq > wrote: > > Is there anyway we can create constraint on column only which are not > part of partition key? > > Unfortunately, there is no way to create a unique or primary key > constraint unless the constraint contains all columns from the > partition key. This is explained in the limitations section in [1]. > > If you need such a constraint, then you might want to consider > changing your partition key. > > David > > [1] https://www.postgresql.org/docs/12/ddl-partitioning.html > > > --00000000000038eaad05e941aef2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
You can create a Constraint trigger to check the new valu= es of the desired columns when updating or insering them. This trigger will= fire for each partition but checks the data in the entire table.=C2=A0 The= trigger should obtain an advisory lock for the unique columns . Here is a = blog for more information.=C2=A0

On Tue, Sep 20, 2022, 5:46 AM David Rowley <dgrowleyml@gmail.com> wrote:
On Fri, 16 Sept 2022 at 19:52, Inzam= am Shafiq
<inzamam.shafiq@hotmail.com> wrote:
> Is there anyway we can create constraint on column only which are not = part of partition key?

Unfortunately, there is no way to create a unique or primary key
constraint unless the constraint contains all columns from the
partition key.=C2=A0 =C2=A0This is explained in the limitations section in = [1].

If you need such a constraint, then you might want to consider
changing your partition key.

David

[1] https://www.postgresql.org/do= cs/12/ddl-partitioning.html


--00000000000038eaad05e941aef2--