Skip to content

Commit 24d0fe1

Browse files
author
Nikita Glukhov
committed
Fix double detoasting of compressed jsonbs
1 parent 5a3015c commit 24d0fe1

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
@@ -2850,15 +2850,13 @@ jsonbzIteratorInit(JsonContainer *jc)
28502850
}
28512851

28522852
static void
2853-
jsonbzInit(JsonContainerData *jc, Datum value)
2853+
jsonbzInitFromCompresedDatum(JsonContainerData *jc, CompressedDatum *cd)
28542854
{
28552855
CompressedJsonb *cjb = palloc(sizeof(*cjb));
2856-
CompressedDatum *cd = palloc(sizeof(*cd));
28572856

28582857
cjb->datum = cd;
28592858
cjb->offset = offsetof(Jsonb, root);
28602859

2861-
CompressedDatumInit(cd, value);
28622860
if (!jsonb_partial_decompression)
28632861
CompressedDatumDecompressAll(cd);
28642862
else
@@ -2867,6 +2865,16 @@ jsonbzInit(JsonContainerData *jc, Datum value)
28672865
jsonbzInitContainer(jc, cjb, VARSIZE_ANY_EXHDR(cd->data)); // cd->total_len - VARHDRSZ
28682866
}
28692867

2868+
static void
2869+
jsonbzInit(JsonContainerData *jc, Datum value)
2870+
{
2871+
CompressedDatum *cd = palloc(sizeof(*cd));
2872+
2873+
CompressedDatumInit(cd, value);
2874+
2875+
jsonbzInitFromCompresedDatum(jc, cd);
2876+
}
2877+
28702878
JsonContainerOps
28712879
jsonbzContainerOps =
28722880
{
@@ -2910,7 +2918,8 @@ DatumGetJsonbPC(Datum datum, Json *tmp, bool copy)
29102918

29112919
js = JsonExpand(tmp, (Datum) 0, false, &jsonbzContainerOps);
29122920

2913-
jsonbzInit(&js->root, datum);
2921+
jsonbzInitFromCompresedDatum(&js->root,
2922+
memcpy(palloc(sizeof(cd)), &cd, sizeof(cd)));
29142923

29152924
return js;
29162925
}

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