提交 16343336 编写于 作者: H Heikki Linnakangas

Move UnpackCheckPointRecord to xlogdesc.c, to avoid duplicating it.

As noted in the FIXME, having two copies of the function is bad. It's easy
to avoid the duplication, if we just put it in xlogdesc.c, so that it's
available to xlog_desc() in client programs, too.
上级 414531a6
......@@ -117,50 +117,3 @@ tablespace_version_directory(void)
return path;
}
/* copied from xlog.c */
void
UnpackCheckPointRecord(XLogRecord *record, CheckpointExtendedRecord *ckptExtended)
{
char *current_record_ptr;
int remainderLen;
if (record->xl_len == sizeof(CheckPoint))
{
/* Special (for bootstrap, xlog switch, maybe others) */
ckptExtended->dtxCheckpoint = NULL;
ckptExtended->dtxCheckpointLen = 0;
ckptExtended->ptas = NULL;
return;
}
/* Normal checkpoint Record */
Assert(record->xl_len > sizeof(CheckPoint));
current_record_ptr = ((char*)XLogRecGetData(record)) + sizeof(CheckPoint);
remainderLen = record->xl_len - sizeof(CheckPoint);
/* Start of distributed transaction information */
ckptExtended->dtxCheckpoint = (TMGXACT_CHECKPOINT *)current_record_ptr;
ckptExtended->dtxCheckpointLen =
TMGXACT_CHECKPOINT_BYTES((ckptExtended->dtxCheckpoint)->committedCount);
/*
* The master prepared transaction aggregate state (ptas) will be skipped
* when gp_before_filespace_setup is ON.
*/
if (remainderLen > ckptExtended->dtxCheckpointLen)
{
current_record_ptr = current_record_ptr + ckptExtended->dtxCheckpointLen;
remainderLen -= ckptExtended->dtxCheckpointLen;
/* Finally, point to prepared transaction information */
ckptExtended->ptas = (prepared_transaction_agg_state *) current_record_ptr;
Assert(remainderLen == PREPARED_TRANSACTION_CHECKPOINT_BYTES(ckptExtended->ptas->count));
}
else
{
Assert(remainderLen == ckptExtended->dtxCheckpointLen);
ckptExtended->ptas = NULL;
}
}
......@@ -34,6 +34,57 @@ const struct config_enum_entry wal_level_options[] = {
{NULL, 0, false}
};
/*
* This is used also in the redo function, but must be defined here so that it
* can also be used in xlog_desc.
*/
void
UnpackCheckPointRecord(XLogRecord *record, CheckpointExtendedRecord *ckptExtended)
{
char *current_record_ptr;
int remainderLen;
if (record->xl_len == sizeof(CheckPoint))
{
/* Special (for bootstrap, xlog switch, maybe others) */
ckptExtended->dtxCheckpoint = NULL;
ckptExtended->dtxCheckpointLen = 0;
ckptExtended->ptas = NULL;
return;
}
/* Normal checkpoint Record */
Assert(record->xl_len > sizeof(CheckPoint));
current_record_ptr = ((char*)XLogRecGetData(record)) + sizeof(CheckPoint);
remainderLen = record->xl_len - sizeof(CheckPoint);
/* Start of distributed transaction information */
ckptExtended->dtxCheckpoint = (TMGXACT_CHECKPOINT *)current_record_ptr;
ckptExtended->dtxCheckpointLen =
TMGXACT_CHECKPOINT_BYTES((ckptExtended->dtxCheckpoint)->committedCount);
/*
* The master prepared transaction aggregate state (ptas) will be skipped
* when gp_before_filespace_setup is ON.
*/
if (remainderLen > ckptExtended->dtxCheckpointLen)
{
current_record_ptr = current_record_ptr + ckptExtended->dtxCheckpointLen;
remainderLen -= ckptExtended->dtxCheckpointLen;
/* Finally, point to prepared transaction information */
ckptExtended->ptas = (prepared_transaction_agg_state *) current_record_ptr;
Assert(remainderLen == PREPARED_TRANSACTION_CHECKPOINT_BYTES(ckptExtended->ptas->count));
}
else
{
Assert(remainderLen == ckptExtended->dtxCheckpointLen);
ckptExtended->ptas = NULL;
}
}
void
xlog_desc(StringInfo buf, XLogRecord *record)
{
......
......@@ -7105,58 +7105,6 @@ ReadCheckpointRecord(XLogReaderState *xlogreader, XLogRecPtr RecPtr,
return record;
}
/*
* NOTE: There's a copy of this in contrib/pg_xlogdump/compat.c. If you change
* this, update the copy as well!
*
* GPDB_93_MERGE_FIXME: refactor this to avoid the duplication.
*/
void
UnpackCheckPointRecord(XLogRecord *record, CheckpointExtendedRecord *ckptExtended)
{
char *current_record_ptr;
int remainderLen;
if (record->xl_len == sizeof(CheckPoint))
{
/* Special (for bootstrap, xlog switch, maybe others) */
ckptExtended->dtxCheckpoint = NULL;
ckptExtended->dtxCheckpointLen = 0;
ckptExtended->ptas = NULL;
return;
}
/* Normal checkpoint Record */
Assert(record->xl_len > sizeof(CheckPoint));
current_record_ptr = ((char*)XLogRecGetData(record)) + sizeof(CheckPoint);
remainderLen = record->xl_len - sizeof(CheckPoint);
/* Start of distributed transaction information */
ckptExtended->dtxCheckpoint = (TMGXACT_CHECKPOINT *)current_record_ptr;
ckptExtended->dtxCheckpointLen =
TMGXACT_CHECKPOINT_BYTES((ckptExtended->dtxCheckpoint)->committedCount);
/*
* The master prepared transaction aggregate state (ptas) will be skipped
* when gp_before_filespace_setup is ON.
*/
if (remainderLen > ckptExtended->dtxCheckpointLen)
{
current_record_ptr = current_record_ptr + ckptExtended->dtxCheckpointLen;
remainderLen -= ckptExtended->dtxCheckpointLen;
/* Finally, point to prepared transaction information */
ckptExtended->ptas = (prepared_transaction_agg_state *) current_record_ptr;
Assert(remainderLen == PREPARED_TRANSACTION_CHECKPOINT_BYTES(ckptExtended->ptas->count));
}
else
{
Assert(remainderLen == ckptExtended->dtxCheckpointLen);
ckptExtended->ptas = NULL;
}
}
/*
* This must be called during startup of a backend process, except that
* it need not be called in a standalone backend (which does StartupXLOG
......
......@@ -309,6 +309,8 @@ extern Buffer RestoreBackupBlock(XLogRecPtr lsn, XLogRecord *record,
extern void xlog_redo(XLogRecPtr beginLoc __attribute__((unused)), XLogRecPtr lsn __attribute__((unused)), XLogRecord *record);
extern void xlog_desc(StringInfo buf, XLogRecord *record);
extern void UnpackCheckPointRecord(struct XLogRecord *record, CheckpointExtendedRecord *ckptExtended);
extern void issue_xlog_fsync(int fd, XLogSegNo segno);
......
......@@ -300,6 +300,4 @@ extern bool XLogArchiveCheckDone(const char *xlog);
extern bool XLogArchiveIsBusy(const char *xlog);
extern void XLogArchiveCleanup(const char *xlog);
extern void UnpackCheckPointRecord(struct XLogRecord *record, CheckpointExtendedRecord *ckptExtended);
#endif /* XLOG_INTERNAL_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册