Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a1c737f

Browse files
author
Nikita Glukhov
committed
Fix copying of resulting jsonb stats to non-temporary context
1 parent b204148 commit a1c737f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/backend/utils/adt/jsonb_typanalyze.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,6 @@ static Jsonb *
10581058
jsonAnalyzePath(JsonAnalyzeContext *ctx, JsonPathAnlStats *pstats,
10591059
JsonPathParentStats *parent_stats)
10601060
{
1061-
MemoryContext oldcxt;
10621061
JsonValueStats *vstats = &pstats->vstats;
10631062
Jsonb *stats;
10641063

@@ -1084,11 +1083,12 @@ jsonAnalyzePath(JsonAnalyzeContext *ctx, JsonPathAnlStats *pstats,
10841083
jsonAnalyzePathValues(ctx, &vstats->numerics, NUMERICOID, pstats->freq);
10851084
#endif
10861085

1087-
oldcxt = MemoryContextSwitchTo(ctx->stats->anl_context);
1086+
/* Build jsonb with path stats */
10881087
stats = jsonAnalyzeBuildPathStats(pstats);
1089-
MemoryContextSwitchTo(oldcxt);
10901088

1091-
return stats;
1089+
/* Copy stats to non-temporary context */
1090+
return memcpy(MemoryContextAlloc(ctx->stats->anl_context, VARSIZE(stats)),
1091+
stats, VARSIZE(stats));
10921092
}
10931093

10941094
/*

0 commit comments

Comments
 (0)