[PATCH] XLogReadRecord returns pointer to currently read page
Andrei Lepikhov <a.lepikhov@postgrespro.ru>
From: Andrey Lepikhov <a.lepikhov@postgrespro.ru>
To: PostgreSQL-Dev <pgsql-hackers@postgresql.org>
Date: 2018-08-17T03:47:15Z
Lists: pgsql-hackers
Attachments
- 0001-WAL-record-local-buffer-pointer-fix.patch (text/x-patch)
Hi, hackers! I propose the patch for fix one small code defect. The XLogReadRecord() function reads the pages of a WAL segment that contain a WAL-record. Then it creates a readRecordBuf buffer in private memory of a backend and copy record from the pages to the readRecordBuf buffer. Pointer 'record' is set to the beginning of the readRecordBuf buffer. But if the WAL-record is fully placed on one page, the XLogReadRecord() function forgets to bind the "record" pointer with the beginning of the readRecordBuf buffer. In this case, XLogReadRecord() returns a pointer to an internal xlog page. This patch fixes the defect. Previously, in all cases of using WAL this was not a problem. However if you plan to perform some decoding operations before returning the WAL record to the caller (this is my case), this can lead to bugs that are difficult to catch. -- Andrey Lepikhov Postgres Professional https://postgrespro.com The Russian Postgres Company
Commits
-
Improve description of buffer used to store records in WAL reader
- 0999ac479292 12.0 landed
-
Remove unnecessary memcpy when reading WAL record fitting on page
- 285bd0ac4a7c 12.0 landed