Fdw cleanup - Mailing list pgsql-hackers

From Feng Tian
Subject Fdw cleanup
Date
Msg-id CAFWGqnsPq0bjmVP6O8KGmFXN3_4HC_tHAbrPpYbP1JvS9VNZdA@mail.gmail.com
Whole thread Raw
Responses Re: Fdw cleanup  (Albe Laurenz <laurenz.albe@wien.gv.at>)
List 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
   

pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Proposal: custom compression methods
Next
From: Craig Ringer
Date:
Subject: Re: [PATCH] Logical decoding support for sequence advances