Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9bc9f72

Browse files
author
Amit Kapila
committed
MAXALIGN the target address where we store flattened value.
The API (EOH_flatten_into) that flattens the expanded value representation expects the target address to be maxaligned. All it's usage adhere to that principle except when serializing datums for parallel query. Fix that usage. Diagnosed-by: Tom Lane Author: Tom Lane and Amit Kapila Backpatch-through: 9.6 Discussion: https://postgr.es/m/11629.1536550032@sss.pgh.pa.us
1 parent a33245a commit 9bc9f72

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/backend/utils/adt/datum.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,19 @@ datumSerialize(Datum value, bool isnull, bool typByVal, int typLen,
338338
}
339339
else if (eoh)
340340
{
341-
EOH_flatten_into(eoh, (void *) *start_address, header);
341+
char *tmp;
342+
343+
/*
344+
* EOH_flatten_into expects the target address to be maxaligned,
345+
* so we can't store directly to *start_address.
346+
*/
347+
tmp = (char *) palloc(header);
348+
EOH_flatten_into(eoh, (void *) tmp, header);
349+
memcpy(*start_address, tmp, header);
342350
*start_address += header;
351+
352+
/* be tidy. */
353+
pfree(tmp);
343354
}
344355
else
345356
{

0 commit comments

Comments
 (0)