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 1jQvdk-0000Pj-BR for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Apr 2020 16:20:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jQvdh-0006Vp-L4 for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Apr 2020 16:20:49 +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 1jQvdh-0006Vg-B9 for pgsql-hackers@lists.postgresql.org; Tue, 21 Apr 2020 16:20:49 +0000 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jQvdc-000728-Ks for pgsql-hackers@lists.postgresql.org; Tue, 21 Apr 2020 16:20:48 +0000 Received: by mail-qk1-x744.google.com with SMTP id b62so15106999qkf.6 for ; Tue, 21 Apr 2020 09:20:44 -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=48lbOBPC2eKm8CGbAPpfyghP7M/Mc7x5P3YvGaVY+Ok=; b=agjX0vPYmyme05ZHh6qShnuCbnwMxh5TzJcf4z/NDfHyKYH9oCYnMSRjWJWD9rY0MU DyOmaQYk7t4SysDVE010Kv4CWUXVJ/UbkX/paJhXiZOXz+DzyoR7qzx51hSrQlsl5DZ/ C3khs8TUCamPJnGLrYGk8gM23SPxQLl8bfqliHcHe6B3EWgJ1nIjfw7NxXpTkzp5G9sT ZlkFbGi9i4g88iMtFSHGzUMTgmCiQjT4cRwbEHHBe0SpBKN17C5qAyIfsxzwoYql/OJ2 cMAW66nW2PDQRseyrXFX3HPiEtyEG7YxwaTqPNBYvsoQ+6L1p6B+EQfCrlNsLl0F/JBx phgw== 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=48lbOBPC2eKm8CGbAPpfyghP7M/Mc7x5P3YvGaVY+Ok=; b=t4QR3wfKJ2Tg/ahe88FneS5dxWFKUx20ZYut1UPCYpd0HY0cPRskM669J0Obicx6B2 iLTkxufNgszrt6aAGgqAkRRHDZPgg0YNdWZuxHhgC0EKxMXLEtuumduhOWtiZGzLiBqD sqXRBWUk9MSmXkxEtcz8b6M9U03NfT/U0j5wVGhLjWcvi84irhqKlr5anxH8Ww58K1sz icrJZRCK+WslVDYFOKJ9yutZKZS/DwSSO9daVwPd7dGaYCbv3MTUHI8OkR6FWBfJITji avms5bu2Wjugds9051xlCvebdvMNRWb2JMEki4RouI6hu+GQaODgyNafvGbIsjgcXyE/ GZBA== X-Gm-Message-State: AGi0PuZtOfU1hEyGSxDYGWde4VT43SWY1jUMSqlrMT+d+k1ztrTjdWMj cYh5Vt/AXv6qo6LQBnguNnv66Q== X-Google-Smtp-Source: APiQypK2yAEt07/ZecuY9jKvV1BEZl5KJ84RKvqhCwqPmZECTLXzZ6X9Xlp5Uajw/uAYGCVzZ8CTSw== X-Received: by 2002:a37:d0a:: with SMTP id 10mr21837419qkn.288.1587486043241; Tue, 21 Apr 2020 09:20:43 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id m12sm2035789qki.75.2020.04.21.09.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 09:20:42 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 8DFB2301985; Tue, 21 Apr 2020 12:20:38 -0400 (-04) Date: Tue, 21 Apr 2020 12:20:38 -0400 From: Alvaro Herrera To: Justin Pryzby Cc: Amit Langote , Tom Lane , PostgreSQL Hackers Subject: Re: DETACH PARTITION and FOR EACH ROW triggers on partitioned tables Message-ID: <20200421162038.GA18628@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="WIyZ46R2i8wDzkSu" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200421154553.GA21155@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 --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit I think I also owe the attached doc updates. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --WIyZ46R2i8wDzkSu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="doc.patch" diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 7595e609b5..233905552c 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -869,13 +869,15 @@ WITH ( MODULUS numeric_literal, REM one will be created in the attached table; or, if an equivalent index already exists, it will be attached to the target table's index, as if ALTER INDEX ATTACH PARTITION had been executed. Note that if the existing table is a foreign table, it is currently not allowed to attach the table as a partition of the target table if there are UNIQUE indexes on the target table. (See also - .) + .) For each user-defined + row-level trigger that exists in the target table, a corresponding one + is created in the attached table. A partition using FOR VALUES uses same syntax for partition_bound_spec as . The partition bound specification @@ -941,13 +943,14 @@ WITH ( MODULUS numeric_literal, REM DETACH PARTITION partition_name This form detaches specified partition of the target table. The detached partition continues to exist as a standalone table, but no longer has any ties to the table from which it was detached. Any indexes that were - attached to the target table's indexes are detached. + attached to the target table's indexes are detached. Any triggers that + were created to mirror those in the target table are removed. diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 155866c7c8..c49c770dd0 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -396,13 +396,15 @@ WITH ( MODULUS numeric_literal, REM PARTITION OF parent_table { FOR VALUES partition_bound_spec | DEFAULT } Creates the table as a partition of the specified parent table. The table can be created either as a partition for specific values using FOR VALUES or as a default partition - using DEFAULT. + using DEFAULT. Any indexes, constraints and + user-defined row-level triggers that exist in the parent table are cloned + on the new partition. The partition_bound_spec must correspond to the partitioning method and partition key of the parent table, and must not overlap with any existing partition of that --WIyZ46R2i8wDzkSu--