@@ -3568,11 +3568,11 @@ my_bool json_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
3568
3568
return JsonInit (initid, args, message, true , reslen, memlen);
3569
3569
} // end of json_set_item_init
3570
3570
3571
- char *json_set_item (UDF_INIT *initid, UDF_ARGS *args, char *result,
3572
- unsigned long *res_length, char *is_null, char *error)
3571
+ static char *json_set_item_core (UDF_INIT *initid, UDF_ARGS *args, char *result,
3572
+ unsigned long *res_length, char *is_null, char *error, int w )
3573
3573
{
3574
3574
char *p, *path, *str = NULL ;
3575
- int w, rc;
3575
+ int rc;
3576
3576
my_bool b = true ;
3577
3577
PJSON jsp;
3578
3578
PJSNX jsx;
@@ -3586,13 +3586,6 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
3586
3586
} else if (initid->const_item )
3587
3587
g->N = 1 ;
3588
3588
3589
- if (!strcmp (result, " $insert" ))
3590
- w = 1 ;
3591
- else if (!strcmp (result, " $update" ))
3592
- w = 2 ;
3593
- else
3594
- w = 0 ;
3595
-
3596
3589
// Save stack and allocation environment and prepare error return
3597
3590
if (g->jump_level == MAX_JUMP) {
3598
3591
PUSH_WARNING (MSG (TOO_MANY_JUMPS));
@@ -3671,7 +3664,13 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
3671
3664
*res_length = strlen (str);
3672
3665
3673
3666
return str;
3674
- } // end of json_set_item
3667
+ } // end of json_set_item_core
3668
+
3669
+ char *json_set_item (UDF_INIT *initid, UDF_ARGS *args, char *result,
3670
+ unsigned long *res_length, char *is_null, char *error)
3671
+ {
3672
+ return json_set_item_core (initid, args, result, res_length, is_null, error, 0 );
3673
+ }
3675
3674
3676
3675
void json_set_item_deinit (UDF_INIT* initid)
3677
3676
{
@@ -3689,8 +3688,7 @@ my_bool json_insert_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
3689
3688
char *json_insert_item (UDF_INIT *initid, UDF_ARGS *args, char *result,
3690
3689
unsigned long *res_length, char *is_null, char *p)
3691
3690
{
3692
- strcpy (result, " $insert" );
3693
- return json_set_item (initid, args, result, res_length, is_null, p);
3691
+ return json_set_item_core (initid, args, result, res_length, is_null, p, 1 );
3694
3692
} // end of json_insert_item
3695
3693
3696
3694
void json_insert_item_deinit (UDF_INIT* initid)
@@ -3709,8 +3707,7 @@ my_bool json_update_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
3709
3707
char *json_update_item (UDF_INIT *initid, UDF_ARGS *args, char *result,
3710
3708
unsigned long *res_length, char *is_null, char *p)
3711
3709
{
3712
- strcpy (result, " $update" );
3713
- return json_set_item (initid, args, result, res_length, is_null, p);
3710
+ return json_set_item_core (initid, args, result, res_length, is_null, p, 2 );
3714
3711
} // end of json_update_item
3715
3712
3716
3713
void json_update_item_deinit (UDF_INIT* initid)
0 commit comments