From 047edeedde19db720ec83b575dfa0b121246371f Mon Sep 17 00:00:00 2001
From: Craig Ringer <craig.ringer@2ndquadrant.com>
Date: Thu, 3 Sep 2020 18:38:27 +0800
Subject: [PATCH 3/9] Enable pg_errcontext_check() for all in-tree users

---
 contrib/file_fdw/file_fdw.c               |  4 +--
 contrib/postgres_fdw/postgres_fdw.c       |  2 +-
 src/backend/access/heap/vacuumlazy.c      |  4 +--
 src/backend/access/transam/xlog.c         |  2 +-
 src/backend/catalog/pg_proc.c             |  2 +-
 src/backend/commands/copy.c               |  2 +-
 src/backend/commands/foreigncmds.c        |  2 +-
 src/backend/executor/functions.c          |  2 +-
 src/backend/executor/spi.c                | 10 ++++----
 src/backend/optimizer/util/clauses.c      |  4 +--
 src/backend/parser/parse_type.c           |  2 +-
 src/backend/replication/logical/logical.c | 30 +++++++++++------------
 src/backend/replication/logical/worker.c  |  4 +--
 src/backend/storage/buffer/bufmgr.c       |  4 +--
 src/backend/storage/lmgr/lmgr.c           |  2 +-
 src/pl/plpgsql/src/pl_comp.c              |  4 +--
 src/pl/plpgsql/src/pl_exec.c              |  6 ++---
 src/pl/plpython/plpy_exec.c               |  4 +--
 src/pl/plpython/plpy_main.c               |  4 +--
 src/pl/tcl/pltcl.c                        |  2 +-
 20 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c
index 072a6dc1c1..17187f1da2 100644
--- a/contrib/file_fdw/file_fdw.c
+++ b/contrib/file_fdw/file_fdw.c
@@ -707,7 +707,7 @@ fileIterateForeignScan(ForeignScanState *node)
 	FileFdwExecutionState *festate = (FileFdwExecutionState *) node->fdw_state;
 	TupleTableSlot *slot = node->ss.ss_ScanTupleSlot;
 	bool		found;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	/* Set up callback to identify error line number. */
 	errcallback.callback = CopyFromErrorCallback;
