pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Clean up manipulations of hash indexes' hasho_flag field.
Date: Fri, 14 Apr 2017 21:04:32 +0000
Message-ID: <E1cz8OO-0000LG-Vt@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Clean up manipulations of hash indexes' hasho_flag field.

Standardize on testing a hash index page's type by doing
	(opaque->hasho_flag & LH_PAGE_TYPE) == LH_xxx_PAGE
Various places were taking shortcuts like
	opaque->hasho_flag & LH_BUCKET_PAGE
which while not actually wrong, is still bad practice because
it encourages use of
	opaque->hasho_flag & LH_UNUSED_PAGE
which *is* wrong (LH_UNUSED_PAGE == 0, so the above is constant false).
hash_xlog.c's hash_mask() contained such an incorrect test.

This also ensures that we mask out the additional flag bits that
hasho_flag has accreted since 9.6.  pgstattuple's pgstat_hash_page(),
for one, was failing to do that and was thus actively broken.

Also fix assorted comments that hadn't been updated to reflect the
extended usage of hasho_flag, and fix some macros that were testing
just "(hasho_flag & bit)" to use the less dangerous, project-approved
form "((hasho_flag & bit) != 0)".

Coverity found the bug in hash_mask(); I noted the one in
pgstat_hash_page() through code reading.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/2040bb4a0b50ef0434a1a723f00d040ab4f1c06f

Modified Files
--------------
contrib/pageinspect/hashfuncs.c     | 12 +++++++-----
contrib/pgstattuple/pgstattuple.c   |  2 +-
src/backend/access/hash/hash_xlog.c |  8 +++++---
src/backend/access/hash/hashovfl.c  |  2 +-
src/backend/access/hash/hashutil.c  |  4 ++--
src/include/access/hash.h           | 26 +++++++++++++-------------
6 files changed, 29 insertions(+), 25 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


view thread (3+ messages)  latest in thread

Message-ID: <E1cz8OO-0000LG-Vt@gemulon.postgresql.org>
Permalink:  ../E1cz8OO-0000LG-Vt@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1cz8OO-0000LG-Vt@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Clean up manipulations of hash indexes' hasho_flag field.
  In-Reply-To: <E1cz8OO-0000LG-Vt@gemulon.postgresql.org>
  References: <E1cz8OO-0000LG-Vt@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox