Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef HEAPAM_XLOG_H
00015 #define HEAPAM_XLOG_H
00016
00017 #include "access/htup.h"
00018 #include "access/xlog.h"
00019 #include "storage/bufpage.h"
00020 #include "storage/relfilenode.h"
00021 #include "utils/relcache.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030 #define XLOG_HEAP_INSERT 0x00
00031 #define XLOG_HEAP_DELETE 0x10
00032 #define XLOG_HEAP_UPDATE 0x20
00033
00034 #define XLOG_HEAP_HOT_UPDATE 0x40
00035 #define XLOG_HEAP_NEWPAGE 0x50
00036 #define XLOG_HEAP_LOCK 0x60
00037 #define XLOG_HEAP_INPLACE 0x70
00038
00039 #define XLOG_HEAP_OPMASK 0x70
00040
00041
00042
00043
00044 #define XLOG_HEAP_INIT_PAGE 0x80
00045
00046
00047
00048
00049
00050
00051 #define XLOG_HEAP2_FREEZE 0x00
00052 #define XLOG_HEAP2_CLEAN 0x10
00053
00054 #define XLOG_HEAP2_CLEANUP_INFO 0x30
00055 #define XLOG_HEAP2_VISIBLE 0x40
00056 #define XLOG_HEAP2_MULTI_INSERT 0x50
00057 #define XLOG_HEAP2_LOCK_UPDATED 0x60
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 typedef struct xl_heaptid
00068 {
00069 RelFileNode node;
00070 ItemPointerData tid;
00071 } xl_heaptid;
00072
00073 #define SizeOfHeapTid (offsetof(xl_heaptid, tid) + SizeOfIptrData)
00074
00075
00076 typedef struct xl_heap_delete
00077 {
00078 xl_heaptid target;
00079 TransactionId xmax;
00080 uint8 infobits_set;
00081 bool all_visible_cleared;
00082 } xl_heap_delete;
00083
00084 #define SizeOfHeapDelete (offsetof(xl_heap_delete, all_visible_cleared) + sizeof(bool))
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 typedef struct xl_heap_header
00095 {
00096 uint16 t_infomask2;
00097 uint16 t_infomask;
00098 uint8 t_hoff;
00099 } xl_heap_header;
00100
00101 #define SizeOfHeapHeader (offsetof(xl_heap_header, t_hoff) + sizeof(uint8))
00102
00103
00104 typedef struct xl_heap_insert
00105 {
00106 xl_heaptid target;
00107 bool all_visible_cleared;
00108
00109 } xl_heap_insert;
00110
00111 #define SizeOfHeapInsert (offsetof(xl_heap_insert, all_visible_cleared) + sizeof(bool))
00112
00113
00114
00115
00116
00117
00118
00119 typedef struct xl_heap_multi_insert
00120 {
00121 RelFileNode node;
00122 BlockNumber blkno;
00123 bool all_visible_cleared;
00124 uint16 ntuples;
00125 OffsetNumber offsets[1];
00126
00127
00128 } xl_heap_multi_insert;
00129
00130 #define SizeOfHeapMultiInsert offsetof(xl_heap_multi_insert, offsets)
00131
00132 typedef struct xl_multi_insert_tuple
00133 {
00134 uint16 datalen;
00135 uint16 t_infomask2;
00136 uint16 t_infomask;
00137 uint8 t_hoff;
00138
00139 } xl_multi_insert_tuple;
00140
00141 #define SizeOfMultiInsertTuple (offsetof(xl_multi_insert_tuple, t_hoff) + sizeof(uint8))
00142
00143
00144 typedef struct xl_heap_update
00145 {
00146 xl_heaptid target;
00147 TransactionId old_xmax;
00148 TransactionId new_xmax;
00149 ItemPointerData newtid;
00150 uint8 old_infobits_set;
00151 bool all_visible_cleared;
00152 bool new_all_visible_cleared;
00153
00154 } xl_heap_update;
00155
00156 #define SizeOfHeapUpdate (offsetof(xl_heap_update, new_all_visible_cleared) + sizeof(bool))
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 typedef struct xl_heap_clean
00170 {
00171 RelFileNode node;
00172 BlockNumber block;
00173 TransactionId latestRemovedXid;
00174 uint16 nredirected;
00175 uint16 ndead;
00176
00177 } xl_heap_clean;
00178
00179 #define SizeOfHeapClean (offsetof(xl_heap_clean, ndead) + sizeof(uint16))
00180
00181
00182
00183
00184
00185
00186 typedef struct xl_heap_cleanup_info
00187 {
00188 RelFileNode node;
00189 TransactionId latestRemovedXid;
00190 } xl_heap_cleanup_info;
00191
00192 #define SizeOfHeapCleanupInfo (sizeof(xl_heap_cleanup_info))
00193
00194
00195
00196 typedef struct xl_heap_newpage
00197 {
00198 RelFileNode node;
00199 ForkNumber forknum;
00200 BlockNumber blkno;
00201
00202 } xl_heap_newpage;
00203
00204 #define SizeOfHeapNewpage (offsetof(xl_heap_newpage, blkno) + sizeof(BlockNumber))
00205
00206
00207 #define XLHL_XMAX_IS_MULTI 0x01
00208 #define XLHL_XMAX_LOCK_ONLY 0x02
00209 #define XLHL_XMAX_EXCL_LOCK 0x04
00210 #define XLHL_XMAX_KEYSHR_LOCK 0x08
00211 #define XLHL_KEYS_UPDATED 0x10
00212
00213
00214 typedef struct xl_heap_lock
00215 {
00216 xl_heaptid target;
00217 TransactionId locking_xid;
00218 int8 infobits_set;
00219 } xl_heap_lock;
00220
00221 #define SizeOfHeapLock (offsetof(xl_heap_lock, infobits_set) + sizeof(int8))
00222
00223
00224 typedef struct xl_heap_lock_updated
00225 {
00226 xl_heaptid target;
00227 TransactionId xmax;
00228 uint8 infobits_set;
00229 } xl_heap_lock_updated;
00230
00231 #define SizeOfHeapLockUpdated (offsetof(xl_heap_lock_updated, infobits_set) + sizeof(uint8))
00232
00233
00234 typedef struct xl_heap_inplace
00235 {
00236 xl_heaptid target;
00237
00238 } xl_heap_inplace;
00239
00240 #define SizeOfHeapInplace (offsetof(xl_heap_inplace, target) + SizeOfHeapTid)
00241
00242
00243 typedef struct xl_heap_freeze
00244 {
00245 RelFileNode node;
00246 BlockNumber block;
00247 TransactionId cutoff_xid;
00248 MultiXactId cutoff_multi;
00249
00250 } xl_heap_freeze;
00251
00252 #define SizeOfHeapFreeze (offsetof(xl_heap_freeze, cutoff_multi) + sizeof(MultiXactId))
00253
00254
00255 typedef struct xl_heap_visible
00256 {
00257 RelFileNode node;
00258 BlockNumber block;
00259 TransactionId cutoff_xid;
00260 } xl_heap_visible;
00261
00262 #define SizeOfHeapVisible (offsetof(xl_heap_visible, cutoff_xid) + sizeof(TransactionId))
00263
00264 extern void HeapTupleHeaderAdvanceLatestRemovedXid(HeapTupleHeader tuple,
00265 TransactionId *latestRemovedXid);
00266
00267 extern void heap_redo(XLogRecPtr lsn, XLogRecord *rptr);
00268 extern void heap_desc(StringInfo buf, uint8 xl_info, char *rec);
00269 extern void heap2_redo(XLogRecPtr lsn, XLogRecord *rptr);
00270 extern void heap2_desc(StringInfo buf, uint8 xl_info, char *rec);
00271
00272 extern XLogRecPtr log_heap_cleanup_info(RelFileNode rnode,
00273 TransactionId latestRemovedXid);
00274 extern XLogRecPtr log_heap_clean(Relation reln, Buffer buffer,
00275 OffsetNumber *redirected, int nredirected,
00276 OffsetNumber *nowdead, int ndead,
00277 OffsetNumber *nowunused, int nunused,
00278 TransactionId latestRemovedXid);
00279 extern XLogRecPtr log_heap_freeze(Relation reln, Buffer buffer,
00280 TransactionId cutoff_xid, MultiXactId cutoff_multi,
00281 OffsetNumber *offsets, int offcnt);
00282 extern XLogRecPtr log_heap_visible(RelFileNode rnode, Buffer heap_buffer,
00283 Buffer vm_buffer, TransactionId cutoff_xid);
00284 extern XLogRecPtr log_newpage(RelFileNode *rnode, ForkNumber forkNum,
00285 BlockNumber blk, Page page);
00286 extern XLogRecPtr log_newpage_buffer(Buffer buffer);
00287
00288 #endif