Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAHe5-0002hE-9d for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Oct 2018 16:47:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gAHe3-0003jj-EY for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Oct 2018 16:47:35 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAHe3-0003jb-5N for pgsql-bugs@lists.postgresql.org; Wed, 10 Oct 2018 16:47:35 +0000 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gAHe0-0002Lw-7i for pgsql-bugs@lists.postgresql.org; Wed, 10 Oct 2018 16:47:34 +0000 Received: by mail-qk1-x72c.google.com with SMTP id 23-v6so3569216qkh.8 for ; Wed, 10 Oct 2018 09:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=HyA2oiKFK/P9cOXPBYY0NI7hyJiYoMDNhfr6HVzQ0HA=; b=VSmC5UTlj5adTewFtCuLGEcZRd96whd5dM3ZyOm+vsefVqpUCmWlunYKUxSHMY+jUr RQKJ7IQpIHT9a/SZAUuFSnTKOHy4lcPu+cAfs06syHC30hrQ7wSHFlmazRzXbfB8uJWI CwD21l72RM/2A8WhxlhT2E2b3kH0ZeMWCnz+PZShWKEp1MEuP5GUx2WV0eTUSkIqvpDd ki8nTXI9OqEF/eeY1XYS3rTKHHSK4qroFHKcYbBRa8fNe7Ao1t51B18Jy3vYGH2Ew3eO 9qywG7GvxqbpjbcV0XmWZPPJxHDgde8ReG1DFCYpSNSQNMTi9MHXioCV73aGXJuFI0Uu NWhg== 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:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=HyA2oiKFK/P9cOXPBYY0NI7hyJiYoMDNhfr6HVzQ0HA=; b=WKqznr9erZwHmOrbRGX/7uQacWrbqeoDSUNEtQMfBvD0KAYiOUxczqKuI+PQoTC/az 6QX9G5H7+/e8TH1MzwiJgTC+9Mrg+PKKhGcKjlQ6N+IdJY+sZ5z7zSTxJhWOCjdErpXH jmWov0QW8juoRym/2nJfw6hsRUd3WAQjcIGA0ytTsl/ZoMHDDYSDWuZtoiL+UA5vPz7T xllko9/Wm+ShyXCv4iXRmZJhGF7a6wDSNkjMKW44D4uzQT5eEKp0UlrKq5JaKgGBA/AY ZwljoRCJsBGDkg2WgzAstkfQb00eXZvYrsWmCmI6pCxj5WJD96O9bCfHS1+j7dCwHgom DzfA== X-Gm-Message-State: ABuFfohdizEhuQa/U2Tk37+VWjQxUDZncwPOfAruut8Zms4Kgr9KnSm5 0T9g1YBlQZMu6q9Syf/J5L3HwQ== X-Google-Smtp-Source: ACcGV62QRn8lqE+hl/B43M36LZg2kZfvWNgEl7i3+9fehStb/+vdQrW63aOsMTD8MA+v+8sbbaUx0A== X-Received: by 2002:a37:4952:: with SMTP id w79-v6mr5548056qka.85.1539190050990; Wed, 10 Oct 2018 09:47:30 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id 144-v6sm11772748qkk.63.2018.10.10.09.47.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Oct 2018 09:47:30 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 480E772C; Wed, 10 Oct 2018 13:47:28 -0300 (-03) Date: Wed, 10 Oct 2018 13:47:28 -0300 From: Alvaro Herrera To: mikemjv@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15425: DETACH/ATTACH PARTITION bug Message-ID: <20181010164728.ymzfjw6loxj6flx6@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <15425-2dbc9d2aa999f816@postgresql.org> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Oct-10, PG Bug reporting form wrote: > After I DETACH a partition, and then try to ATTACH it again, I get errors: > ERROR: duplicate key value violates unique constraint > "pg_constraint_conrelid_contypid_conname_index" > DETAIL: Key (conrelid, contypid, conname)=(26702, 0, > test_result_asset_id_fkey) already exists. > > It looks like it is trying to add the foreign key again. Thanks. Reproduced with create table main (a int primary key); create table part (a int references main) partition by range (a); create table part1 partition of part for values from (1) to (100); alter table part detach partition part1; alter table part attach partition part1 for values from (1) to (100); Looking into it. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services