Skip to content

Commit 38259fd

Browse files
author
Nikita Glukhov
committed
Fix initialization of JsonbzArrayIterator
1 parent b9acb6b commit 38259fd

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/backend/utils/adt/jsonb_util.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,10 +2855,23 @@ JsonbzArrayIteratorInit(JsonbzArrayIterator *it, CompressedJsonb *cjb)
28552855
#endif
28562856
const JsonbContainerHeader *jbc = (const JsonbContainerHeader *)((char *) jb + cjb->offset);
28572857

2858+
#ifndef JSONB_DETOAST_ITERATOR
2859+
CompressedDatumDecompress(cjb->datum, cjb->offset + ((char *) &jbc->children - (char *) jbc));
2860+
#else
2861+
PG_DETOAST_ITERATE(cjb->iter, (const char *) &jbc->children);
2862+
#endif
2863+
2864+
it->count = (jbc->header & JBC_CMASK);
2865+
2866+
#ifndef JSONB_DETOAST_ITERATOR
2867+
CompressedDatumDecompress(cjb->datum, cjb->offset + ((char *) &jbc->children[it->count] - (char *) jbc));
2868+
#else
2869+
PG_DETOAST_ITERATE(cjb->iter, (const char *) &jbc->children[it->count]);
2870+
#endif
2871+
28582872
it->cjb = cjb;
28592873
it->container = jbc;
28602874
it->index = 0;
2861-
it->count = (jbc->header & JBC_CMASK);
28622875
it->offset = 0;
28632876
it->base_addr = (char *) &jbc->children[it->count];
28642877
}
@@ -2972,7 +2985,7 @@ jsonbzInitFromDetoastIterator(JsonContainerData *jc, DetoastIterator iter)
29722985
if (!jsonb_partial_decompression)
29732986
PG_DETOAST_ITERATE(iter, iter->buf->capacity);
29742987
else
2975-
PG_DETOAST_ITERATE(iter, Min(iter->buf->buf + offsetof(Jsonb, root.children), iter->buf->capacity));
2988+
PG_DETOAST_ITERATE(iter, Min(iter->buf->buf + offsetof(JsonbDatum, root.children), iter->buf->capacity));
29762989

29772990
jsonbzInitContainer(jc, cjb, VARSIZE_ANY_EXHDR(iter->buf->buf)); // cd->total_len - VARHDRSZ
29782991
#endif

0 commit comments

Comments
 (0)