Skip to content

Commit 50ba65e

Browse files
committed
Add an additional hook for EXPLAIN option validation.
Commit c65bc2e made it possible for loadable modules to add EXPLAIN options. Normally, any necessary validation can be performed by the hook function passed to RegisterExtensionExplainOption, but if a loadable module wants to sanity check options against each other, that needs to be done after the entire options list has been processed. So, add an additional hook for that purpose. Author: Sami Imseih <samimseih@gmail.com> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Reviewed-by: Andrei Lepikhov <lepihov@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: http://postgr.es/m/CAA5RZ0vOcJF91O2e5AQN+V6guMNLMhJx83dxALf-iUZ-hLGO_Q@mail.gmail.com
1 parent af0d490 commit 50ba65e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/backend/commands/explain_state.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
#include "commands/explain.h"
3838
#include "commands/explain_state.h"
3939

40+
/* Hook to perform additional EXPLAIN options validation */
41+
explain_validate_options_hook_type explain_validate_options_hook = NULL;
42+
4043
typedef struct
4144
{
4245
const char *option_name;
@@ -196,6 +199,10 @@ ParseExplainOptionList(ExplainState *es, List *options, ParseState *pstate)
196199

197200
/* if the summary was not set explicitly, set default value */
198201
es->summary = (summary_set) ? es->summary : es->analyze;
202+
203+
/* plugin specific option validation */
204+
if (explain_validate_options_hook)
205+
(*explain_validate_options_hook) (es, options, pstate);
199206
}
200207

201208
/*

src/include/commands/explain_state.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ typedef struct ExplainState
7878

7979
typedef void (*ExplainOptionHandler) (ExplainState *, DefElem *, ParseState *);
8080

81+
/* Hook to perform additional EXPLAIN options validation */
82+
typedef void (*explain_validate_options_hook_type) (struct ExplainState *es, List *options,
83+
ParseState *pstate);
84+
extern PGDLLIMPORT explain_validate_options_hook_type explain_validate_options_hook;
85+
8186
extern ExplainState *NewExplainState(void);
8287
extern void ParseExplainOptionList(ExplainState *es, List *options,
8388
ParseState *pstate);

0 commit comments

Comments
 (0)