To support logical decoding for zheap operations, we need a way to ensure zheap tuples can be registered as change streams. One idea could be that we make ReorderBufferChange aware of another kind of tuples as well, something like this:
@@ -100,6 +123,20 @@ typedef struct ReorderBufferChange ReorderBufferTupleBuf *newtuple; } tp; + struct + { + /* relation that has been changed */ + RelFileNode relnode; + + /* no previously reassembled toast chunks are necessary anymore */ + bool clear_toast_afterwards; + + /* valid for DELETE || UPDATE */ + ReorderBufferZTupleBuf *oldtuple; + /* valid for INSERT || UPDATE */ + ReorderBufferZTupleBuf *newtuple; + } ztp; + +/* an individual zheap tuple, stored in one chunk of memory */ +typedef struct ReorderBufferZTupleBuf +{ .. + /* tuple header, the interesting bit for users of logical decoding */ + ZHeapTupleData tuple; .. +} ReorderBufferZTupleBuf; Apart from this, we need to define different decode functions for zheap operations as the WAL data is different for heap and zheap, so same functions can't be used to decode. I have written a very hacky version to support zheap Insert operation based on the above idea. If we want to go with this approach, we might need a better way to represent a different type of tuple in ReorderBufferChange. The yet another approach could be that in the decode functions after forming zheap tuples from WAL, we can convert them to heap tuples. I have not tried that, so not sure if it can work, but it seems to me if we can avoid tuple conversion overhead, it will be good. This email is primarily to discuss about how the logical decoding for basic DML operations (Insert/Update/Delete) will work in zheap. We might need some special mechanism to deal with sub-transactions as zheap doesn't generate a transaction id for sub-transactions, but we can discuss that separately. Thoughts? Note - This patch is based on pluggable_zheap branch (https://github.com/anarazel/postgres-pluggable-storage) -- With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com
decode_zinsert_1.patch
Description: Binary data