From: | Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com> |
---|---|
To: | exclusion(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #16139: Assertion fails on INSERT into a postgres_fdw' table with two AFTER INSERT triggers |
Date: | 2019-11-28 11:25:46 |
Message-ID: | CAPmGK15st2aAuWXn8FCeyYg1Jvu7NCtH0=BdvPZoUCmXMq09Kg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Wed, Nov 27, 2019 at 8:35 PM Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com> wrote:
> A bit of investigation showed that this is caused by commit
> ff11e7f4b9ae017585c3ba146db7ba39c31f209a. I haven't yet looked at the
> commit in any detail, though.
I spent some time studying the commit. I think AfterTriggerExecute()
should make sure that:
* foreign tables always use zero and save the tuple(s) to a
* tuplestore. AFTER_TRIGGER_FDW_FETCH directs AfterTriggerExecute() to
* retrieve a fresh tuple or pair of tuples from that tuplestore, while
* AFTER_TRIGGER_FDW_REUSE directs it to use the most-recently-retrieved
* tuple(s). This permits storing tuples once regardless of the number of
* row-level triggers on a foreign table.
But the commit modified that function to clear the tg_trigslot and
tg_newslot slots' contents, which are reused when
AFTER_TRIGGER_FDW_REUSE, as shown below:
@@ -4374,12 +4373,17 @@ AfterTriggerExecute(AfterTriggerEvent event,
heap_freetuple(rettuple);
/*
- * Release buffers
+ * Release resources
*/
- if (buffer1 != InvalidBuffer)
- ReleaseBuffer(buffer1);
- if (buffer2 != InvalidBuffer)
- ReleaseBuffer(buffer2);
+ if (should_free_trig)
+ heap_freetuple(LocTriggerData.tg_trigtuple);
+ if (should_free_new)
+ heap_freetuple(LocTriggerData.tg_newtuple);
+
+ if (LocTriggerData.tg_trigslot)
+ ExecClearTuple(LocTriggerData.tg_trigslot);
+ if (LocTriggerData.tg_newslot)
+ ExecClearTuple(LocTriggerData.tg_newslot);
Attached is a patch for fixing that. Maybe I'm missing something, though.
Best regards,
Etsuro Fujita
Attachment | Content-Type | Size |
---|---|---|
fix-AfterTriggerExecute-1.patch | application/octet-stream | 2.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2019-11-28 13:09:22 | Re: BUG #16125: Crash of PostgreSQL's wal sender during logical replication |
Previous Message | Juan José Santamaría Flecha | 2019-11-28 10:55:30 | Re: BUG #16127: PostgreSQL 12.1 on Windows 2008 R2copy table from ‘large 2GB csv’report “Unknown error” |