Skip to content

Commit 86b1afa

Browse files
author
Nikita Glukhov
committed
Fix double detoasting of compressed jsonbs
1 parent eb7f58f commit 86b1afa

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/backend/utils/adt/jsonb_util.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,15 +2864,13 @@ jsonbzIteratorInit(JsonContainer *jc)
28642864
}
28652865

28662866
static void
2867-
jsonbzInit(JsonContainerData *jc, Datum value)
2867+
jsonbzInitFromCompresedDatum(JsonContainerData *jc, CompressedDatum *cd)
28682868
{
28692869
CompressedJsonb *cjb = palloc(sizeof(*cjb));
2870-
CompressedDatum *cd = palloc(sizeof(*cd));
28712870

28722871
cjb->datum = cd;
28732872
cjb->offset = offsetof(Jsonb, root);
28742873

2875-
CompressedDatumInit(cd, value);
28762874
if (!jsonb_partial_decompression)
28772875
CompressedDatumDecompressAll(cd);
28782876
else
@@ -2881,6 +2879,16 @@ jsonbzInit(JsonContainerData *jc, Datum value)
28812879
jsonbzInitContainer(jc, cjb, VARSIZE_ANY_EXHDR(cd->data)); // cd->total_len - VARHDRSZ
28822880
}
28832881

2882+
static void
2883+
jsonbzInit(JsonContainerData *jc, Datum value)
2884+
{
2885+
CompressedDatum *cd = palloc(sizeof(*cd));
2886+
2887+
CompressedDatumInit(cd, value);
2888+
2889+
jsonbzInitFromCompresedDatum(jc, cd);
2890+
}
2891+
28842892
JsonContainerOps
28852893
jsonbzContainerOps =
28862894
{
@@ -2927,7 +2935,8 @@ DatumGetJsonbPC(Datum datum, Json *tmp, bool copy)
29272935

29282936
js = JsonExpand(tmp, (Datum) 0, false, &jsonbzContainerOps);
29292937

2930-
jsonbzInit(&js->root, datum);
2938+
jsonbzInitFromCompresedDatum(&js->root,
2939+
memcpy(palloc(sizeof(cd)), &cd, sizeof(cd)));
29312940

29322941
return js;
29332942
}

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