I have another approach for this.
Recall that the issue is ultimately that RelationGetIndexAttrBitmap()
might need a snapshot under certain circumstances, and it will crash if
there isn't one. There are actually two separate bugs, in the publisher
and in the subscriber. Some patches have been proposed in this thread
that either bypass RelationGetIndexAttrBitmap() or obtain a snapshot at
different times in the publisher or subscriber code.
My approach is to make RelationGetIndexAttrBitmap() not need a snapshot.
The whole code was overly complicated anyway, calling BuildIndexInfo()
and then throwing the result away. We can do it directly more
efficiently and avoid all the business about eval_const_expressions().
Moreover, this fixes the problem in a central place and does not require
bespoke separate fixes in the publisher and subscriber code. External
logical decoding or logical replication implementations could also be
affected and would benefit from this fix.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services