2010-02-07 15:48:13 -05:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* relmapper.h
|
|
|
|
|
* Catalog-to-filenode mapping
|
|
|
|
|
*
|
|
|
|
|
*
|
2017-01-03 13:48:53 -05:00
|
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
2010-02-07 15:48:13 -05:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
|
*
|
2010-09-20 16:08:53 -04:00
|
|
|
* src/include/utils/relmapper.h
|
2010-02-07 15:48:13 -05:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
#ifndef RELMAPPER_H
|
|
|
|
|
#define RELMAPPER_H
|
|
|
|
|
|
Revamp the WAL record format.
Each WAL record now carries information about the modified relation and
block(s) in a standardized format. That makes it easier to write tools that
need that information, like pg_rewind, prefetching the blocks to speed up
recovery, etc.
There's a whole new API for building WAL records, replacing the XLogRecData
chains used previously. The new API consists of XLogRegister* functions,
which are called for each buffer and chunk of data that is added to the
record. The new API also gives more control over when a full-page image is
written, by passing flags to the XLogRegisterBuffer function.
This also simplifies the XLogReadBufferForRedo() calls. The function can dig
the relation and block number from the WAL record, so they no longer need to
be passed as arguments.
For the convenience of redo routines, XLogReader now disects each WAL record
after reading it, copying the main data part and the per-block data into
MAXALIGNed buffers. The data chunks are not aligned within the WAL record,
but the redo routines can assume that the pointers returned by XLogRecGet*
functions are. Redo routines are now passed the XLogReaderState, which
contains the record in the already-disected format, instead of the plain
XLogRecord.
The new record format also makes the fixed size XLogRecord header smaller,
by removing the xl_len field. The length of the "main data" portion is now
stored at the end of the WAL record, and there's a separate header after
XLogRecord for it. The alignment padding at the end of XLogRecord is also
removed. This compansates for the fact that the new format would otherwise
be more bulky than the old format.
Reviewed by Andres Freund, Amit Kapila, Michael Paquier, Alvaro Herrera,
Fujii Masao.
2014-11-20 10:56:26 -05:00
|
|
|
#include "access/xlogreader.h"
|
2014-11-06 06:52:08 -05:00
|
|
|
#include "lib/stringinfo.h"
|
2010-02-07 15:48:13 -05:00
|
|
|
|
|
|
|
|
/* ----------------
|
|
|
|
|
* relmap-related XLOG entries
|
|
|
|
|
* ----------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define XLOG_RELMAP_UPDATE 0x00
|
|
|
|
|
|
|
|
|
|
typedef struct xl_relmap_update
|
|
|
|
|
{
|
|
|
|
|
Oid dbid; /* database ID, or 0 for shared map */
|
|
|
|
|
Oid tsid; /* database's tablespace, or pg_global */
|
|
|
|
|
int32 nbytes; /* size of relmap data */
|
2015-02-20 00:11:42 -05:00
|
|
|
char data[FLEXIBLE_ARRAY_MEMBER];
|
2010-02-07 15:48:13 -05:00
|
|
|
} xl_relmap_update;
|
|
|
|
|
|
|
|
|
|
#define MinSizeOfRelmapUpdate offsetof(xl_relmap_update, data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern Oid RelationMapOidToFilenode(Oid relationId, bool shared);
|
|
|
|
|
|
2013-07-22 10:34:34 -04:00
|
|
|
extern Oid RelationMapFilenodeToOid(Oid relationId, bool shared);
|
|
|
|
|
|
2010-02-07 15:48:13 -05:00
|
|
|
extern void RelationMapUpdateMap(Oid relationId, Oid fileNode, bool shared,
|
2010-02-25 21:01:40 -05:00
|
|
|
bool immediate);
|
2010-02-07 15:48:13 -05:00
|
|
|
|
|
|
|
|
extern void RelationMapRemoveMapping(Oid relationId);
|
|
|
|
|
|
|
|
|
|
extern void RelationMapInvalidate(bool shared);
|
|
|
|
|
extern void RelationMapInvalidateAll(void);
|
|
|
|
|
|
|
|
|
|
extern void AtCCI_RelationMap(void);
|
|
|
|
|
extern void AtEOXact_RelationMap(bool isCommit);
|
|
|
|
|
extern void AtPrepare_RelationMap(void);
|
|
|
|
|
|
|
|
|
|
extern void CheckPointRelationMap(void);
|
|
|
|
|
|
|
|
|
|
extern void RelationMapFinishBootstrap(void);
|
|
|
|
|
|
|
|
|
|
extern void RelationMapInitialize(void);
|
|
|
|
|
extern void RelationMapInitializePhase2(void);
|
|
|
|
|
extern void RelationMapInitializePhase3(void);
|
|
|
|
|
|
Revamp the WAL record format.
Each WAL record now carries information about the modified relation and
block(s) in a standardized format. That makes it easier to write tools that
need that information, like pg_rewind, prefetching the blocks to speed up
recovery, etc.
There's a whole new API for building WAL records, replacing the XLogRecData
chains used previously. The new API consists of XLogRegister* functions,
which are called for each buffer and chunk of data that is added to the
record. The new API also gives more control over when a full-page image is
written, by passing flags to the XLogRegisterBuffer function.
This also simplifies the XLogReadBufferForRedo() calls. The function can dig
the relation and block number from the WAL record, so they no longer need to
be passed as arguments.
For the convenience of redo routines, XLogReader now disects each WAL record
after reading it, copying the main data part and the per-block data into
MAXALIGNed buffers. The data chunks are not aligned within the WAL record,
but the redo routines can assume that the pointers returned by XLogRecGet*
functions are. Redo routines are now passed the XLogReaderState, which
contains the record in the already-disected format, instead of the plain
XLogRecord.
The new record format also makes the fixed size XLogRecord header smaller,
by removing the xl_len field. The length of the "main data" portion is now
stored at the end of the WAL record, and there's a separate header after
XLogRecord for it. The alignment padding at the end of XLogRecord is also
removed. This compansates for the fact that the new format would otherwise
be more bulky than the old format.
Reviewed by Andres Freund, Amit Kapila, Michael Paquier, Alvaro Herrera,
Fujii Masao.
2014-11-20 10:56:26 -05:00
|
|
|
extern void relmap_redo(XLogReaderState *record);
|
|
|
|
|
extern void relmap_desc(StringInfo buf, XLogReaderState *record);
|
2014-09-19 09:17:12 -04:00
|
|
|
extern const char *relmap_identify(uint8 info);
|
2010-02-07 15:48:13 -05:00
|
|
|
|
|
|
|
|
#endif /* RELMAPPER_H */
|