@@ -3655,7 +3655,7 @@ jsonb_insert(PG_FUNCTION_ARGS)
3655
3655
it = JsonbIteratorInit (& in -> root );
3656
3656
3657
3657
res = setPath (& it , path_elems , path_nulls , path_len , & st , 0 , newval ,
3658
- false , after ? JB_PATH_INSERT_AFTER : JB_PATH_INSERT_BEFORE );
3658
+ false, after ? JB_PATH_INSERT_AFTER : JB_PATH_INSERT_BEFORE );
3659
3659
3660
3660
Assert (res != NULL );
3661
3661
@@ -4013,9 +4013,7 @@ setPathArray(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
4013
4013
r = JsonbIteratorNext (it , & v , true); /* skip */
4014
4014
4015
4015
if (op_type & (JB_PATH_INSERT_BEFORE | JB_PATH_CREATE ))
4016
- {
4017
4016
add_newval (st , newval , unpacked );
4018
- }
4019
4017
4020
4018
/*
4021
4019
* We should keep current value only in case of
@@ -4066,10 +4064,8 @@ setPathArray(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
4066
4064
}
4067
4065
}
4068
4066
4069
-
4070
4067
Datum
4071
- jsonb_get_element (Datum jsonbdatum ,
4072
- text * * path , int path_len , bool * is_null )
4068
+ jsonb_get_element (Datum jsonbdatum , text * * path , int path_len , bool * is_null )
4073
4069
{
4074
4070
Jsonb * jb = DatumGetJsonb (jsonbdatum );
4075
4071
JsonbValue * v ;
@@ -4089,15 +4085,13 @@ jsonb_get_element(Datum jsonbdatum,
4089
4085
v -> type == jbvBinary && level < path_len )
4090
4086
{
4091
4087
v = findJsonbValueFromContainerLen (v -> val .binary .data , JB_FOBJECT ,
4092
- VARDATA_ANY (path [level ]),
4093
- VARSIZE_ANY_EXHDR (path [level ]));
4088
+ VARDATA_ANY (path [level ]),
4089
+ VARSIZE_ANY_EXHDR (path [level ]));
4094
4090
level ++ ;
4095
4091
}
4096
4092
4097
4093
if (v != NULL && level == path_len )
4098
- {
4099
4094
PG_RETURN_JSONB (JsonbValueToJsonb (v ));
4100
- }
4101
4095
4102
4096
* is_null = true;
4103
4097
return (Datum ) 0 ;
@@ -4106,19 +4100,19 @@ jsonb_get_element(Datum jsonbdatum,
4106
4100
Datum
4107
4101
jsonb_subscription_evaluate (PG_FUNCTION_ARGS )
4108
4102
{
4109
- SubscriptionRefExprState * sbstate = (SubscriptionRefExprState * ) PG_GETARG_POINTER (0 );
4110
- SubscriptionExecData * sbsdata = (SubscriptionExecData * ) PG_GETARG_POINTER (1 );
4111
- ExprContext * econtext = sbsdata -> xprcontext ;
4112
- bool * is_null = sbsdata -> isNull ;
4113
- SubscriptionRef * jsonb_ref = (SubscriptionRef * ) sbstate -> xprstate .expr ;
4114
- bool is_assignment = (jsonb_ref -> refassgnexpr != NULL );
4115
- bool eisnull ;
4116
- text * * path ;
4117
- int i = 0 ;
4103
+ SubscriptionRefExprState * sbstate = (SubscriptionRefExprState * ) PG_GETARG_POINTER (0 );
4104
+ SubscriptionExecData * sbsdata = (SubscriptionExecData * ) PG_GETARG_POINTER (1 );
4105
+ ExprContext * econtext = sbsdata -> xprcontext ;
4106
+ bool * is_null = sbsdata -> isNull ;
4107
+ SubscriptionRef * jsonb_ref = (SubscriptionRef * ) sbstate -> xprstate .expr ;
4108
+ bool is_assignment = (jsonb_ref -> refassgnexpr != NULL );
4109
+ bool eisnull ;
4110
+ text * * path ;
4111
+ int i = 0 ;
4118
4112
4119
4113
path = (text * * ) palloc (i * sizeof (text * ));
4120
- for (i = 0 ; i < sbsdata -> indexprNumber ; i ++ )
4121
- path [i ] = cstring_to_text ((char * )DatumGetPointer (sbsdata -> upper [i ]));
4114
+ for (i = 0 ; i < sbsdata -> indexprNumber ; i ++ )
4115
+ path [i ] = cstring_to_text ((char * ) DatumGetPointer (sbsdata -> upper [i ]));
4122
4116
4123
4117
if (is_assignment )
4124
4118
{
@@ -4189,68 +4183,58 @@ jsonb_subscription_evaluate(PG_FUNCTION_ARGS)
4189
4183
Datum
4190
4184
jsonb_subscription_prepare (PG_FUNCTION_ARGS )
4191
4185
{
4192
- SubscriptionRef * sbsref = (SubscriptionRef * ) PG_GETARG_POINTER (0 );
4193
- ParseState * pstate = (ParseState * ) PG_GETARG_POINTER (1 );
4186
+ SubscriptionRef * sbsref = (SubscriptionRef * ) PG_GETARG_POINTER (0 );
4187
+ ParseState * pstate = (ParseState * ) PG_GETARG_POINTER (1 );
4194
4188
4195
4189
if (sbsref -> reflowerindexpr != NIL )
4196
- {
4197
4190
ereport (ERROR ,
4198
4191
(errcode (ERRCODE_DATATYPE_MISMATCH ),
4199
4192
errmsg ("jsonb subscript does not support slices" ),
4200
4193
parser_errposition (pstate , exprLocation (
4201
4194
((Node * )lfirst (sbsref -> reflowerindexpr -> head ))) )));
4202
- }
4203
4195
4204
4196
PG_RETURN_POINTER (sbsref );
4205
4197
}
4206
4198
4207
4199
Datum
4208
4200
jsonb_subscription (PG_FUNCTION_ARGS )
4209
4201
{
4210
- int op_type = PG_GETARG_INT32 (0 );
4211
- FunctionCallInfoData target_fcinfo = get_slice_arguments (fcinfo , 1 ,
4212
- fcinfo -> nargs );
4202
+ int op_type = PG_GETARG_INT32 (0 );
4203
+ FunctionCallInfoData target_fcinfo = get_slice_arguments (fcinfo , 1 ,
4204
+ fcinfo -> nargs );
4213
4205
4214
4206
if (op_type & SBS_VALIDATION )
4215
- {
4216
4207
return jsonb_subscription_prepare (& target_fcinfo );
4217
- }
4218
4208
4219
4209
if (op_type & SBS_EXEC )
4220
- {
4221
4210
return jsonb_subscription_evaluate (& target_fcinfo );
4222
- }
4223
4211
4224
4212
elog (ERROR , "incorrect op_type for subscription function: %d" , op_type );
4225
4213
}
4226
4214
4227
4215
Datum
4228
- jsonb_set_element (Datum jsonbdatum ,
4229
- text * * path , int path_len , Datum sourceData , Oid source_type )
4216
+ jsonb_set_element (Datum jsonbdatum , text * * path , int path_len ,
4217
+ Datum sourceData , Oid source_type )
4230
4218
{
4231
- Jsonb * jb = DatumGetJsonb (jsonbdatum );
4232
- JsonbValue * newval , * res = NULL ;
4233
- JsonbParseState * state = NULL ;
4234
- JsonbIterator * it ;
4219
+ Jsonb * jb = DatumGetJsonb (jsonbdatum );
4220
+ JsonbValue * newval ,
4221
+ * res = NULL ;
4222
+ JsonbParseState * state = NULL ;
4223
+ JsonbIterator * it ;
4235
4224
int i = 0 ;
4236
- bool * path_nulls = palloc (path_len * sizeof (bool ));
4225
+ bool * path_nulls = palloc (path_len * sizeof (bool ));
4237
4226
4238
4227
newval = to_jsonb_worker (sourceData , source_type );
4239
4228
it = JsonbIteratorInit (& jb -> root );
4240
4229
4241
-
4242
4230
if (newval -> type == jbvArray && newval -> val .array .rawScalar == true)
4243
- {
4244
4231
* newval = newval -> val .array .elems [0 ];
4245
- }
4246
4232
4247
- for (i = 0 ; i < path_len ; i ++ )
4248
- {
4249
- path_nulls [i ]= false;
4250
- }
4233
+ for (i = 0 ; i < path_len ; i ++ )
4234
+ path_nulls [i ] = false;
4251
4235
4252
4236
res = setPath (& it , (Datum * ) path , path_nulls , path_len , & state , 0 ,
4253
- (void * )newval , true, true);
4237
+ (void * ) newval , true, true);
4254
4238
4255
4239
PG_RETURN_JSONB (JsonbValueToJsonb (res ));
4256
4240
}
0 commit comments