session? I think the "free_using_plugin" flag:
! if (get_relation_stats_hook)
! vardata->statsTuple = (*get_relation_stats_hook)
! if (vardata->statsTuple)
! vardata->free_using_plugin = true;
! vardata->statsTuple = SearchSysCache(STATRELATT,
is insufficient to handle this. vardata->free_using_plugin could be true but
by the time the variable is released the plugin pointer could have been
cleared. Or worse, set to a different plugin.
The easiest way to fix this seems like also the best way, instead of storing a
boolean store the pointer to the release function.
Ask me about EnterpriseDB's 24x7 Postgres support!