On 2019-Apr-11, Antonin Houska wrote: > While working on the instance encryption I found it annoying to apply > decyption of XLOG page to three different functions. Attached is a patch that > tries to merge them all into one function, XLogRead(). The existing > implementations differ in the way new segment is opened. So I added a pointer > to callback function as a new argument. This callback handles the specific > ways to determine segment file name and to open the file. > > I can split the patch into multiple diffs to make detailed review easier, but > first I'd like to hear if anything is seriously wrong about this > design. Thanks.
I agree that xlog reading is pretty messy. I think ifdef'ing the way XLogRead reports errors is not great. Maybe we can pass a function pointer that is to be called in case of errors? Not sure about the walsize; maybe it can be a member in XLogReadPos, and given to XLogReadInitPos()? (Maybe rename XLogReadPos as XLogReadContext or something like that, indicating it's not just the read position.) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services