其insert由函數heapam_tuple_insert完成。
1、首先需要從slot中取出tuple值,HeapTupleTableSlot.tuple
2、從relation中得到該記錄即將插入表的OID:relation->rd_id,然後slot->tts_tableOid和tuple->t_tableOid更新爲該OID
3、調用heap_insert將tuple插入heap 頁中,這個過程中產生WAL日誌並寫入WAL BUFFER中:
1)生成事務ID:xid
2)調用函數heap_prepare_insert:設置tup->t_data的t_infomask和t_infomask2;tup->t_data->t_choice.t_heap.t_xmin爲xid;
(tup->t_data)->t_choice.t_heap.t_field3.t_cid爲入參cid
(tup->t_data)->t_choice.t_heap.t_xmax爲0