Re: Which hook to use when overriding utility commands (COPY ...)

2022-03-19 Thread Michael Paquier
On Sat, Mar 19, 2022 at 12:28:46PM +0100, Hannu Krosing wrote:
> Which hook should I use when overriding the COPY command in an extension?

CopyStmt goes through ProcessUtility(), so you can use the hook called
ProcessUtility_hook to override what you want.
--
Michael


signature.asc
Description: PGP signature


Which hook to use when overriding utility commands (COPY ...)

2022-03-19 Thread Hannu Krosing
Hi Pgsql-Hackers

Which hook should I use when overriding the COPY command in an extension?

I am working on adding new functionalities to COPY (compression, index
management, various other transports in addition to stdin and file, other
data formats, etc...) and while the aim is to contribute this to v15 I
would also like to have much of it in earlier versions.

As the current policy is to back-port only bugfixes and not "features" ,
the only way I can see to get it in earlier versions is to provide an
extension which intercepts the COPY command and replaces it with my own
implementation.

So my question is, which of the hooks would be easiest to use for this ?

At the syntax level it would still look the same COPY ... FROM/TO ... WITH
( options) and the extensibility will be in file names (using a URI scheme
mapped to transports) and in options part.
so I hope to fully reuse the parsing part and get in before the existence
checks.

Does anyone have experience in this and can [point to samples?

Cheers
Hannu