Hi,
I was looking at the code in use_physical_tlist().
In the code block checking CP_LABEL_TLIST, I noticed that the Bitmapset sortgroupatts is not freed before returning from the method.
Looking at create_foreignscan_plan() (in the same file):
bms_free(attrs_used);
It seems the intermediate Bitmapset is freed before returning.
I would appreciate review comments for the proposed patch.
Thanks