diff options
author | Michael Paquier <michael@paquier.xyz> | 2022-10-11 11:45:52 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2022-10-11 11:45:52 +0900 |
commit | 9fcdf2c787ac6da330165ea3cd50ec5155943a2b (patch) | |
tree | 6e376c7b1258238403feb61da7fc90815d803258 /src/include/commands/copy.h | |
parent | 0e87dfe46443286e630e9bcbc0c39a39c2c2cbb2 (diff) |
Add support for COPY TO callback functions
This is useful as a way for extensions to process COPY TO rows in the
way they see fit (say auditing, analytics, backend, etc.) without the
need to invoke an external process running as the OS user running the
backend through PROGRAM that requires superuser rights. COPY FROM
already provides a similar callback for logical replication. For COPY
TO, the callback is triggered when we are ready to send a row in
CopySendEndOfRow(), which is the same code path as when sending a row
to a frontend or a pipe/file.
A small test module, test_copy_callbacks, is added to provide some
coverage for this facility.
Author: Bilva Sanaba, Nathan Bossart
Discussion: https://postgr.es/m/253C21D1-FCEB-41D9-A2AF-E6517015B7D7@amazon.com
Diffstat (limited to 'src/include/commands/copy.h')
-rw-r--r-- | src/include/commands/copy.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/include/commands/copy.h b/src/include/commands/copy.h index 3f6677b1327..b77b9350058 100644 --- a/src/include/commands/copy.h +++ b/src/include/commands/copy.h @@ -66,6 +66,7 @@ typedef struct CopyFromStateData *CopyFromState; typedef struct CopyToStateData *CopyToState; typedef int (*copy_data_source_cb) (void *outbuf, int minread, int maxread); +typedef void (*copy_data_dest_cb) (void *data, int len); extern void DoCopy(ParseState *pstate, const CopyStmt *stmt, int stmt_location, int stmt_len, @@ -91,7 +92,7 @@ extern DestReceiver *CreateCopyDestReceiver(void); */ extern CopyToState BeginCopyTo(ParseState *pstate, Relation rel, RawStmt *raw_query, Oid queryRelId, const char *filename, bool is_program, - List *attnamelist, List *options); + copy_data_dest_cb data_dest_cb, List *attnamelist, List *options); extern void EndCopyTo(CopyToState cstate); extern uint64 DoCopyTo(CopyToState cstate); extern List *CopyGetAttnums(TupleDesc tupDesc, Relation rel, |