public inbox for [email protected]  
help / color / mirror / Atom feed
From: Daniel Gustafsson <[email protected]>
To: Tom Lane <[email protected]>
Cc: Fujii Masao <[email protected]>
Cc: [email protected]
Cc: [email protected]
Subject: Re: Missing File weather.txt
Date: Fri, 11 Jul 2025 00:22:55 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>

> On 5 Jul 2025, at 19:29, Tom Lane <[email protected]> wrote:
> 
> Fujii Masao <[email protected]> writes:
>> On 2020/01/28 19:18, Daniel Gustafsson wrote:
>>> This is only mentioned as an example of another input method, with a link to
>>> the COPY page for more information.  That being said, it's a good thing for a
>>> tutorial to be self-contained, and going from a basic tutorial to the COPY
>>> reference page is a fairly large step.  I propose that we add a small example
>>> on what weather.txt could look like as per the attached diff.
> 
>> Sorry for reviving this old thread, but I wanted to follow up since
>> the same issue was reported again in [1], and the proposed patch
>> basically looks good to me.
> 
> +1
> 
>> In the tutorial, three rows are inserted using INSERT, so shouldn't
>> the sample input for COPY include all three, like this?
> 
> Agreed, the example file should match what the tutorial expects to be
> in the table.  I'd include text along the lines of "The data inserted
> above could also be inserted from a file containing:".

The attached v2 adds the missing line, and tweaks the text added to document
the file.  Since there have been reports I propose backpatching this all the
way down to 13 while at it.

--
Daniel Gustafsson



Attachments:

  [application/octet-stream] v2-0001-doc-Add-example-file-for-COPY.patch (1.8K, 2-v2-0001-doc-Add-example-file-for-COPY.patch)
  download | inline diff:
From 5d45c8cd7fefab10670d91d9f541001b4631d1a0 Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <[email protected]>
Date: Fri, 11 Jul 2025 00:03:57 +0200
Subject: [PATCH v2] doc: Add example file for COPY

The paragraph for introducing INSERT and COPY discussed how a file
could be used for bulk loading with COPY, without actually showing
what the file would look like.  This adds a programlisting for the
file contents.

Backpatch to all supported branches since this example has lacked
the file contents since PostgreSQL 7.2.

Author: Daniel Gustafsson <[email protected]>
Reported-by: [email protected]
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 13
---
 doc/src/sgml/query.sgml | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/doc/src/sgml/query.sgml b/doc/src/sgml/query.sgml
index 727a0cb185f..b1770bb782d 100644
--- a/doc/src/sgml/query.sgml
+++ b/doc/src/sgml/query.sgml
@@ -264,8 +264,18 @@ COPY weather FROM '/home/user/weather.txt';
 
     where the file name for the source file must be available on the
     machine running the backend process, not the client, since the backend process
-    reads the file directly.  You can read more about the
-    <command>COPY</command> command in <xref linkend="sql-copy"/>.
+    reads the file directly.  The data inserted above into the weather table
+    could also be inserted from a file containing (note that the white space
+    on each line is actually a tab character):
+
+<programlisting>
+San Francisco    46    50    0.25    1994-11-27
+San Francisco    43    57    0.0    1994-11-29
+Hayward    37    54    0.0    1994-11-29
+</programlisting>
+
+    You can read more about the <command>COPY</command> command in
+    <xref linkend="sql-copy"/>.
    </para>
   </sect1>
 
-- 
2.39.3 (Apple Git-146)



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Missing File weather.txt
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox