@@ -2914,6 +2914,9 @@ jsonb_toaster_save_object(Relation rel, Oid toasterid, JsonContainer *root,
2914
2914
JsonContainer * jc ;
2915
2915
JsonbContainerHeader * jbc ;
2916
2916
2917
+ Datum value_to_toast ;
2918
+ bool compress_chunks ;
2919
+
2917
2920
for (i = 0 ; i < nkeys ; i ++ )
2918
2921
{
2919
2922
if (pairs [i ].value .type == jbvBinary &&
@@ -3045,9 +3048,6 @@ jsonb_toaster_save_object(Relation rel, Oid toasterid, JsonContainer *root,
3045
3048
if (!jsonb_toast_fields )
3046
3049
goto exit ;
3047
3050
3048
- Datum value_to_toast ;
3049
- bool compress_chunks ;
3050
-
3051
3051
if (jsonb_compress_chunks && orig_val )
3052
3052
{
3053
3053
compress_chunks = true;
@@ -3108,8 +3108,8 @@ jsonb_toaster_save_object(Relation rel, Oid toasterid, JsonContainer *root,
3108
3108
3109
3109
//Assert(VARSIZE_ANY(toasted_val) == TOAST_POINTER_SIZE);
3110
3110
3111
- fields [max_key_idx ].orig_value = ( Datum ) 0 ;
3112
- fields [max_key_idx ].value = ( Datum ) 0 ;
3111
+ fields [max_key_idx ].orig_value = NULL ;
3112
+ fields [max_key_idx ].value = NULL ;
3113
3113
fields [max_key_idx ].size = offsetof(JsonbToastedContainerPointer , data ) + VARSIZE_ANY (toasted_val ); //TOAST_POINTER_SIZE;
3114
3114
fields [max_key_idx ].status = 't' ;
3115
3115
pairs [max_key_idx ].value .val .binary .data = jsonxzInitContainerFromDatum (jc , toasted_val );
@@ -3652,7 +3652,7 @@ jsonb_toaster_default_toast(Relation rel, Oid toasterid, char cmethod,
3652
3652
NULL , options , NULL , NULL , false);
3653
3653
}
3654
3654
3655
- static struct varlena *
3655
+ static Datum
3656
3656
jsonb_toaster_toast (Relation rel , Oid toasterid ,
3657
3657
Datum new_val , Datum old_val ,
3658
3658
int max_inline_size , int options )
@@ -3678,10 +3678,10 @@ jsonb_toaster_toast(Relation rel, Oid toasterid,
3678
3678
3679
3679
jsonbFreeIterators ();
3680
3680
3681
- return ( struct varlena * ) DatumGetPointer ( res ) ;
3681
+ return res ;
3682
3682
}
3683
3683
3684
- static struct varlena *
3684
+ static Datum
3685
3685
jsonb_toaster_update_toast (Relation rel , Oid toasterid ,
3686
3686
Datum new_val , Datum old_val ,
3687
3687
int options )
@@ -3699,10 +3699,10 @@ jsonb_toaster_update_toast(Relation rel, Oid toasterid,
3699
3699
3700
3700
jsonbFreeIterators ();
3701
3701
3702
- return ( struct varlena * ) DatumGetPointer ( res ) ;
3702
+ return res ;
3703
3703
}
3704
3704
3705
- static struct varlena *
3705
+ static Datum
3706
3706
jsonb_toaster_copy_toast (Relation rel , Oid toasterid ,
3707
3707
Datum new_val , int options )
3708
3708
{
@@ -3717,7 +3717,7 @@ jsonb_toaster_copy_toast(Relation rel, Oid toasterid,
3717
3717
3718
3718
jsonbFreeIterators ();
3719
3719
3720
- return ( struct varlena * ) DatumGetPointer ( res ) ;
3720
+ return res ;
3721
3721
}
3722
3722
3723
3723
static void
@@ -3733,11 +3733,11 @@ jsonb_toaster_delete_toast(Datum val, bool is_speculative)
3733
3733
jsonbFreeIterators ();
3734
3734
}
3735
3735
3736
- static struct varlena *
3736
+ static Datum
3737
3737
jsonb_toaster_detoast (Datum toastptr , int sliceoffset , int slicelength )
3738
3738
{
3739
3739
struct varlena * result ;
3740
- Json jsbuf ;
3740
+ // Json jsbuf;
3741
3741
Json * js ;
3742
3742
JsonValue bin ;
3743
3743
void * detoasted ;
@@ -3758,7 +3758,7 @@ jsonb_toaster_detoast(Datum toastptr, int sliceoffset, int slicelength)
3758
3758
jsonbFreeIterators ();
3759
3759
3760
3760
if (sliceoffset == 0 && (slicelength < 0 || slicelength >= len ))
3761
- return detoasted ;
3761
+ return PointerGetDatum ( detoasted ) ;
3762
3762
3763
3763
if (sliceoffset < 0 )
3764
3764
sliceoffset = 0 ;
@@ -3774,7 +3774,7 @@ jsonb_toaster_detoast(Datum toastptr, int sliceoffset, int slicelength)
3774
3774
3775
3775
pfree (detoasted );
3776
3776
3777
- return result ;
3777
+ return PointerGetDatum ( result ) ;
3778
3778
}
3779
3779
3780
3780
static void *
@@ -3789,10 +3789,11 @@ jsonb_toaster_vtable(Datum toast_ptr)
3789
3789
}
3790
3790
3791
3791
static void
3792
- jsonb_toaster_init (Relation rel , Datum reloptions , LOCKMODE lockmode ,
3792
+ jsonb_toaster_init (Relation rel , Oid toastoid , Oid toastindexoid ,
3793
+ Datum reloptions , LOCKMODE lockmode ,
3793
3794
bool check , Oid OIDOldToast )
3794
3795
{
3795
- (void ) create_toast_table (rel , InvalidOid , InvalidOid , reloptions ,
3796
+ (void ) create_toast_table (rel , toastoid , toastindexoid , reloptions ,
3796
3797
lockmode , check , OIDOldToast );
3797
3798
}
3798
3799
0 commit comments