@@ -141,6 +141,7 @@ jsonx_toast_make_pointer_compressed_chunks(Oid toasterid,
141
141
struct varlena *
142
142
jsonx_toast_make_pointer_diff (Oid toasterid ,
143
143
struct varatt_external * toast_pointer ,
144
+ bool compressed_chunks ,
144
145
int32 diff_offset , int32 diff_len ,
145
146
const void * diff_data )
146
147
{
@@ -150,7 +151,10 @@ jsonx_toast_make_pointer_diff(Oid toasterid,
150
151
TOAST_POINTER_SIZE + offsetof(JsonxPointerDiff , data ) + diff_len ;
151
152
152
153
struct varlena * result =
153
- jsonx_toast_make_custom_pointer (toasterid , JSONX_POINTER_DIFF ,
154
+ jsonx_toast_make_custom_pointer (toasterid ,
155
+ compressed_chunks ?
156
+ JSONX_POINTER_DIFF_COMP :
157
+ JSONX_POINTER_DIFF ,
154
158
datalen , toast_pointer -> va_rawsize , & data );
155
159
156
160
SET_VARTAG_EXTERNAL (data , VARTAG_ONDISK );
@@ -169,7 +173,10 @@ jsonxMakeToastPointer(JsonbToastedContainerPointerData *ptr)
169
173
if (ptr -> ntids || ptr -> has_diff )
170
174
{
171
175
char * data ;
172
- uint32 header = ptr -> has_diff ? JSONX_POINTER_DIFF :
176
+ uint32 header = ptr -> has_diff ?
177
+ (ptr -> compressed_chunks ?
178
+ JSONX_POINTER_DIFF_COMP :
179
+ JSONX_POINTER_DIFF ) :
173
180
ptr -> ntids | (ptr -> compressed_tids ?
174
181
JSONX_POINTER_DIRECT_TIDS_COMP :
175
182
JSONX_POINTER_DIRECT_TIDS );
@@ -209,7 +216,9 @@ jsonxWriteToastPointer(StringInfo buffer, JsonbToastedContainerPointerData *ptr)
209
216
char custom_ptr [JSONX_CUSTOM_PTR_HEADER_SIZE ];
210
217
char toast_ptr [TOAST_POINTER_SIZE ];
211
218
uint32 header = ptr -> has_diff ?
212
- JSONX_POINTER_DIFF :
219
+ (ptr -> compressed_chunks ?
220
+ JSONX_POINTER_DIFF_COMP :
221
+ JSONX_POINTER_DIFF ) :
213
222
ptr -> ntids | (ptr -> compressed_tids ?
214
223
JSONX_POINTER_DIRECT_TIDS_COMP :
215
224
JSONX_POINTER_DIRECT_TIDS );
@@ -989,12 +998,16 @@ jsonx_create_fetch_datum_iterator(struct varlena *attr, Oid toasterid,
989
998
iter -> toasterid = toasterid ;
990
999
iter -> chunk_tids_inline_size = inline_size ;
991
1000
992
- if (inline_size <= 0 || type == JSONX_POINTER_DIFF )
1001
+ if (inline_size <= 0 ||
1002
+ type == JSONX_POINTER_DIFF ||
1003
+ type == JSONX_POINTER_DIFF_COMP )
993
1004
{
994
1005
iter -> nchunk_tids = 0 ;
995
1006
iter -> chunk_tids = NULL ;
996
1007
iter -> compressed_chunk_tids = NULL ;
997
- iter -> compressed_chunks = type == JSONX_POINTER_COMPRESSED_CHUNKS ;
1008
+ iter -> compressed_chunks =
1009
+ type == JSONX_POINTER_COMPRESSED_CHUNKS ||
1010
+ type == JSONX_POINTER_DIFF_COMP ;
998
1011
}
999
1012
else
1000
1013
{
@@ -1628,7 +1641,8 @@ jsonx_create_detoast_iterator(struct varlena *attr)
1628
1641
/* prepare buffer to received decompressed data */
1629
1642
iter -> buf = create_toast_buffer (toast_pointer .va_rawsize , false);
1630
1643
1631
- if (type == JSONX_POINTER_DIFF )
1644
+ if (type == JSONX_POINTER_DIFF ||
1645
+ type == JSONX_POINTER_DIFF_COMP )
1632
1646
iter -> orig_buf = create_toast_buffer (toast_pointer .va_rawsize , false);
1633
1647
else
1634
1648
iter -> orig_buf = iter -> buf ;
@@ -1642,7 +1656,8 @@ jsonx_create_detoast_iterator(struct varlena *attr)
1642
1656
iter -> buf = iter -> orig_buf = iter -> fetch_datum_iterator -> buf ;
1643
1657
}
1644
1658
1645
- if (type == JSONX_POINTER_DIFF )
1659
+ if (type == JSONX_POINTER_DIFF ||
1660
+ type == JSONX_POINTER_DIFF_COMP )
1646
1661
{
1647
1662
JsonxPointerDiff * diff = (JsonxPointerDiff * ) inline_data ;
1648
1663
0 commit comments