Re: New "raw" COPY format

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: New "raw" COPY format
Date: 2024-10-11 21:01:10
Message-ID: 24b04d63-b44c-470f-80b2-addb7d9ff536@app.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 11, 2024, at 22:29, Joel Jacobson wrote:
> Hi hackers,
>
> This thread is about implementing a new "raw" COPY format.
...
> The attached patch implements the above ideas.
>
> I think with these changes, it would be easier to hack on new and existing
> copy options and formats.
>
> /Joel
>
> Attachments:
> * v1-0001-Replace-binary-flags-binary-and-csv_mode-with-format.patch
> * v1-0002-Reorganize-ProcessCopyOptions-for-clarity-and-consis.patch

Ops, I see I failed to use the correct way to check if
opts_out->force_notnull or opts_out->force_null
have been set, that is using != NIL.

However, thanks to not just blindly copy/pasting this code,
I see I actually fixed a bug in HEAD, by also checking
opts_out->force_notnull_all or opts_out->force_null_all,
which HEAD currently fails to do:

joel=# copy t to '/tmp/t.csv' (format text, FORCE_NOT_NULL (c1));
ERROR: COPY FORCE_NOT_NULL requires CSV mode
joel=# copy t to '/tmp/t.csv' (format text, FORCE_NOT_NULL *);
COPY 0
joel=# copy t to '/tmp/t.csv' (format text, FORCE_NULL (c1));
ERROR: COPY FORCE_NULL requires CSV mode
joel=# copy t to '/tmp/t.csv' (format text, FORCE_NULL *);
COPY 0

Fixed in new version:

joel=# copy t to '/tmp/t.csv' (format text, FORCE_NOT_NULL *);
ERROR: COPY FORCE_NOT_NULL requires CSV mode
joel=# copy t to '/tmp/t.csv' (format text, FORCE_NULL *);
ERROR: COPY FORCE_NULL requires CSV mode

/Joel

Attachment Content-Type Size
v2-0001-Replace-binary-flags-binary-and-csv_mode-with-format.patch application/octet-stream 18.0 KB
v2-0002-Reorganize-ProcessCopyOptions-for-clarity-and-consis.patch application/octet-stream 19.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2024-10-11 21:20:43 Re: [PATCH] Avoid mixing custom and OpenSSL BIO functions
Previous Message Joel Jacobson 2024-10-11 20:29:15 New "raw" COPY format