Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1he1Mz-0005Ch-Ic for pgsql-bugs@arkaria.postgresql.org; Thu, 20 Jun 2019 18:01:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1he1Mx-0005Co-Qb for pgsql-bugs@arkaria.postgresql.org; Thu, 20 Jun 2019 18:01:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1he1Mx-0005Ch-Dt for pgsql-bugs@lists.postgresql.org; Thu, 20 Jun 2019 18:01:07 +0000 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1he1Ms-00021M-SY for pgsql-bugs@lists.postgresql.org; Thu, 20 Jun 2019 18:01:06 +0000 Received: by mail-qt1-x843.google.com with SMTP id x47so4059179qtk.11 for ; Thu, 20 Jun 2019 11:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=RCqWMJLhV6iXiOtIBWSp2lh35vHg74VJNJaPY815HRQ=; b=vEa2k2yWRW0M9PdPOsQmqZkk7ca2nIRjcYUtx7jrHfzJaFyrg34bt+j3k5eNfEcEJ8 UycTTgivcibRfezMTIxKHhVyFDL5apRE4Q9jzsMsiTT17FdnXlmyRRN6tm9pAUZ3gto+ 56hQNEp/AqqPmrOZ/jE7TuyYYTOjpyqG+5cIiuGUVZmoohyBVbEcOl94MybMa48KLcQv xT4dujNFlWhZxIwjxlNxo1apprslH/7y85G9lzL4QGfJk1/4I2Y37KQFbJPbwLvWv9VX vyB2iRiYakftRHfVsSkjL3UxXR6H3lz47VNjS6sYrba28veXzbcYycZRBgnGvZj5D4DC fAXQ== 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:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=RCqWMJLhV6iXiOtIBWSp2lh35vHg74VJNJaPY815HRQ=; b=Df6b0Onk1RB2N4Vf5ezhBbbZOWx97ltit/WByXeFAmCR/j9A9cn4nQgbE+jpH1VEu3 nU6GLrLkcm+gJtO4jLLj1jqa9G0bcli9v62PTHtMc/+ejS7nZFM9gOOr8c3JFoEkGOiL VLt8+w3YLk+eRaS3aviLzeC/f9/A4alKsj7iT8Nx1esDjrgNbLWqwKf0WU1wyObs89qJ Rh234ZRSXBQEH1HJU2H8l52ay2GlGfh464IyKwqY6lwcsKLUUOaJ8IWztE0AMfBhJxMM 3LBBfnCId82wuWsbwm7xSyZFR/n8eYDgH+J6s7dvlq5ZTXwi4DJh5DxFAOuSUAqDcbJE WfrQ== X-Gm-Message-State: APjAAAWbDK/ZcM/lbQ5Aa9To10O2CLfWcCMSMlMkeFOJYBDXR3GipFhl nmC1BlWy6+kgJE11PrB0Mz0d5A== X-Google-Smtp-Source: APXvYqxTrf9Er5sD+O/iYPxsAjnjNn9ARyZdOsADx8ll362sYMy4UGZ0fm7gtu8rZ2fKLffw5hsWNw== X-Received: by 2002:ac8:152:: with SMTP id f18mr108381363qtg.84.1561053660868; Thu, 20 Jun 2019 11:01:00 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([177.154.139.195]) by smtp.gmail.com with ESMTPSA id o22sm165838qkk.50.2019.06.20.11.01.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 11:01:00 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id D0A0B121ADA; Thu, 20 Jun 2019 14:00:56 -0400 (-04) Date: Thu, 20 Jun 2019 14:00:56 -0400 From: Alvaro Herrera To: "Rozboril, Robert" Cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: PostgreSQL v11.3 - Records are deleted from child table if partition key of parent table is changed Message-ID: <20190620180056.GA25386@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Jun-20, Rozboril, Robert wrote: > ALTER TABLE polf ADD CONSTRAINT polf_po_id_fk FOREIGN KEY (po_id) REFERENCES pof(po_id) ON DELETE CASCADE; > ALTER TABLE polt ADD CONSTRAINT polt_po_id_fk FOREIGN KEY (po_id) REFERENCES pot(po_id) ON DELETE CASCADE; Hmm, yeah, I wouldn't expect this to work well -- the UPDATEs done by the cascade action would not see that there is another partition. If you were declaring the PK and FK constraints on the parent tablej, it should work correctly: ALTER TABLE pol ADD CONSTRAINT pol_pkey PRIMARY KEY (pol_id); ALTER TABLE pol ADD CONSTRAINT pol_po_id_fk FOREIGN KEY (po_id) REFERENCES po(po_id) ON DELETE CASCADE; (similarly for the "po" table). -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services