Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0a24820

Browse files
committed
Temporary patch to try to debug why event trigger patch broke Windows.
Apologies for the ugliness.
1 parent ae55d9f commit 0a24820

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/pl/plpgsql/src/pl_comp.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ do_compile(FunctionCallInfo fcinfo,
285285
int *in_arg_varnos = NULL;
286286
PLpgSQL_variable **out_arg_variables;
287287
MemoryContext func_cxt;
288+
PLpgSQL_trigtype fn_is_trigger;
288289

289290
/*
290291
* Setup the scanner input and error info. We assume that this function
@@ -352,11 +353,12 @@ do_compile(FunctionCallInfo fcinfo,
352353
function->resolve_option = plpgsql_variable_conflict;
353354

354355
if (is_dml_trigger)
355-
function->fn_is_trigger = PLPGSQL_DML_TRIGGER;
356+
fn_is_trigger = PLPGSQL_DML_TRIGGER;
356357
else if (is_event_trigger)
357-
function->fn_is_trigger = PLPGSQL_EVENT_TRIGGER;
358+
fn_is_trigger = PLPGSQL_EVENT_TRIGGER;
358359
else
359-
function->fn_is_trigger = PLPGSQL_NOT_TRIGGER;
360+
fn_is_trigger = PLPGSQL_NOT_TRIGGER;
361+
function->fn_is_trigger = fn_is_trigger;
360362

361363
/*
362364
* Initialize the compiler, particularly the namespace stack. The
@@ -374,6 +376,7 @@ do_compile(FunctionCallInfo fcinfo,
374376
sizeof(PLpgSQL_datum *) * datums_alloc);
375377
datums_last = 0;
376378

379+
Assert(fn_is_trigger == function->fn_is_trigger);
377380
switch (function->fn_is_trigger)
378381
{
379382
case PLPGSQL_NOT_TRIGGER:
@@ -537,9 +540,13 @@ do_compile(FunctionCallInfo fcinfo,
537540
rettypeid == RECORDOID)
538541
/* okay */ ;
539542
else if (rettypeid == TRIGGEROID || rettypeid == EVTTRIGGEROID)
543+
{
540544
ereport(ERROR,
541545
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
542-
errmsg("trigger functions can only be called as triggers")));
546+
errmsg("trigger functions can only be called as triggers"),
547+
errhint("CALLED_AS_TRIGGER=%d CALLED_AS_EVENT_TRIGGER=%d",
548+
CALLED_AS_TRIGGER(fcinfo), CALLED_AS_EVENT_TRIGGER(fcinfo))));
549+
}
543550
else
544551
ereport(ERROR,
545552
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

0 commit comments

Comments
 (0)