Skip to content

Commit

Permalink
Add CopyToState{Get,Set}Opaque()
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Dec 21, 2023
1 parent 3216c9b commit 5a610b6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/backend/commands/copyto.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ typedef struct CopyToStateData
FmgrInfo *out_functions; /* lookup info for output functions */
MemoryContext rowcontext; /* per-row evaluation context */
uint64 bytes_processed; /* number of bytes processed so far */

/* For custom format implementation */
void *opaque; /* private space */
} CopyToStateData;

/* DestReceiver for COPY (query) TO */
Expand Down Expand Up @@ -131,6 +134,20 @@ static void CopySendEndOfRow(CopyToState cstate);
static void CopySendInt32(CopyToState cstate, int32 val);
static void CopySendInt16(CopyToState cstate, int16 val);

/* Exported functions that are used by custom format routines. */

/* TODO: Document */
void *CopyToStateGetOpaque(CopyToState cstate)
{
return cstate->opaque;
}

/* TODO: Document */
void CopyToStateSetOpaque(CopyToState cstate, void *opaque)
{
cstate->opaque = opaque;
}

/*
* CopyToFormatOps implementations.
*/
Expand Down
6 changes: 5 additions & 1 deletion src/include/commands/copyapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

#include "executor/tuptable.h"

typedef struct CopyFromStateData *CopyFromState;
typedef struct CopyToStateData *CopyToState;
extern void *CopyToStateGetOpaque(CopyToState cstate);
extern void CopyToStateSetOpaque(CopyToState cstate, void *opaque);

typedef struct CopyFromStateData *CopyFromState;


typedef void (*CopyToStart_function) (CopyToState cstate, TupleDesc tupDesc);
typedef void (*CopyToOneRow_function) (CopyToState cstate, TupleTableSlot *slot);
Expand Down

0 comments on commit 5a610b6

Please sign in to comment.