Skip to content

Commit bade01c

Browse files
Fix recent pg_walinspect fpi_length bug.
Commit 0276ae4 taught pg_walinspect's pg_get_wal_record_info() function to output NULLs rather than empty strings for its record description and block_ref output parameters. However, it inadvertently moved the function call that sets fpi_length until after it was already set. As a result, pg_get_wal_record_info() always output spurious fpi_length values of 0. Fix by switching the order back (but keep the behavioral change). Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> Discussion: https://postgr.es/m/CAH2-WzkJmgSYkt6-smQ+57SxSmov+EKqFZdSimFewosoL_JKoA@mail.gmail.com
1 parent 326a33a commit bade01c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

contrib/pg_walinspect/pg_walinspect.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ GetWALRecordInfo(XLogReaderState *record, Datum *values,
186186
RmgrData desc;
187187
uint32 fpi_len = 0;
188188
StringInfoData rec_desc;
189+
StringInfoData rec_blk_ref;
189190
int i = 0;
190191

191192
desc = GetRmgr(XLogRecGetRmid(record));
@@ -197,6 +198,12 @@ GetWALRecordInfo(XLogReaderState *record, Datum *values,
197198
initStringInfo(&rec_desc);
198199
desc.rm_desc(&rec_desc, record);
199200

201+
if (XLogRecHasAnyBlockRefs(record))
202+
{
203+
initStringInfo(&rec_blk_ref);
204+
XLogRecGetBlockRefInfo(record, false, true, &rec_blk_ref, &fpi_len);
205+
}
206+
200207
values[i++] = LSNGetDatum(record->ReadRecPtr);
201208
values[i++] = LSNGetDatum(record->EndRecPtr);
202209
values[i++] = LSNGetDatum(XLogRecGetPrev(record));
@@ -205,23 +212,15 @@ GetWALRecordInfo(XLogReaderState *record, Datum *values,
205212
values[i++] = CStringGetTextDatum(id);
206213
values[i++] = UInt32GetDatum(XLogRecGetTotalLen(record));
207214
values[i++] = UInt32GetDatum(XLogRecGetDataLen(record));
208-
209215
values[i++] = UInt32GetDatum(fpi_len);
210216

211217
if (rec_desc.len > 0)
212218
values[i++] = CStringGetTextDatum(rec_desc.data);
213219
else
214220
nulls[i++] = true;
215221

216-
/* Block references. */
217222
if (XLogRecHasAnyBlockRefs(record))
218-
{
219-
StringInfoData rec_blk_ref;
220-
221-
initStringInfo(&rec_blk_ref);
222-
XLogRecGetBlockRefInfo(record, false, true, &rec_blk_ref, &fpi_len);
223223
values[i++] = CStringGetTextDatum(rec_blk_ref.data);
224-
}
225224
else
226225
nulls[i++] = true;
227226

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy