heap_insert
xl_heap_insert xlrec;
xl_heap_header xlhdr;
XLogRegisterData((char *) &xlrec, SizeOfHeapInsert);->//xl_heap_insert
|-- XLogRecData *rdata;
| rdata->data = data;
| rdata->len = len;
| mainrdata_last->next = rdata;
| mainrdata_last = rdata;
|-- mainrdata_len += len;
//xl_heap_header+heapup->t_data
XLogRegisterBufData(0, (char *) &xlhdr, SizeOfHeapHeader);->
|-- regbuf = ®istered_buffers[block_id];
| rdata->data = data;
| rdata->len = len;
| regbuf->rdata_tail->next = rdata;
| regbuf->rdata_tail = rdata;
|-- regbuf->rdata_len += len;
XLogRegisterBufData(0,(char *) heaptup->t_data + SizeofHeapTupleHeader,heaptup->t_len - SizeofHeapTupleHeader);
recptr = XLogInsert(RM_HEAP_ID, info);->
|-- rdt = XLogRecordAssemble(rmid, info, RedoRecPtr, doPageWrites,&fpw_lsn);
|-- EndPos = XLogInsertRecord(rdt, fpw_lsn, curinsert_flags);
static XLogRecData hdr_rdt;
XLogRecordAssemble:
char *scratch = hdr_scratch;//hdr_scratch是一个xlog记录的开始位置
rechdr = (XLogRecord *) scratch;
scratch += SizeOfXLogRecord;
hdr_rdt.next = NULL;
rdt_datas_last = &hdr_rdt;//xlog记录链表头
hdr_rdt.data = hdr_scratch;
//hdr_rdt->next=xl_heap_header+heapup->t_data
registered_buffer *regbuf = ®istered_buffers[block_id];
rdt_datas_last->next = regbuf->rdata_head;
dt_datas_last = regbuf->rdata_tail;
//xl_heap_header+heapup->t_data后面紧跟着xl_heap_insert
rdt_datas_last->next = mainrdata_head;
rdt_datas_last = mainrdata_last;