From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Small code improvement for btree |
Date: | 2017-08-04 18:12:33 |
Message-ID: | 20170804181233.lohknf2tqsdlz5fg@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Masahiko Sawada wrote:
> While hacking the btree code I found two points we can improve in nbtxlog.c.
>
> @@ -135,7 +135,7 @@ _bt_clear_incomplete_split(XLogReaderState
> *record, uint8 block_id)
> Page page = (Page) BufferGetPage(buf);
> BTPageOpaque pageop = (BTPageOpaque)
> PageGetSpecialPointer(page);
>
> - Assert((pageop->btpo_flags & BTP_INCOMPLETE_SPLIT) != 0);
> + Assert(P_INCOMPLETE_SPLIT(pageop) != 0);
> pageop->btpo_flags &= ~BTP_INCOMPLETE_SPLIT;
Interesting. We learned elsewhere that it's better to integrate the
"!= 0" test as part of the macro definition; so a
better formulation of this patch would be to change the
P_INCOMPLETE_SPLIT macro and omit the comparison in the Assert. (See
commit 594e61a1de03 for an example).
> - LockBuffer(hbuffer, BUFFER_LOCK_SHARE);
> + LockBuffer(hbuffer, BT_READ);
I think BT_READ and BT_WRITE are useless, and I'd rather get rid of
them ...
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2017-08-04 18:15:40 | Re: pgsql 10: hash indexes testing |
Previous Message | Robert Haas | 2017-08-04 18:09:03 | Re: Page Scan Mode in Hash Index |