pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Clean up manipulations of hash indexes' hasho_flag field.
3+ messages / 2 participants
[nested] [flat]
* pgsql: Clean up manipulations of hash indexes' hasho_flag field.
@ 2017-04-14 21:04 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2017-04-14 21:04 UTC (permalink / raw)
To: pgsql-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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: Clean up manipulations of hash indexes' hasho_flag field.
@ 2017-04-15 14:20 Amit Kapila <amit.kapila16@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Amit Kapila @ 2017-04-15 14:20 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers
On Sat, Apr 15, 2017 at 2:34 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Clean up manipulations of hash indexes' hasho_flag field.
>
Attached patch to fix one remaining cleanup for the hasho_flag field.
--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Attachments:
change_usage_hashho_flag.patch (application/octet-stream, 515B) download
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index 8092361..3eb5b1d 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -897,7 +897,7 @@ hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf,
* flag.
*/
if (tuples_removed && *tuples_removed > 0 &&
- opaque->hasho_flag & LH_PAGE_HAS_DEAD_TUPLES)
+ H_HAS_DEAD_TUPLES(opaque))
{
opaque->hasho_flag &= ~LH_PAGE_HAS_DEAD_TUPLES;
clear_dead_marking = true;
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: Clean up manipulations of hash indexes' hasho_flag field.
@ 2017-04-15 18:11 Tom Lane <tgl@sss.pgh.pa.us>
parent: Amit Kapila <amit.kapila16@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2017-04-15 18:11 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: pgsql-committers
Amit Kapila <amit.kapila16@gmail.com> writes:
> Attached patch to fix one remaining cleanup for the hasho_flag field.
Pushed, thanks.
regards, tom lane
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2017-04-15 18:11 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-04-14 21:04 pgsql: Clean up manipulations of hash indexes' hasho_flag field. Tom Lane <tgl@sss.pgh.pa.us>
2017-04-15 14:20 ` Amit Kapila <amit.kapila16@gmail.com>
2017-04-15 18:11 ` Tom Lane <tgl@sss.pgh.pa.us>
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