pgsql: Ensure proper alignment of tuples in HashMemoryChunkData buffers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Ensure proper alignment of tuples in HashMemoryChunkData buffers
Date: 2018-01-03 02:23:22
Message-ID: E1eWYiA-0001Tq-DI@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Ensure proper alignment of tuples in HashMemoryChunkData buffers.

The previous coding relied (without any documentation) on the data[]
member of HashMemoryChunkData being at a MAXALIGN'ed offset. If it
was not, the tuples would not be maxaligned either, leading to failures
on alignment-picky machines. While there seems to be no live bug on any
platform we support, this is clearly pretty fragile: any addition to or
rearrangement of the fields in HashMemoryChunkData could break it.
Let's remove the hazard by getting rid of the data[] member and instead
using pointer arithmetic with an explicitly maxalign'ed offset.

Discussion: https://postgr.es/m/14483.1514938129@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5dc692f78d3bee1e86d095a9e8d9242b44f78b01

Modified Files
--------------
src/backend/executor/nodeHash.c | 34 +++++++++++++++-------------------
src/include/executor/hashjoin.h | 12 +++++++++---
2 files changed, 24 insertions(+), 22 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2018-01-03 03:12:55 pgsql: Simplify representation of aggregate transition values a bit.
Previous Message Alvaro Herrera 2018-01-03 02:20:14 pgsql: Fix deadlock hazard in CREATE INDEX CONCURRENTLY