@@ -141,6 +141,7 @@ jsonx_toast_make_pointer_compressed_chunks(Oid toasterid,
141141struct varlena *
142142jsonx_toast_make_pointer_diff (Oid toasterid ,
143143 struct varatt_external * toast_pointer ,
144+ bool compressed_chunks ,
144145 int32 diff_offset , int32 diff_len ,
145146 const void * diff_data )
146147{
@@ -150,7 +151,10 @@ jsonx_toast_make_pointer_diff(Oid toasterid,
150151 TOAST_POINTER_SIZE + offsetof(JsonxPointerDiff , data ) + diff_len ;
151152
152153 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 ,
154158 datalen , toast_pointer -> va_rawsize , & data );
155159
156160 SET_VARTAG_EXTERNAL (data , VARTAG_ONDISK );
@@ -169,7 +173,10 @@ jsonxMakeToastPointer(JsonbToastedContainerPointerData *ptr)
169173 if (ptr -> ntids || ptr -> has_diff )
170174 {
171175 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 ) :
173180 ptr -> ntids | (ptr -> compressed_tids ?
174181 JSONX_POINTER_DIRECT_TIDS_COMP :
175182 JSONX_POINTER_DIRECT_TIDS );
@@ -209,7 +216,9 @@ jsonxWriteToastPointer(StringInfo buffer, JsonbToastedContainerPointerData *ptr)
209216 char custom_ptr [JSONX_CUSTOM_PTR_HEADER_SIZE ];
210217 char toast_ptr [TOAST_POINTER_SIZE ];
211218 uint32 header = ptr -> has_diff ?
212- JSONX_POINTER_DIFF :
219+ (ptr -> compressed_chunks ?
220+ JSONX_POINTER_DIFF_COMP :
221+ JSONX_POINTER_DIFF ) :
213222 ptr -> ntids | (ptr -> compressed_tids ?
214223 JSONX_POINTER_DIRECT_TIDS_COMP :
215224 JSONX_POINTER_DIRECT_TIDS );
@@ -989,12 +998,16 @@ jsonx_create_fetch_datum_iterator(struct varlena *attr, Oid toasterid,
989998 iter -> toasterid = toasterid ;
990999 iter -> chunk_tids_inline_size = inline_size ;
9911000
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 )
9931004 {
9941005 iter -> nchunk_tids = 0 ;
9951006 iter -> chunk_tids = NULL ;
9961007 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 ;
9981011 }
9991012 else
10001013 {
@@ -1628,7 +1641,8 @@ jsonx_create_detoast_iterator(struct varlena *attr)
16281641 /* prepare buffer to received decompressed data */
16291642 iter -> buf = create_toast_buffer (toast_pointer .va_rawsize , false);
16301643
1631- if (type == JSONX_POINTER_DIFF )
1644+ if (type == JSONX_POINTER_DIFF ||
1645+ type == JSONX_POINTER_DIFF_COMP )
16321646 iter -> orig_buf = create_toast_buffer (toast_pointer .va_rawsize , false);
16331647 else
16341648 iter -> orig_buf = iter -> buf ;
@@ -1642,7 +1656,8 @@ jsonx_create_detoast_iterator(struct varlena *attr)
16421656 iter -> buf = iter -> orig_buf = iter -> fetch_datum_iterator -> buf ;
16431657 }
16441658
1645- if (type == JSONX_POINTER_DIFF )
1659+ if (type == JSONX_POINTER_DIFF ||
1660+ type == JSONX_POINTER_DIFF_COMP )
16461661 {
16471662 JsonxPointerDiff * diff = (JsonxPointerDiff * ) inline_data ;
16481663
0 commit comments