Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4eb9798

Browse files
committed
Avoid freeing objects during json aggregate finalization
Commitf4fb45d tried to free memory during aggregate finalization.This cause issues, particularly when used as a window function, so stopdoing that.Per complaint by Jaime Casanova and diagnosis by Andres FreundDiscussion:https://postgr.es/m/YkfeMNYRCGhySKyg@ahch-to
1 parentafb529e commit4eb9798

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

‎src/backend/utils/adt/json.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -979,12 +979,6 @@ json_unique_check_init(JsonUniqueCheckState *cxt)
979979
HASH_ELEM |HASH_CONTEXT |HASH_FUNCTION |HASH_COMPARE);
980980
}
981981

982-
staticvoid
983-
json_unique_check_free(JsonUniqueCheckState*cxt)
984-
{
985-
hash_destroy(*cxt);
986-
}
987-
988982
staticbool
989983
json_unique_check_key(JsonUniqueCheckState*cxt,constchar*key,intobject_id)
990984
{
@@ -1009,12 +1003,10 @@ json_unique_builder_init(JsonUniqueBuilderState *cxt)
10091003
}
10101004

10111005
staticvoid
1012-
json_unique_builder_free(JsonUniqueBuilderState*cxt)
1006+
json_unique_builder_clean(JsonUniqueBuilderState*cxt)
10131007
{
1014-
json_unique_check_free(&cxt->check);
1015-
10161008
if (cxt->skipped_keys.data)
1017-
pfree(cxt->skipped_keys.data);
1009+
resetStringInfo(&cxt->skipped_keys);
10181010
}
10191011

10201012
/* On-demand initialization of skipped_keys StringInfo structure */
@@ -1224,7 +1216,7 @@ json_object_agg_finalfn(PG_FUNCTION_ARGS)
12241216
if (state==NULL)
12251217
PG_RETURN_NULL();
12261218

1227-
json_unique_builder_free(&state->unique_check);
1219+
json_unique_builder_clean(&state->unique_check);
12281220

12291221
/* Else return state with appropriate object terminator added */
12301222
PG_RETURN_TEXT_P(catenate_stringinfo_string(state->str," }"));
@@ -1333,7 +1325,7 @@ json_build_object_worker(int nargs, Datum *args, bool *nulls, Oid *types,
13331325
appendStringInfoChar(result,'}');
13341326

13351327
if (unique_keys)
1336-
json_unique_builder_free(&unique_check);
1328+
json_unique_builder_clean(&unique_check);
13371329

13381330
returnPointerGetDatum(cstring_to_text_with_len(result->data,result->len));
13391331
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp