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 1izpHC-0003Sb-Bh for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Feb 2020 22:05:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1izpHA-0003oG-Vf for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Feb 2020 22:05:32 +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 1izpHA-0003gQ-N7 for pgsql-bugs@lists.postgresql.org; Thu, 06 Feb 2020 22:05:32 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1izpH7-00061O-RX for pgsql-bugs@lists.postgresql.org; Thu, 06 Feb 2020 22:05:31 +0000 Received: by mail-qt1-x841.google.com with SMTP id t13so363105qto.3 for ; Thu, 06 Feb 2020 14:05:29 -0800 (PST) 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=2JSpqb18MmEQl3VTHCM9Bcn9MIJ+WH5bHX7vZ8HKEto=; b=cvkJR0vpoPDutIgmFOW/4WOHT9RvTnvMvJOfdGqj0tzPiFPVwWbioHaPLAHv6kvJbx 4nXHdKNZg6MmV5yozjtz30IxblDIu6oIn+cpcH6WgMECeAcK+fGB2f/66hCCsw0FLi6L AzTWzqCSQYPEDHKS4mCgnGcMS/NHHkEcPyOh/69GCemMs548bTUiI9kt3oYZkp6XA4Sq m+Mc7+ZmPbXfhU0cj+sVUe3l7Y4e4W3HwbGhi65jOGhq0MQ/4q0qGW1Br0pnPLWIB3UB 0KAUhEyPfUanFcYSB6gqiHWS6VCZ9fNTrsy0hs46xOmeNIoKLuiCsh+//4XsWHv/UjOh gkrw== 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=2JSpqb18MmEQl3VTHCM9Bcn9MIJ+WH5bHX7vZ8HKEto=; b=LUSo8hV85wuKrijDhr83hXJ9kSSTzfPe4uSlB6/Jdn7Mje5uSCbnzYleZtZQF50OpK k3BTySpMXLTnxsRnz2X3eC03V9DNjTEINPCbFoIha4mfct5m7dEYp7TuPagbyomITiRl zVsrZk1jdyFXjDnBjooYd6USe3lJigoWar86ZpuDSfhgLQqVanUiPZu32HJ22N4bTb2O 4OVR0jctsfAmbN6PLw2dEEDfwRS7nZqbAMkljt64k5KwqxZonMApkqxFlxbZmFMY9Z1c 8yd5tof/KNX7h6Mfrx8H1QyOChqSmaHHnpu88hlZXOUq1Jt9x6akO0dBnxAtt42IXVmD ehCg== X-Gm-Message-State: APjAAAXcrdSoUSBXQi0Fgnu28ySfAAryizOANsQp2Da5vODNAxjaMKNu yX7zz3c+GBpKGiOc0o0gsNlVYrtixzw= X-Google-Smtp-Source: APXvYqyfX/zyWZdLrqohvyLGLJ6jmdG0oTjMau6OD25tWcQiOv0rXY2r/jvRcaligsWmUmzwO/geCw== X-Received: by 2002:ac8:75d8:: with SMTP id z24mr4626308qtq.193.1581026727840; Thu, 06 Feb 2020 14:05:27 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([179.56.50.157]) by smtp.gmail.com with ESMTPSA id c18sm338410qkk.5.2020.02.06.14.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2020 14:05:27 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 1007F300807; Thu, 6 Feb 2020 19:05:25 -0300 (-03) Date: Thu, 6 Feb 2020 19:05:25 -0300 From: Alvaro Herrera To: Jehan-Guillaume de Rorthais Cc: pgsql-bugs@lists.postgresql.org Subject: Re: FK violation in partitioned table after truncating a referenced partition Message-ID: <20200206220525.GA31831@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="5mCyUwZo2JvN/JJP" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200206220005.GA31399@alvherre.pgsql> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --5mCyUwZo2JvN/JJP Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2020-Feb-06, Alvaro Herrera wrote: > Also, I think we should patch the documentation like this, because this > effect is not 100% obvious. (For example, if the partition strategy is > identical in both referenced and referencing tables, you would wish that > only the equivalent partition is truncated. However, I doubt this can > be really implemented.) And of course, I forgot to attach the file. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --5mCyUwZo2JvN/JJP Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="truncate-docs.patch" diff --git a/doc/src/sgml/ref/truncate.sgml b/doc/src/sgml/ref/truncate.sgml index c1e42376ab..0895fd17eb 100644 --- a/doc/src/sgml/ref/truncate.sgml +++ b/doc/src/sgml/ref/truncate.sgml @@ -123,7 +123,9 @@ TRUNCATE [ TABLE ] [ ONLY ] name [ scans, and the whole point is not to do one. The CASCADE option can be used to automatically include all dependent tables — but be very careful when using this option, or else you might lose data you - did not intend to! + did not intend to! Note in particular that when the table to be truncated + is a partition, cascading occurs as if the parent partitioned table is + truncated. --5mCyUwZo2JvN/JJP--