Re: Make COPY format extendable: Extract COPY TO format implementations

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Sutou Kouhei <kou(at)clear-code(dot)com>, sawada(dot)mshk(at)gmail(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us, zhjwpku(at)gmail(dot)com, michael(at)paquier(dot)xyz, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Make COPY format extendable: Extract COPY TO format implementations
Date: 2025-04-06 16:20:56
Message-ID: CAKFQuwZbD_=-Htfv1CjuhcXjTtG-xdCYrjUa4Yi7tVHEHnhorA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Apr 6, 2025 at 4:30 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:

>
> CREATE FUNCTION test_copy_format(internal)
> RETURNS copy_handler
> AS 'MODULE_PATHNAME', 'test_copy_format'
> LANGUAGE C;
> src/backend/commands/copy.c: ProcessCopyOptions
> if (strcmp(fmt, "text") == 0)
> /* default format */ ;
> else if (strcmp(fmt, "csv") == 0)
> opts_out->csv_mode = true;
> else if (strcmp(fmt, "binary") == 0)
> opts_out->binary = true;
> else
> {
> List *qualified_format;
> ....
> }
> what if our customized format name is one of "csv", "binary", "text",
> then that ELSE branch will never be reached.
> then our customized format is being shadowed?
>
>
Yes. The user of your extension can specify a schema name to get access to
your conflicting format name choice but all the existing code out there
that relied on text/csv/binary being the built-in options continue to
behave the same no matter the search_path.

David J.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2025-04-06 16:46:36 Re: Removing unneeded self joins
Previous Message Mahendra Singh Thalor 2025-04-06 16:10:58 Re: getting "shell command argument contains a newline or carriage return:" error with pg_dumpall when db name have new line in double quote