From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Joel Jacobson <joel(at)compiler(dot)org> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Daniel Verite <daniel(at)manitou-mail(dot)org>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: New "single" COPY format |
Date: | 2024-11-10 04:26:21 |
Message-ID: | CACJufxHWUWddXr=EsV3ZUrpwLZy8weTHJjeiQDtaizHPRoq3oQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, Nov 10, 2024 at 3:29 AM Joel Jacobson <joel(at)compiler(dot)org> wrote:
>
> Cool. I've drafted a new patch on this approach.
> The list of newline-free built-in types is not exhaustive, yet.
do we care that COPY back and forth always work?
doc not mentioned, but seems it's an implicit idea.
copy the_table to '/tmp/3.txt' with (format whatever_format);
truncate the_table;
copy the_table from '/tmp/3.txt' with (format whatever_format);
but v20, will not work for an non-text column with SQL NULL data in it.
example:
drop table if exists x1;
create table x1(a int);
insert into x1 select null;
copy x1 to '/tmp/3.txt' with (format list);
copy x1 from '/tmp/3.txt' with (format list);
ERROR: invalid input syntax for type integer: ""
CONTEXT: COPY x1, line 1, column a: ""
<para>
The <literal>list</literal> format does not distinguish a
<literal>NULL</literal>
value from an empty string. Empty lines are imported as empty strings, not
as <literal>NULL</literal> values.
</para>
we only mentioned import, not export (COPY TO) dealing with
NULL value.
+ if (c == '\n' || c == '\r')
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("list format doesn't support newlines in field values"),
+ errhint("Consider using csv or text format for data containing newlines.")));
"list format doesn't support newlines in field values"
word list need single or double quote?
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("Unsupported COPY format")));
should be "unsupported" per
https://www.postgresql.org/docs/current/error-style-guide.html#ERROR-STYLE-GUIDE-CASE
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2024-11-10 04:55:15 | Re: New "single" COPY format |
Previous Message | Amit Kapila | 2024-11-10 03:16:37 | Re: Virtual generated columns |