Re: New "single" COPY format

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "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-09 19:29:01
Message-ID: fbc63db8-94de-45f6-b327-50456630264d@app.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 9, 2024, at 15:13, David G. Johnston wrote:
> On Saturday, November 9, 2024, Joel Jacobson <joel(at)compiler(dot)org> wrote:
>> On Sat, Nov 9, 2024, at 08:07, Joel Jacobson wrote:
>> > Here's a draft of an idea I'm considering (not yet implemented):
>>
>> I realize the last part about optional quoting is unnecessary,
>> since if quoting is desired, users could just use the 'csv' format.
>>
>> Revised draft of the idea (not yet implemented):
>>
>> - Fast path for newline-free types:
>> For the list of built-in types where we know the ::text representation cannot
>> contain newlines, we take the fast path in NextCopyFromRawFields(),
>> pointing cstate->raw_fields[0] directly to cstate->line_buf.data.

Ops, the above should of course have said:
"we take the fast path in CopyAttributeOutList()".

>> - Handling newlines for other types:
>> For any other types, we would need to scan the string for newline characters.
>> If a newline is encountered, it results in an error.
>
> Make sense to me.

Cool. I've drafted a new patch on this approach.
The list of newline-free built-in types is not exhaustive, yet.

/Joel

Attachment Content-Type Size
v20-0001-Introduce-CopyFormat-and-replace-csv_mode-and-binary.patch application/octet-stream 18.8 KB
v20-0002-Add-COPY-format-list.patch application/octet-stream 35.0 KB
v20-0003-Reorganize-option-validations.patch application/octet-stream 19.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2024-11-09 20:48:07 Re: New "single" COPY format
Previous Message Peter Geoghegan 2024-11-09 18:46:45 Re: Showing primitive index scan count in EXPLAIN ANALYZE (for skip scan and SAOP scans)