Fdw cleanup

From: Feng Tian <ftian(at)vitessedata(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Fdw cleanup
Date: 2015-12-14 07:38:43
Message-ID: CAFWGqnsPq0bjmVP6O8KGmFXN3_4HC_tHAbrPpYbP1JvS9VNZdA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, Hackers,

I need some help to understand foreign table error handling.

For a query on foreign table, ExecInitForeignScan is called, which in turn
calls the BeginForeignScan hook. Inside this hook, I allocated some
resource,

node->fdw_state = allocate_resource(...);

If everything goes well, ExecEndForeignScan will call call my
EndForeignScan hook, inside the hook, I free the resource.

free_resource(node->fdw_state);

However, if during the execution an error happened, seems to me that
EndForeignScan will not be called (traced using gdb). So my question is,
is Begin/End the right place for allocate/free resources? If it is not,
what is the right way to do this?

Thank you very much,
Feng

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2015-12-14 08:19:33 Re: [PATCH] Logical decoding support for sequence advances
Previous Message Craig Ringer 2015-12-14 07:36:49 Re: Proposal: custom compression methods