I searched and didn't find any similar existing tests. Can we think of any other way to test this code path? We already have one copy test in toast.sql, isn't it possible to write a similar test here?
Yeah, I wasn't very confident about this either. I just wrote it to reduce the test footprint in the reproducer. I think we can simply include a lot more data and do the copy via stdin.
Alternatively, we can reduce logical_decoding_work_mem minimum value and run the test with a smaller value. But that same GUC is used to decide spilling txn to disk as well. So I am not sure if reducing the compile time default is acceptable or not.