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