Commit bb513b36 authored by Alexander Korotkov's avatar Alexander Korotkov

Get rid of unnecessary memory allocation in jsonb_subscript_assign()

Current code allocates memory for JsonbValue, but it could be placed locally.
parent fe61df7f
...@@ -283,7 +283,7 @@ jsonb_subscript_assign(ExprState *state, ...@@ -283,7 +283,7 @@ jsonb_subscript_assign(ExprState *state,
*/ */
if (*op->resnull) if (*op->resnull)
{ {
JsonbValue *newSource = (JsonbValue *) palloc(sizeof(JsonbValue)); JsonbValue newSource;
/* /*
* To avoid any surprising results, set up an empty jsonb array in * To avoid any surprising results, set up an empty jsonb array in
...@@ -292,17 +292,17 @@ jsonb_subscript_assign(ExprState *state, ...@@ -292,17 +292,17 @@ jsonb_subscript_assign(ExprState *state,
*/ */
if (workspace->expectArray) if (workspace->expectArray)
{ {
newSource->type = jbvArray; newSource.type = jbvArray;
newSource->val.array.nElems = 0; newSource.val.array.nElems = 0;
newSource->val.array.rawScalar = false; newSource.val.array.rawScalar = false;
} }
else else
{ {
newSource->type = jbvObject; newSource.type = jbvObject;
newSource->val.object.nPairs = 0; newSource.val.object.nPairs = 0;
} }
jsonbSource = JsonbValueToJsonb(newSource); jsonbSource = JsonbValueToJsonb(&newSource);
*op->resnull = false; *op->resnull = false;
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment