Repair plpgsql_validator breakage.
authorRobert Haas <rhaas@postgresql.org>
Sat, 21 Jul 2012 01:25:26 +0000 (21:25 -0400)
committerRobert Haas <rhaas@postgresql.org>
Sat, 21 Jul 2012 01:28:26 +0000 (21:28 -0400)
Commit 3a0e4d36ebd7f477822d5bae41ba121a40d22ccc arranged to
reference stack-allocated variables after they were out of scope.
That's no good, so let's arrange to not do that after all.

src/pl/plpgsql/src/pl_handler.c

index 2adf166164ef887c394b314e48f39858f9696b92..905fff0b31d6785c4a5b33875a21175acef432b0 100644 (file)
@@ -280,6 +280,8 @@ plpgsql_validator(PG_FUNCTION_ARGS)
        FunctionCallInfoData fake_fcinfo;
        FmgrInfo    flinfo;
        int         rc;
+       TriggerData trigdata;
+       EventTriggerData etrigdata;
 
        /*
         * Connect to SPI manager (is this needed for compilation?)
@@ -298,17 +300,15 @@ plpgsql_validator(PG_FUNCTION_ARGS)
        flinfo.fn_mcxt = CurrentMemoryContext;
        if (is_dml_trigger)
        {
-           TriggerData trigdata;
            MemSet(&trigdata, 0, sizeof(trigdata));
            trigdata.type = T_TriggerData;
            fake_fcinfo.context = (Node *) &trigdata;
        }
        else if (is_event_trigger)
        {
-           EventTriggerData trigdata;
-           MemSet(&trigdata, 0, sizeof(trigdata));
-           trigdata.type = T_EventTriggerData;
-           fake_fcinfo.context = (Node *) &trigdata;
+           MemSet(&etrigdata, 0, sizeof(etrigdata));
+           etrigdata.type = T_EventTriggerData;
+           fake_fcinfo.context = (Node *) &etrigdata;
        }
 
        /* Test-compile the function */