From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org> |
Cc: | Israel Barth Rubio <barthisrael(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Add support for DEFAULT specification in COPY FROM |
Date: | 2022-08-18 15:01:48 |
Message-ID: | 27bb3f48-137a-1ddb-4ec7-a832f420e076@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2022-08-18 Th 05:55, Dagfinn Ilmari Mannsåker wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>
>> On 2022-08-16 Tu 14:12, Israel Barth Rubio wrote:
>>> Hello all,
>>>
>>> With the current implementation of COPY FROM in PostgreSQL we are
>>> able to load the DEFAULT value/expression of a column if the column
>>> is absent in the list of specified columns. We are not able to
>>> explicitly ask that PostgreSQL uses the DEFAULT value/expression in a
>>> column that is being fetched from the input file, though.
>>>
>>> This patch adds support for handling DEFAULT values in COPY FROM. It
>>> works similarly to NULL in COPY FROM: whenever the marker that was
>>> set for DEFAULT value/expression is read from the input stream, it
>>> will evaluate the DEFAULT value/expression of the corresponding
>>> column.
> […]
>> Interesting, and probably useful. I've only had a brief look, but it's
>> important that the default marker not be quoted in CSV mode (c.f. NULL)
>> -f it is it should be taken as a literal rather than a special value.
> For the NULL marker that can be overridden for individual columns with
> the FORCE(_NOT)_NULL option. This feature should have a similar
> FORCE(_NOT)_DEFAULT option to allow the DEFAULT marker to be ignored, or
> recognised even when quoted, respectively.
>
That seems to be over-egging the pudding somewhat. FORCE_NOT_DEFAULT
should not be necessary at all, since here if there's no default
specified nothing will be taken as the default. I suppose a quoted
default is just faintly possible, but I'd like a concrete example of a
producer that emitted it.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-08-18 15:04:03 | Another dead configure test |
Previous Message | Laurenz Albe | 2022-08-18 15:00:52 | Re: cataloguing NOT NULL constraints |