summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/datum.c
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2018-10-03 09:54:01 +0530
committerAmit Kapila <akapila@postgresql.org>2018-10-03 09:54:01 +0530
commitdca44d07c585637d8245a46a29be732241fa40bf (patch)
tree8a371a4320f4dba0ca2008dcb61766b16bd2da3a /src/backend/utils/adt/datum.c
parentd5895717e000f3b6a89a9e290a47e9edb64eea28 (diff)
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
Diffstat (limited to 'src/backend/utils/adt/datum.c')
-rw-r--r--src/backend/utils/adt/datum.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c
index d02e3c81106..76e99ccf4ee 100644
--- a/src/backend/utils/adt/datum.c
+++ b/src/backend/utils/adt/datum.c
@@ -334,8 +334,19 @@ datumSerialize(Datum value, bool isnull, bool typByVal, int typLen,
}
else if (eoh)
{
- EOH_flatten_into(eoh, (void *) *start_address, header);
+ char *tmp;
+
+ /*
+ * EOH_flatten_into expects the target address to be maxaligned,
+ * so we can't store directly to *start_address.
+ */
+ tmp = (char *) palloc(header);
+ EOH_flatten_into(eoh, (void *) tmp, header);
+ memcpy(*start_address, tmp, header);
*start_address += header;
+
+ /* be tidy. */
+ pfree(tmp);
}
else
{