@@ -1108,7 +1108,7 @@ file_acquire_sample_rows(Relation onerel, int elevel,
 	bool		is_program;
 	List	   *options;
 	CopyState	cstate;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 	MemoryContext oldcontext = CurrentMemoryContext;
 	MemoryContext tupcontext;
 
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index a31abce7c9..1151829197 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -6323,7 +6323,7 @@ make_tuple_from_result_row(PGresult *res,
 	bool	   *nulls;
 	ItemPointer ctid = NULL;
 	ConversionLocation errpos;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 	MemoryContext oldcontext;
 	ListCell   *lc;
 	int			j;
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 92389e6666..1c63a25339 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -439,7 +439,7 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params,
 	double		new_live_tuples;
 	TransactionId new_frozen_xid;
 	MultiXactId new_min_multi;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(params != NULL);
 	Assert(params->index_cleanup != VACOPT_TERNARY_DEFAULT);
@@ -3517,7 +3517,7 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc)
 	char	   *sharedquery;
 	IndexBulkDeleteResult **stats;
 	LVRelStats	vacrelstats;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	lvshared = (LVShared *) shm_toc_lookup(toc, PARALLEL_VACUUM_KEY_SHARED,
 										   false);
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 09c01ed4ae..81d04912fe 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7167,7 +7167,7 @@ StartupXLOG(void)
 
 		if (record != NULL)
 		{
-			ErrorContextCallback errcallback;
+			ErrorContextCallback errcallback pg_errcontext_check();
 			TimestampTz xtime;
 
 			InRedo = true;
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index a28ab74d60..b389f0d0a8 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -807,7 +807,7 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
 	Datum		tmp;
 	char	   *prosrc;
 	parse_error_callback_arg callback_arg;
-	ErrorContextCallback sqlerrcontext;
+	ErrorContextCallback sqlerrcontext pg_errcontext_check();
 	bool		haspolyarg;
 	int			i;
 
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index db7d24a511..202d81b845 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -2711,7 +2711,7 @@ CopyFrom(CopyState cstate)
 	MemoryContext oldcontext = CurrentMemoryContext;
 
 	PartitionTupleRouting *proute = NULL;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 	CommandId	mycid = GetCurrentCommandId(true);
 	int			ti_options = 0; /* start with default options for insert */
 	BulkInsertState bistate = NULL;
diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c
index de31ddd1f3..90236bdc32 100644
--- a/src/backend/commands/foreigncmds.c
+++ b/src/backend/commands/foreigncmds.c
@@ -1512,7 +1512,7 @@ ImportForeignSchema(ImportForeignSchemaStmt *stmt)
 	{
 		char	   *cmd = (char *) lfirst(lc);
 		import_error_callback_arg callback_arg;
-		ErrorContextCallback sqlerrcontext;
+		ErrorContextCallback sqlerrcontext pg_errcontext_check();
 		List	   *raw_parsetree_list;
 		ListCell   *lc2;
 
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index f940f48c6d..2ea1e2e5fc 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -1007,7 +1007,7 @@ Datum
 fmgr_sql(PG_FUNCTION_ARGS)
 {
 	SQLFunctionCachePtr fcache;
-	ErrorContextCallback sqlerrcontext;
+	ErrorContextCallback sqlerrcontext pg_errcontext_check();
 	MemoryContext oldcontext;
 	bool		randomAccess;
 	bool		lazyEvalOK;
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 055ebb77ae..7fcd172721 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -1436,7 +1436,7 @@ SPI_cursor_open_internal(const char *name, SPIPlanPtr plan,
 	Snapshot	snapshot;
 	MemoryContext oldcontext;
 	Portal		portal;
-	ErrorContextCallback spierrcontext;
+	ErrorContextCallback spierrcontext pg_errcontext_check();
 
 	/*
 	 * Check that the plan is something the Portal code will special-case as
@@ -1909,7 +1909,7 @@ SPI_plan_get_cached_plan(SPIPlanPtr plan)
 {
 	CachedPlanSource *plansource;
 	CachedPlan *cplan;
-	ErrorContextCallback spierrcontext;
+	ErrorContextCallback spierrcontext pg_errcontext_check();
 
 	Assert(plan->magic == _SPI_PLAN_MAGIC);
 
@@ -2050,7 +2050,7 @@ _SPI_prepare_plan(const char *src, SPIPlanPtr plan)
 	List	   *raw_parsetree_list;
 	List	   *plancache_list;
 	ListCell   *list_item;
-	ErrorContextCallback spierrcontext;
+	ErrorContextCallback spierrcontext pg_errcontext_check();
 
 	/*
 	 * Setup error traceback support for ereport()
@@ -2155,7 +2155,7 @@ _SPI_prepare_oneshot_plan(const char *src, SPIPlanPtr plan)
 	List	   *raw_parsetree_list;
 	List	   *plancache_list;
 	ListCell   *list_item;
-	ErrorContextCallback spierrcontext;
+	ErrorContextCallback spierrcontext pg_errcontext_check();
 
 	/*
 	 * Setup error traceback support for ereport()
@@ -2219,7 +2219,7 @@ _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
 	SPITupleTable *my_tuptable = NULL;
 	int			res = 0;
 	bool		pushed_active_snap = false;
-	ErrorContextCallback spierrcontext;
+	ErrorContextCallback spierrcontext pg_errcontext_check();
 	CachedPlan *cplan = NULL;
 	ListCell   *lc1;
 
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index 750586fceb..3ebb581ed5 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -4369,7 +4369,7 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
 	MemoryContext oldcxt;
 	MemoryContext mycxt;
 	inline_error_callback_arg callback_arg;
-	ErrorContextCallback sqlerrcontext;
+	ErrorContextCallback sqlerrcontext pg_errcontext_check();
 	FuncExpr   *fexpr;
 	SQLFunctionParseInfoPtr pinfo;
 	TupleDesc	rettupdesc;
@@ -4858,7 +4858,7 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
 	MemoryContext oldcxt;
 	MemoryContext mycxt;
 	inline_error_callback_arg callback_arg;
-	ErrorContextCallback sqlerrcontext;
+	ErrorContextCallback sqlerrcontext pg_errcontext_check();
 	SQLFunctionParseInfoPtr pinfo;
 	TypeFuncClass functypclass;
 	TupleDesc	rettupdesc;
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index 2709f6f9c7..33176e5d59 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -743,7 +743,7 @@ typeStringToTypeName(const char *str)
 	ResTarget  *restarget;
 	TypeCast   *typecast;
 	TypeName   *typeName;
-	ErrorContextCallback ptserrcontext;
+	ErrorContextCallback ptserrcontext pg_errcontext_check();
 
 	/* make sure we give useful error for empty input */
 	if (strspn(str, " \t\n\r\f") == strlen(str))
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 0f6af952f9..bcb9eacfe0 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -665,7 +665,7 @@ static void
 startup_cb_wrapper(LogicalDecodingContext *ctx, OutputPluginOptions *opt, bool is_init)
 {
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -692,7 +692,7 @@ static void
 shutdown_cb_wrapper(LogicalDecodingContext *ctx)
 {
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -725,7 +725,7 @@ begin_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn)
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -756,7 +756,7 @@ commit_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -787,7 +787,7 @@ change_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -824,7 +824,7 @@ truncate_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -862,7 +862,7 @@ bool
 filter_by_origin_cb_wrapper(LogicalDecodingContext *ctx, RepOriginId origin_id)
 {
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 	bool		ret;
 
 	Assert(!ctx->fast_forward);
@@ -895,7 +895,7 @@ message_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -930,7 +930,7 @@ stream_start_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -976,7 +976,7 @@ stream_stop_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -1022,7 +1022,7 @@ stream_abort_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -1061,7 +1061,7 @@ stream_commit_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -1100,7 +1100,7 @@ stream_change_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -1147,7 +1147,7 @@ stream_message_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
@@ -1187,7 +1187,7 @@ stream_truncate_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
 {
 	LogicalDecodingContext *ctx = cache->private_data;
 	LogicalErrorCallbackState state;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	Assert(!ctx->fast_forward);
 
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 812aca8011..87d3cf8f7f 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -476,7 +476,7 @@ slot_store_data(TupleTableSlot *slot, LogicalRepRelMapEntry *rel,
 	int			natts = slot->tts_tupleDescriptor->natts;
 	int			i;
 	SlotErrCallbackArg errarg;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	ExecClearTuple(slot);
 
@@ -592,7 +592,7 @@ slot_modify_data(TupleTableSlot *slot, TupleTableSlot *srcslot,
 	int			natts = slot->tts_tupleDescriptor->natts;
 	int			i;
 	SlotErrCallbackArg errarg;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 
 	/* We'll fill "slot" with a virtual tuple, so we must start with ... */
 	ExecClearTuple(slot);
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index a2a963bd5b..b8c06259f8 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -2728,7 +2728,7 @@ static void
 FlushBuffer(BufferDesc *buf, SMgrRelation reln)
 {
 	XLogRecPtr	recptr;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 	instr_time	io_start,
 				io_time;
 	Block		bufBlock;
@@ -3275,7 +3275,7 @@ FlushRelationBuffers(Relation rel)
 				((buf_state = pg_atomic_read_u32(&bufHdr->state)) &
 				 (BM_VALID | BM_DIRTY)) == (BM_VALID | BM_DIRTY))
 			{
-				ErrorContextCallback errcallback;
+				ErrorContextCallback errcallback pg_errcontext_check();
 				Page		localpage;
 
 				localpage = (char *) LocalBufHdrGetBlock(bufHdr);
diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c
index 7409de9405..14483f3238 100644
--- a/src/backend/storage/lmgr/lmgr.c
+++ b/src/backend/storage/lmgr/lmgr.c
@@ -641,7 +641,7 @@ XactLockTableWait(TransactionId xid, Relation rel, ItemPointer ctid,
 {
 	LOCKTAG		tag;
 	XactLockTableWaitInfo info;
-	ErrorContextCallback callback;
+	ErrorContextCallback callback pg_errcontext_check();
 	bool		first = true;
 
 	/*
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index e7f4a5f291..7894e0437a 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -277,7 +277,7 @@ do_compile(FunctionCallInfo fcinfo,
 	PLpgSQL_variable *var;
 	PLpgSQL_rec *rec;
 	int			i;
-	ErrorContextCallback plerrcontext;
+	ErrorContextCallback plerrcontext pg_errcontext_check();
 	int			parse_rc;
 	Oid			rettypeid;
 	int			numargs;
@@ -844,7 +844,7 @@ plpgsql_compile_inline(char *proc_source)
 {
 	char	   *func_name = "inline_code_block";
 	PLpgSQL_function *function;
-	ErrorContextCallback plerrcontext;
+	ErrorContextCallback plerrcontext pg_errcontext_check();
 	PLpgSQL_variable *var;
 	int			parse_rc;
 	MemoryContext func_cxt;
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index d4a3d58daa..c36d21e811 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -470,7 +470,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo,
 					  bool atomic)
 {
 	PLpgSQL_execstate estate;
-	ErrorContextCallback plerrcontext;
+	ErrorContextCallback plerrcontext pg_errcontext_check();
 	int			i;
 	int			rc;
 
@@ -902,7 +902,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
 					 TriggerData *trigdata)
 {
 	PLpgSQL_execstate estate;
-	ErrorContextCallback plerrcontext;
+	ErrorContextCallback plerrcontext pg_errcontext_check();
 	int			rc;
 	TupleDesc	tupdesc;
 	PLpgSQL_rec *rec_new,
@@ -1141,7 +1141,7 @@ void
 plpgsql_exec_event_trigger(PLpgSQL_function *func, EventTriggerData *trigdata)
 {
 	PLpgSQL_execstate estate;
-	ErrorContextCallback plerrcontext;
+	ErrorContextCallback plerrcontext pg_errcontext_check();
 	int			rc;
 
 	/*
diff --git a/src/pl/plpython/plpy_exec.c b/src/pl/plpython/plpy_exec.c
index c6f6a6fbcc..d2a41cb156 100644
--- a/src/pl/plpython/plpy_exec.c
+++ b/src/pl/plpython/plpy_exec.c
@@ -60,7 +60,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
 	PyObject   *volatile plrv = NULL;
 	FuncCallContext *volatile funcctx = NULL;
 	PLySRFState *volatile srfstate = NULL;
-	ErrorContextCallback plerrcontext;
+	ErrorContextCallback plerrcontext pg_errcontext_check();
 
 	/*
 	 * If the function is called recursively, we must push outer-level
@@ -887,7 +887,7 @@ PLy_modify_tuple(PLyProcedure *proc, PyObject *pltd, TriggerData *tdata,
 	Datum	   *volatile modvalues;
 	bool	   *volatile modnulls;
 	bool	   *volatile modrepls;
-	ErrorContextCallback plerrcontext;
+	ErrorContextCallback plerrcontext pg_errcontext_check();
 
 	plerrcontext.callback = plpython_trigger_error_callback;
 	plerrcontext.previous = error_context_stack;
diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c
index 3eedaa80da..25bde27ca1 100644
--- a/src/pl/plpython/plpy_main.c
+++ b/src/pl/plpython/plpy_main.c
@@ -218,7 +218,7 @@ plpython_call_handler(PG_FUNCTION_ARGS)
 	bool		nonatomic;
 	Datum		retval;
 	PLyExecutionContext *exec_ctx;
-	ErrorContextCallback plerrcontext;
+	ErrorContextCallback plerrcontext pg_errcontext_check();
 
 	PLy_initialize();
 
@@ -300,7 +300,7 @@ plpython_inline_handler(PG_FUNCTION_ARGS)
 	FmgrInfo	flinfo;
 	PLyProcedure proc;
 	PLyExecutionContext *exec_ctx;
-	ErrorContextCallback plerrcontext;
+	ErrorContextCallback plerrcontext pg_errcontext_check();
 
 	PLy_initialize();
 
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index f4eabc8f39..357713e228 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -591,7 +591,7 @@ call_pltcl_start_proc(Oid prolang, bool pltrusted)
 	LOCAL_FCINFO(fcinfo, 0);
 	char	   *start_proc;
 	const char *gucname;
-	ErrorContextCallback errcallback;
+	ErrorContextCallback errcallback pg_errcontext_check();
 	List	   *namelist;
 	Oid			procOid;
 	HeapTuple	procTup;
-- 
2.26.2

