Commit 80634e3b authored by Peter Geoghegan's avatar Peter Geoghegan

Rearrange _bt_insertonpg() "update metapage" code.

Nest the "update metapage as part of insert into root-like page" branch
inside the broader "insert into internal page" branch.  This improves
readability.
parent 8128b0c1
...@@ -1306,6 +1306,7 @@ _bt_insertonpg(Relation rel, ...@@ -1306,6 +1306,7 @@ _bt_insertonpg(Relation rel,
* Leaf insert with posting list split. Must include * Leaf insert with posting list split. Must include
* postingoff field before newitem/orignewitem. * postingoff field before newitem/orignewitem.
*/ */
Assert(isleaf);
xlinfo = XLOG_BTREE_INSERT_POST; xlinfo = XLOG_BTREE_INSERT_POST;
} }
else else
...@@ -1313,31 +1314,34 @@ _bt_insertonpg(Relation rel, ...@@ -1313,31 +1314,34 @@ _bt_insertonpg(Relation rel,
/* Internal page insert, which finishes a split on cbuf */ /* Internal page insert, which finishes a split on cbuf */
xlinfo = XLOG_BTREE_INSERT_UPPER; xlinfo = XLOG_BTREE_INSERT_UPPER;
XLogRegisterBuffer(1, cbuf, REGBUF_STANDARD); XLogRegisterBuffer(1, cbuf, REGBUF_STANDARD);
}
if (BufferIsValid(metabuf)) if (BufferIsValid(metabuf))
{ {
Assert(metad->btm_version >= BTREE_NOVAC_VERSION); /* Actually, it's an internal page insert + meta update */
xlmeta.version = metad->btm_version; xlinfo = XLOG_BTREE_INSERT_META;
xlmeta.root = metad->btm_root;
xlmeta.level = metad->btm_level; Assert(metad->btm_version >= BTREE_NOVAC_VERSION);
xlmeta.fastroot = metad->btm_fastroot; xlmeta.version = metad->btm_version;
xlmeta.fastlevel = metad->btm_fastlevel; xlmeta.root = metad->btm_root;
xlmeta.oldest_btpo_xact = metad->btm_oldest_btpo_xact; xlmeta.level = metad->btm_level;
xlmeta.last_cleanup_num_heap_tuples = xlmeta.fastroot = metad->btm_fastroot;
metad->btm_last_cleanup_num_heap_tuples; xlmeta.fastlevel = metad->btm_fastlevel;
xlmeta.allequalimage = metad->btm_allequalimage; xlmeta.oldest_btpo_xact = metad->btm_oldest_btpo_xact;
xlmeta.last_cleanup_num_heap_tuples =
XLogRegisterBuffer(2, metabuf, REGBUF_WILL_INIT | REGBUF_STANDARD); metad->btm_last_cleanup_num_heap_tuples;
XLogRegisterBufData(2, (char *) &xlmeta, sizeof(xl_btree_metadata)); xlmeta.allequalimage = metad->btm_allequalimage;
xlinfo = XLOG_BTREE_INSERT_META; XLogRegisterBuffer(2, metabuf,
REGBUF_WILL_INIT | REGBUF_STANDARD);
XLogRegisterBufData(2, (char *) &xlmeta,
sizeof(xl_btree_metadata));
}
} }
XLogRegisterBuffer(0, buf, REGBUF_STANDARD); XLogRegisterBuffer(0, buf, REGBUF_STANDARD);
if (postingoff == 0) if (postingoff == 0)
{ {
/* Simple, common case -- log itup from caller */ /* Just log itup from caller */
XLogRegisterBufData(0, (char *) itup, IndexTupleSize(itup)); XLogRegisterBufData(0, (char *) itup, IndexTupleSize(itup));
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment