From f01ad61fe6c251a00870ace5d37669350f8e2043 Mon Sep 17 00:00:00 2001 From: Zhao Junwang Date: Fri, 26 Jan 2024 15:55:07 +0800 Subject: [PATCH] add check incomptiblity options hooks Signed-off-by: Zhao Junwang --- src/backend/commands/copy.c | 5 +++++ src/include/commands/copyapi.h | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 479f36868c..985d50870f 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -924,6 +924,11 @@ ProcessCopyOptions(ParseState *pstate, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("NULL specification and DEFAULT specification cannot be the same"))); } + + if (is_from) + opts_out->from_routine->CopyFromCheckIncompatibleOptions(cstate, opts_out); + else + opts_out->to_routine->CopyToCheckIncompatibleOptions(cstate, opts_out); } /* diff --git a/src/include/commands/copyapi.h b/src/include/commands/copyapi.h index 22accc83ab..34aa86761a 100644 --- a/src/include/commands/copyapi.h +++ b/src/include/commands/copyapi.h @@ -21,8 +21,10 @@ #include "nodes/parsenodes.h" typedef struct CopyFromStateData *CopyFromState; +typedef struct CopyFormatOptions; typedef bool (*CopyFromProcessOption_function) (CopyFromState cstate, DefElem *defel); +typedef void (*CopyFromCheckIncompatibleOptions_function) (CopyFromState cstate, CopyFormatOptions *options); typedef int16 (*CopyFromGetFormat_function) (CopyFromState cstate); typedef void (*CopyFromStart_function) (CopyFromState cstate, TupleDesc tupDesc); typedef bool (*CopyFromOneRow_function) (CopyFromState cstate, ExprContext *econtext, Datum *values, bool *nulls); @@ -39,6 +41,12 @@ typedef struct CopyFromRoutine */ CopyFromProcessOption_function CopyFromProcessOption; + /* + * Called for processing incompatible options. This will report error + * messages when find incompatible options. + */ + CopyFromCheckIncompatibleOptions_function CopyFromCheckIncompatibleOptions; + /* * Called when COPY FROM is started. This will return a format as int16 * value. It's used for the CopyInResponse message. @@ -67,6 +75,7 @@ extern CopyFromRoutine CopyFromRoutineBinary; typedef struct CopyToStateData *CopyToState; typedef bool (*CopyToProcessOption_function) (CopyToState cstate, DefElem *defel); +typedef void (*CopyToCheckIncompatibleOptions_function) (CopyToState cstate, CopyFormatOptions *options); typedef int16 (*CopyToGetFormat_function) (CopyToState cstate); typedef void (*CopyToStart_function) (CopyToState cstate, TupleDesc tupDesc); typedef void (*CopyToOneRow_function) (CopyToState cstate, TupleTableSlot *slot); @@ -83,6 +92,12 @@ typedef struct CopyToRoutine */ CopyToProcessOption_function CopyToProcessOption; + /* + * Called for processing incompatible options. This will report error + * messages when find incompatible options. + */ + CopyToCheckIncompatibleOptions_function CopyToCheckIncompatibleOptions; + /* * Called when COPY TO is started. This will return a format as int16 * value. It's used for the CopyOutResponse message. -- 2.41.0