Skip to content

Commit 799de18

Browse files
author
Nikita Glukhov
committed
Fix whitespace
1 parent ea1a497 commit 799de18

File tree

2 files changed

+35
-51
lines changed

2 files changed

+35
-51
lines changed

src/backend/utils/adt/jsonb.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,12 +1149,12 @@ to_jsonb(PG_FUNCTION_ARGS)
11491149
PG_RETURN_POINTER(JsonbValueToJsonb(res));
11501150
}
11511151

1152-
JsonbValue*
1152+
JsonbValue *
11531153
to_jsonb_worker(Datum source, Oid source_type)
11541154
{
1155-
JsonbInState result;
1156-
JsonbTypeCategory tcategory;
1157-
Oid outfuncoid;
1155+
JsonbInState result;
1156+
JsonbTypeCategory tcategory;
1157+
Oid outfuncoid;
11581158

11591159
if (source_type == InvalidOid)
11601160
ereport(ERROR,

src/backend/utils/adt/jsonfuncs.c

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3655,7 +3655,7 @@ jsonb_insert(PG_FUNCTION_ARGS)
36553655
it = JsonbIteratorInit(&in->root);
36563656

36573657
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);
36593659

36603660
Assert(res != NULL);
36613661

@@ -4013,9 +4013,7 @@ setPathArray(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
40134013
r = JsonbIteratorNext(it, &v, true); /* skip */
40144014

40154015
if (op_type & (JB_PATH_INSERT_BEFORE | JB_PATH_CREATE))
4016-
{
40174016
add_newval(st, newval, unpacked);
4018-
}
40194017

40204018
/*
40214019
* We should keep current value only in case of
@@ -4066,10 +4064,8 @@ setPathArray(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
40664064
}
40674065
}
40684066

4069-
40704067
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)
40734069
{
40744070
Jsonb *jb = DatumGetJsonb(jsonbdatum);
40754071
JsonbValue *v;
@@ -4089,15 +4085,13 @@ jsonb_get_element(Datum jsonbdatum,
40894085
v->type == jbvBinary && level < path_len)
40904086
{
40914087
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]));
40944090
level++;
40954091
}
40964092

40974093
if (v != NULL && level == path_len)
4098-
{
40994094
PG_RETURN_JSONB(JsonbValueToJsonb(v));
4100-
}
41014095

41024096
*is_null = true;
41034097
return (Datum) 0;
@@ -4106,19 +4100,19 @@ jsonb_get_element(Datum jsonbdatum,
41064100
Datum
41074101
jsonb_subscription_evaluate(PG_FUNCTION_ARGS)
41084102
{
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;
41184112

41194113
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]));
41224116

41234117
if (is_assignment)
41244118
{
@@ -4189,68 +4183,58 @@ jsonb_subscription_evaluate(PG_FUNCTION_ARGS)
41894183
Datum
41904184
jsonb_subscription_prepare(PG_FUNCTION_ARGS)
41914185
{
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);
41944188

41954189
if (sbsref->reflowerindexpr != NIL)
4196-
{
41974190
ereport(ERROR,
41984191
(errcode(ERRCODE_DATATYPE_MISMATCH),
41994192
errmsg("jsonb subscript does not support slices"),
42004193
parser_errposition(pstate, exprLocation(
42014194
((Node *)lfirst(sbsref->reflowerindexpr->head))) )));
4202-
}
42034195

42044196
PG_RETURN_POINTER(sbsref);
42054197
}
42064198

42074199
Datum
42084200
jsonb_subscription(PG_FUNCTION_ARGS)
42094201
{
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);
42134205

42144206
if (op_type & SBS_VALIDATION)
4215-
{
42164207
return jsonb_subscription_prepare(&target_fcinfo);
4217-
}
42184208

42194209
if (op_type & SBS_EXEC)
4220-
{
42214210
return jsonb_subscription_evaluate(&target_fcinfo);
4222-
}
42234211

42244212
elog(ERROR, "incorrect op_type for subscription function: %d", op_type);
42254213
}
42264214

42274215
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)
42304218
{
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;
42354224
int i = 0;
4236-
bool *path_nulls = palloc(path_len * sizeof(bool));
4225+
bool *path_nulls = palloc(path_len * sizeof(bool));
42374226

42384227
newval = to_jsonb_worker(sourceData, source_type);
42394228
it = JsonbIteratorInit(&jb->root);
42404229

4241-
42424230
if (newval->type == jbvArray && newval->val.array.rawScalar == true)
4243-
{
42444231
*newval = newval->val.array.elems[0];
4245-
}
42464232

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;
42514235

42524236
res = setPath(&it, (Datum *) path, path_nulls, path_len, &state, 0,
4253-
(void *)newval, true, true);
4237+
(void *) newval, true, true);
42544238

42554239
PG_RETURN_JSONB(JsonbValueToJsonb(res));
42564240
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy