Skip to content

Commit 7c5d57c

Browse files
committed
Fix portability issue in new jsonbsubs code.
On machines where sizeof(Datum) > sizeof(Oid) (that is, any 64-bit platform), the previous coding would compute a misaligned workspace->index pointer if nupper is odd. Architectures where misaligned access is a hard no-no would then fail. This appears to explain why thorntail is unhappy but other buildfarm members are not.
1 parent aa6e46d commit 7c5d57c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/backend/utils/adt/jsonbsubs.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ jsonb_subscript_fetch_old(ExprState *state,
356356
static void
357357
jsonb_exec_setup(const SubscriptingRef *sbsref,
358358
SubscriptingRefState *sbsrefstate,
359-
SubscriptExecSteps * methods)
359+
SubscriptExecSteps *methods)
360360
{
361361
JsonbSubWorkspace *workspace;
362362
ListCell *lc;
@@ -368,9 +368,14 @@ jsonb_exec_setup(const SubscriptingRef *sbsref,
368368
nupper * (sizeof(Datum) + sizeof(Oid)));
369369
workspace->expectArray = false;
370370
ptr = ((char *) workspace) + MAXALIGN(sizeof(JsonbSubWorkspace));
371-
workspace->indexOid = (Oid *) ptr;
372-
ptr += nupper * sizeof(Oid);
371+
372+
/*
373+
* This coding assumes sizeof(Datum) >= sizeof(Oid), else we might
374+
* misalign the indexOid pointer
375+
*/
373376
workspace->index = (Datum *) ptr;
377+
ptr += nupper * sizeof(Datum);
378+
workspace->indexOid = (Oid *) ptr;
374379

375380
sbsrefstate->workspace = workspace;
376381

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy