Re: Parameter binding for COPY TO queries - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Parameter binding for COPY TO queries
Date
Msg-id s45xxcatvkl3blte4jcaorrke6saddqamfuls4impcvhc3jnz7@kdewpeudwkik
Whole thread Raw
In response to Re: Parameter binding for COPY TO queries  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Parameter binding for COPY TO queries
List pgsql-hackers
Hi,

On 2025-02-14 10:06:13 -0500, Tom Lane wrote:
> None of those arguments apply to the sub-SELECT of a "COPY (query) TO"
> command, but there's a practical matter of how to get the parameters
> passed through the COPY to the sub-SELECT without opening Pandora's
> box for every other kind of utility statement.

I think there's already precedent - CREATE TABLE AS does accept parameters
today, and it's a utility command too:

DROP TABLE IF EXISTS foo;
CREATE TABLE foo AS SELECT $1 as a, $2 as b \bind fooval, barval \g \d foo

Is there anything stopping us from implementing COPY along the same lines as
CTAS?  There's some special case code for it, but it seems within reason,
unless we want to make dozens of commands accepting parameters...

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [Feature Request] INSERT FROZEN to Optimize Large Cold Data Imports and Migrations
Next
From: Daniel Gustafsson
Date:
Subject: Re: New buildfarm animals with FIPS mode enabled