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 1kpKZ1-0004L8-8A for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Dec 2020 00:21:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kpKYx-0000Ne-CW for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Dec 2020 00:21: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 1kpKYx-0000NT-5V for pgsql-hackers@lists.postgresql.org; Wed, 16 Dec 2020 00:21:03 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kpKYu-0004AL-U8 for pgsql-hackers@lists.postgresql.org; Wed, 16 Dec 2020 00:21:02 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1kpKYt-0004rr-TV; Tue, 15 Dec 2020 19:20:59 -0500 Date: Tue, 15 Dec 2020 19:20:59 -0500 From: Bruce Momjian To: Justin Pryzby Cc: pgsql-hackers@lists.postgresql.org Subject: Re: copy.sgml and partitioned tables Message-ID: <20201216002059.GD14807@momjian.us> References: <20201203211723.GR24052@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="kXdP64Ggrk/fb43R" Content-Disposition: inline In-Reply-To: <20201203211723.GR24052@telsasoft.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --kXdP64Ggrk/fb43R Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Dec 3, 2020 at 03:17:23PM -0600, Justin Pryzby wrote: > https://www.postgresql.org/docs/current/sql-copy.html > |. COPY FROM can be used with plain, foreign, or partitioned tables or with views that have INSTEAD OF INSERT triggers. > |. COPY only deals with the specific table named; IT DOES NOT COPY DATA TO OR FROM CHILD TABLES. ... > > That language in commit 854b5eb51 was never updated since partitioning was > added, so I propose this. > > I'm not sure, but maybe it should still say that "COPY TO does not copy data to > child tables of inheritance hierarchies." I reworded it slightly, attached, and applied it back to PG 10, where we added the partition syntax. -- Bruce Momjian https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee --kXdP64Ggrk/fb43R Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="master.diff" diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml index 369342b74d..0fca6583af 100644 --- a/doc/src/sgml/ref/copy.sgml +++ b/doc/src/sgml/ref/copy.sgml @@ -413,10 +413,16 @@ COPY count Notes - COPY TO can only be used with plain tables, not - with views. However, you can write COPY (SELECT * FROM - viewname) TO ... - to copy the current contents of a view. + COPY TO can be used only with plain + tables, not views, and does not copy rows from child tables + or child partitions. For example, COPY table TO copies + the same rows as SELECT * FROM ONLY table. + The syntax COPY (SELECT * FROM table) TO ... can be used to + dump all of the rows in an inheritance hierarchy, partitioned table, + or view. @@ -425,16 +431,6 @@ COPY count INSTEAD OF INSERT triggers. - - COPY only deals with the specific table named; - it does not copy data to or from child tables. Thus for example - COPY table TO - shows the same data as SELECT * FROM ONLY table. But COPY - (SELECT * FROM table) TO ... - can be used to dump all of the data in an inheritance hierarchy. - - You must have select privilege on the table whose values are read by COPY TO, and --kXdP64Ggrk/fb43R--