@@ -764,14 +764,19 @@ jsonb_object_field(PG_FUNCTION_ARGS)
764
764
Jsonb * jb = PG_GETARG_JSONB (0 );
765
765
text * key = PG_GETARG_TEXT_PP (1 );
766
766
JsonbValue * v ;
767
+ JsonCacheContext oldcxt ;
767
768
768
769
if (!JB_ROOT_IS_OBJECT (jb ))
769
770
PG_RETURN_NULL ();
770
771
772
+ oldcxt = JsonCacheSwitchToFunc (fcinfo );
773
+
771
774
v = findJsonbValueFromContainerLen (& jb -> root , JB_FOBJECT ,
772
775
VARDATA_ANY (key ),
773
776
VARSIZE_ANY_EXHDR (key ));
774
777
778
+ JsonCacheSwitchTo (oldcxt );
779
+
775
780
if (v != NULL )
776
781
PG_RETURN_JSONB (JsonbValueToJsonb (v ));
777
782
@@ -803,14 +808,19 @@ jsonb_object_field_text(PG_FUNCTION_ARGS)
803
808
text * key = PG_GETARG_TEXT_PP (1 );
804
809
JsonbValue * v ;
805
810
JsonbValue vbuf ;
811
+ JsonCacheContext oldcxt ;
806
812
807
813
if (!JB_ROOT_IS_OBJECT (jb ))
808
814
PG_RETURN_NULL ();
809
815
816
+ oldcxt = JsonCacheSwitchToFunc (fcinfo );
817
+
810
818
v = findJsonbValueFromContainerLen (& jb -> root , JB_FOBJECT ,
811
819
VARDATA_ANY (key ),
812
820
VARSIZE_ANY_EXHDR (key ));
813
821
822
+ JsonCacheSwitchTo (oldcxt );
823
+
814
824
if (v != NULL )
815
825
{
816
826
text * result = NULL ;
@@ -1444,13 +1454,23 @@ get_scalar(void *state, char *token, JsonTokenType tokentype)
1444
1454
Datum
1445
1455
jsonb_extract_path (PG_FUNCTION_ARGS )
1446
1456
{
1447
- return get_jsonb_path_all (fcinfo , false);
1457
+ JsonCacheContext oldcxt = JsonCacheSwitchToFunc (fcinfo );
1458
+ Datum result = get_jsonb_path_all (fcinfo , false);
1459
+
1460
+ JsonCacheSwitchTo (oldcxt );
1461
+
1462
+ PG_RETURN_DATUM (result );
1448
1463
}
1449
1464
1450
1465
Datum
1451
1466
jsonb_extract_path_text (PG_FUNCTION_ARGS )
1452
1467
{
1453
- return get_jsonb_path_all (fcinfo , true);
1468
+ JsonCacheContext oldcxt = JsonCacheSwitchToFunc (fcinfo );
1469
+ Datum result = get_jsonb_path_all (fcinfo , true);
1470
+
1471
+ JsonCacheSwitchTo (oldcxt );
1472
+
1473
+ PG_RETURN_DATUM (result );
1454
1474
}
1455
1475
1456
1476
static Datum
0 commit comments