]> granicus.if.org Git - postgresql/commitdiff
Remove dedicated B-tree root-split record types.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 16 Aug 2017 09:16:18 +0000 (12:16 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 16 Aug 2017 09:24:40 +0000 (12:24 +0300)
Since commit 40dae7ec53, which changed the way b-tree page splitting
works, there has been no difference in the handling of root, and non-root
split WAL records. We don't need to distinguish them anymore

If you're worried about the loss of debugging information, note that
usually a root split record will normally be followed by a WAL record to
create the new root page. The root page will also have the BTP_ROOT flag
set on the page itself, and there is a pointer to it from the metapage.

Author: Aleksander Alekseev
Discussion: https://www.postgresql.org/message-id/20170406122116.GA11081@e733.localdomain

src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtxlog.c
src/backend/access/rmgrdesc/nbtdesc.c
src/include/access/nbtxlog.h

index 4aca7e4db8f8cef3b7e3dede0d456f50f42084f5..bf963fcdef22252f79b10ae6f1280ce42ef630a5 100644 (file)
@@ -980,7 +980,6 @@ _bt_split(Relation rel, Buffer buf, Buffer cbuf, OffsetNumber firstright,
                                rightoff;
        OffsetNumber maxoff;
        OffsetNumber i;
-       bool            isroot;
        bool            isleaf;
 
        /* Acquire a new page to split into */
@@ -1019,7 +1018,6 @@ _bt_split(Relation rel, Buffer buf, Buffer cbuf, OffsetNumber firstright,
        lopaque = (BTPageOpaque) PageGetSpecialPointer(leftpage);
        ropaque = (BTPageOpaque) PageGetSpecialPointer(rightpage);
 
-       isroot = P_ISROOT(oopaque);
        isleaf = P_ISLEAF(oopaque);
 
        /* if we're splitting this page, it won't be the root when we're done */
@@ -1330,11 +1328,7 @@ _bt_split(Relation rel, Buffer buf, Buffer cbuf, OffsetNumber firstright,
                                                        (char *) rightpage + ((PageHeader) rightpage)->pd_upper,
                                                        ((PageHeader) rightpage)->pd_special - ((PageHeader) rightpage)->pd_upper);
 
-               if (isroot)
-                       xlinfo = newitemonleft ? XLOG_BTREE_SPLIT_L_ROOT : XLOG_BTREE_SPLIT_R_ROOT;
-               else
-                       xlinfo = newitemonleft ? XLOG_BTREE_SPLIT_L : XLOG_BTREE_SPLIT_R;
-
+               xlinfo = newitemonleft ? XLOG_BTREE_SPLIT_L : XLOG_BTREE_SPLIT_R;
                recptr = XLogInsert(RM_BTREE_ID, xlinfo);
 
                PageSetLSN(origpage, recptr);
index ac60db0d4904b4525a928948645c6f175fef169f..3610c7c7e0f5521fe4df95cb304ce5ff7cedf7cd 100644 (file)
@@ -193,7 +193,7 @@ btree_xlog_insert(bool isleaf, bool ismeta, XLogReaderState *record)
 }
 
 static void
-btree_xlog_split(bool onleft, bool isroot, XLogReaderState *record)
+btree_xlog_split(bool onleft, XLogReaderState *record)
 {
        XLogRecPtr      lsn = record->EndRecPtr;
        xl_btree_split *xlrec = (xl_btree_split *) XLogRecGetData(record);
@@ -996,16 +996,10 @@ btree_redo(XLogReaderState *record)
                        btree_xlog_insert(false, true, record);
                        break;
                case XLOG_BTREE_SPLIT_L:
-                       btree_xlog_split(true, false, record);
+                       btree_xlog_split(true, record);
                        break;
                case XLOG_BTREE_SPLIT_R:
-                       btree_xlog_split(false, false, record);
-                       break;
-               case XLOG_BTREE_SPLIT_L_ROOT:
-                       btree_xlog_split(true, true, record);
-                       break;
-               case XLOG_BTREE_SPLIT_R_ROOT:
-                       btree_xlog_split(false, true, record);
+                       btree_xlog_split(false, record);
                        break;
                case XLOG_BTREE_VACUUM:
                        btree_xlog_vacuum(record);
index ad6bba6130bd0d3c1d969961452b0597f5900c5f..a3e1331fe292a6bbf8e34936842f7384c2e772e6 100644 (file)
@@ -35,8 +35,6 @@ btree_desc(StringInfo buf, XLogReaderState *record)
                        }
                case XLOG_BTREE_SPLIT_L:
                case XLOG_BTREE_SPLIT_R:
-               case XLOG_BTREE_SPLIT_L_ROOT:
-               case XLOG_BTREE_SPLIT_R_ROOT:
                        {
                                xl_btree_split *xlrec = (xl_btree_split *) rec;
 
@@ -121,12 +119,6 @@ btree_identify(uint8 info)
                case XLOG_BTREE_SPLIT_R:
                        id = "SPLIT_R";
                        break;
-               case XLOG_BTREE_SPLIT_L_ROOT:
-                       id = "SPLIT_L_ROOT";
-                       break;
-               case XLOG_BTREE_SPLIT_R_ROOT:
-                       id = "SPLIT_R_ROOT";
-                       break;
                case XLOG_BTREE_VACUUM:
                        id = "VACUUM";
                        break;
index a46e9c36f33537c1ec7eabea43df0fdc888843f2..e3cddb2e641892fd3a39b36a1ba227bf9967e39e 100644 (file)
@@ -28,8 +28,7 @@
 #define XLOG_BTREE_INSERT_META 0x20    /* same, plus update metapage */
 #define XLOG_BTREE_SPLIT_L             0x30    /* add index tuple with split */
 #define XLOG_BTREE_SPLIT_R             0x40    /* as above, new item on right */
-#define XLOG_BTREE_SPLIT_L_ROOT 0x50   /* add tuple with split of root */
-#define XLOG_BTREE_SPLIT_R_ROOT 0x60   /* as above, new item on right */
+/* 0x50 and 0x60 are unused */
 #define XLOG_BTREE_DELETE              0x70    /* delete leaf index tuples for a page */
 #define XLOG_BTREE_UNLINK_PAGE 0x80    /* delete a half-dead page */
 #define XLOG_BTREE_UNLINK_PAGE_META 0x90       /* same, and update metapage */