aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Geoghegan <pg@bowt.ie>2020-04-13 21:11:03 -0700
committerPeter Geoghegan <pg@bowt.ie>2020-04-13 21:11:03 -0700
commitf762b2feba276a627585cb7e834fb7a1bf4c549d (patch)
treef449f80de80c227bfd5c5643b20ba659438a2ca0 /src
parenta6fea120a7e3858e642bb5e96027f166a1a6f134 (diff)
downloadpostgresql-f762b2feba276a627585cb7e834fb7a1bf4c549d.tar.gz
postgresql-f762b2feba276a627585cb7e834fb7a1bf4c549d.zip
Add defensive "split_only_page" nbtree assertion.
Clearly it's not okay for nbtree to split a page that is the only page on its level, and then find that it has to split the parent one level up in turn. There is simply no code to handle the split_only_page case in the _bt_insertonpg() "newitem won't fit" branch (only the "newitem fits" branch handles split_only_page). Add a defensive assertion that will fail if a split_only_page call to _bt_insertonpg() somehow ends up splitting the target/parent page. I (pgeoghegan) believe that we don't need split_only_page handling for the "newitem won't fit" branch because anybody calling _bt_insertonpg() like this would have to hold a lock on the same one and only child page.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/nbtree/nbtinsert.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c
index 4fa2e85877a..3a7f25df813 100644
--- a/src/backend/access/nbtree/nbtinsert.c
+++ b/src/backend/access/nbtree/nbtinsert.c
@@ -1183,6 +1183,8 @@ _bt_insertonpg(Relation rel,
bool is_only = P_LEFTMOST(lpageop) && P_RIGHTMOST(lpageop);
Buffer rbuf;
+ Assert(!split_only_page);
+
/* split the buffer into left and right halves */
rbuf = _bt_split(rel, itup_key, buf, cbuf, newitemoff, itemsz, itup,
origitup, nposting, postingoff);