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 1lO2I5-0001ej-2s for pgsql-hackers@arkaria.postgresql.org; Sun, 21 Mar 2021 17:55:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lO2I3-0008Aj-SC for pgsql-hackers@arkaria.postgresql.org; Sun, 21 Mar 2021 17:55:03 +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 1lO2I3-0008Ab-HS for pgsql-hackers@lists.postgresql.org; Sun, 21 Mar 2021 17:55:03 +0000 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lO2Hw-0007We-JT for pgsql-hackers@lists.postgresql.org; Sun, 21 Mar 2021 17:55:02 +0000 Received: by mail-io1-xd2d.google.com with SMTP id f19so11564753ion.3 for ; Sun, 21 Mar 2021 10:54:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=VTMT1GLeEjYS2NLDvu52Ay8cN28Djo898jxXUOeh2E4=; b=hirCo3QhkFLrA0QNnYMLg5CBEgnUNmEzcIVWDO0fVGzNbWNCydjPMtImuTmaZq5Lj4 WTJAj0GREwIh0zj8sgRbp3cwTT6lOyN+ttqxocDSvAy9hW49V3bUwPsrmY3teUzFjGUB H/MHThanHqfNsiZBWrO4dEJo60PdHRX43jGzsIxljpjgQKE3Olj4AP2YrOnpvqlVSdtg 7lX+lRYlm7A/gPBPdPAirKI2C0iOLWPnt+0yKIJYjqt+IuKZpxr+ZK0QCjACPyl1SpYy qYpcqdua34OH4oXvQuwCD7+L1Sc38EUoeaQhS9jhtm0frjLEgYQrjS/7xLXrBbPFbsOk PHlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=VTMT1GLeEjYS2NLDvu52Ay8cN28Djo898jxXUOeh2E4=; b=G1iPJw2UezJOsYJJCxhQIlhz9pdHu3OzvdcgV8vxZokJHwMYPtonFGT9MbXwbTP7u4 rx7NOrO5ez1PUXsPv7ZjzaVp6gmbE1ZYZeiSNtd7cEY1nZ5kdFpKo7VC2sU/0dtuovyF WYUBjKS/FWgXpftjr3y9j4fqFnJRBhunS1txxlS6j4xF9UbLSPosGq1euqyRYAJFzd05 78JoZaL5yFoCxaDJLiXMgZkdh2Gug/X6+LfHXlXKwrtfexddG0zIrZtSqyGtQQ6sXUzw QB8TRwFFwgAqtiqLd7qag+sQymmUq9/Y4nokOBflfUv++1PAnVuxC5ev/AOikOGVcTia PYIQ== X-Gm-Message-State: AOAM5328ouDEnDPGBAK72iqkorbgY81wDIoltDQVUTwDSp/VXYylYqAX FNX8QKStddQPVIhVNlYgcTzM/w== X-Google-Smtp-Source: ABdhPJyqWIV63mnH0mi8DAJkwpHhT6Z8LTo1LuTV/GR0osyfjuAwQd5WXPCGzNK/yGDTyO3efgR5EQ== X-Received: by 2002:a05:6602:2248:: with SMTP id o8mr8349947ioo.155.1616349295767; Sun, 21 Mar 2021 10:54:55 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id g14sm6104480ioc.38.2021.03.21.10.54.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Mar 2021 10:54:55 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id D89B8800A4D; Sun, 21 Mar 2021 12:54:53 -0500 (CDT) Date: Sun, 21 Mar 2021 12:54:53 -0500 From: Justin Pryzby To: Alvaro Herrera Cc: Amit Langote , pgsql-hackers@lists.postgresql.org Subject: Re: ALTER TABLE .. DETACH PARTITION CONCURRENTLY Message-ID: <20210321175453.GB11765@telsasoft.com> References: <20210317184534.GB11765@telsasoft.com> <20210319135737.GA28771@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210319135737.GA28771@alvherre.pgsql> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Mar 19, 2021 at 10:57:37AM -0300, Alvaro Herrera wrote: > > Also, it "fails to avoid" adding duplicate constraints: > > > > Check constraints: > > "c" CHECK (i IS NOT NULL AND i > 1 AND i < 2) > > "cc" CHECK (i IS NOT NULL AND i >= 1 AND i < 2) > > "p1_check" CHECK (true) > > "p1_i_check" CHECK (i IS NOT NULL AND i >= 1 AND i < 2) > > Do you mean the "cc" and "p1_i_check" one? I mean, if you already have No, I started with c and cc, and it added the broken constraint p1_check (which you say you've fixed) and the redundant constraint p1_i_check. I guess that's what you meant. > a constraint in the partition that duplicates the partition constraint, > then during attach we still create our new constraint? I guess a > solution to this would be to scan all constraints and see if any equals > the expression that the new one would have. Sounds easy enough now that > write it out loud. But it looks like DetachAddConstraintIfNeeded already intended to do that: + if (equal(constraintExpr, thisconstr)) + return; Actually, it appears your latest notpatch resolves both these issues. But note that it doesn't check if an existing constraint "implies" the new constraint - maybe it should. -- Justin