pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedcopy.sgml and partitioned tables
2+ messages / 2 participants
[nested] [flat]
Commits from this thread:
2020-12-16 9595b06ef7 f32c687355 48cbed8821 de7b034daf 02c767b0fe doc: clarify COPY TO for partitioning/inheritance
* copy.sgml and partitioned tables
@ 2020-12-03 21:17 Justin Pryzby <pryzby@telsasoft.com>
2020-12-16 00:20 ` Re: copy.sgml and partitioned tables Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 2+ messages in thread
From: Justin Pryzby @ 2020-12-03 21:17 UTC (permalink / raw)
To: pgsql-hackers@lists.postgresql.org
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."
inline patch 1: doc/src/sgml/ref/copy.sgml (+8/-13 lines) download inline-1.patch
diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml
index 369342b74d..0631dfe6b3 100644
--- a/doc/src/sgml/ref/copy.sgml
+++ b/doc/src/sgml/ref/copy.sgml
@@ -414,9 +414,14 @@ COPY <replaceable class="parameter">count</replaceable>
<para>
<command>COPY TO</command> can only be used with plain tables, not
- with views. However, you can write <literal>COPY (SELECT * FROM
- <replaceable class="parameter">viewname</replaceable>) TO ...</literal>
- to copy the current contents of a view.
+ views, and does not copy data from child tables or partitions.
+ Thus for example
+ <literal>COPY <replaceable class="parameter">table</replaceable> TO</literal>
+ shows the same data as <literal>SELECT * FROM ONLY <replaceable
+ class="parameter">table</replaceable></literal>. But <literal>COPY
+ (SELECT * FROM <replaceable class="parameter">table</replaceable>) TO ...</literal>
+ can be used to dump all of the data in an inheritance hierarchy,
+ partitioned table, or view.
</para>
<para>
@@ -425,16 +430,6 @@ COPY <replaceable class="parameter">count</replaceable>
<literal>INSTEAD OF INSERT</literal> triggers.
</para>
- <para>
- <command>COPY</command> only deals with the specific table named;
- it does not copy data to or from child tables. Thus for example
- <literal>COPY <replaceable class="parameter">table</replaceable> TO</literal>
- shows the same data as <literal>SELECT * FROM ONLY <replaceable
- class="parameter">table</replaceable></literal>. But <literal>COPY
- (SELECT * FROM <replaceable class="parameter">table</replaceable>) TO ...</literal>
- can be used to dump all of the data in an inheritance hierarchy.
- </para>
-
<para>
You must have select privilege on the table
whose values are read by <command>COPY TO</command>, and
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: copy.sgml and partitioned tables
2020-12-03 21:17 copy.sgml and partitioned tables Justin Pryzby <pryzby@telsasoft.com>
@ 2020-12-16 00:20 ` Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 2+ messages in thread
From: Bruce Momjian @ 2020-12-16 00:20 UTC (permalink / raw)
To: Justin Pryzby <pryzby@telsasoft.com>; +Cc: pgsql-hackers@lists.postgresql.org
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 <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
Attachments:
master.diff (text/x-diff, 1.9K) download
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 <replaceable class="parameter">count</replaceable>
<title>Notes</title>
<para>
- <command>COPY TO</command> can only be used with plain tables, not
- with views. However, you can write <literal>COPY (SELECT * FROM
- <replaceable class="parameter">viewname</replaceable>) TO ...</literal>
- to copy the current contents of a view.
+ <command>COPY TO</command> can be used only with plain
+ tables, not views, and does not copy rows from child tables
+ or child partitions. For example, <literal>COPY <replaceable
+ class="parameter">table</replaceable> TO</literal> copies
+ the same rows as <literal>SELECT * FROM ONLY <replaceable
+ class="parameter">table</replaceable></literal>.
+ The syntax <literal>COPY (SELECT * FROM <replaceable
+ class="parameter">table</replaceable>) TO ...</literal> can be used to
+ dump all of the rows in an inheritance hierarchy, partitioned table,
+ or view.
</para>
<para>
@@ -425,16 +431,6 @@ COPY <replaceable class="parameter">count</replaceable>
<literal>INSTEAD OF INSERT</literal> triggers.
</para>
- <para>
- <command>COPY</command> only deals with the specific table named;
- it does not copy data to or from child tables. Thus for example
- <literal>COPY <replaceable class="parameter">table</replaceable> TO</literal>
- shows the same data as <literal>SELECT * FROM ONLY <replaceable
- class="parameter">table</replaceable></literal>. But <literal>COPY
- (SELECT * FROM <replaceable class="parameter">table</replaceable>) TO ...</literal>
- can be used to dump all of the data in an inheritance hierarchy.
- </para>
-
<para>
You must have select privilege on the table
whose values are read by <command>COPY TO</command>, and
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2020-12-16 00:20 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 21:17 copy.sgml and partitioned tables Justin Pryzby <pryzby@telsasoft.com>
2020-12-16 00:20 ` Bruce Momjian <bruce@momjian.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox