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

Commit9032dd5

Browse files
author
Nikita Glukhov
committed
Optimize jsonb returning, Json allocation
1 parent6de0f21 commit9032dd5

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2974,6 +2974,9 @@ DatumGetJsonbPC(Datum datum, Json *tmp, bool copy)
29742974
datum=PointerGetDatum(pg_detoast_datum_copy(src));
29752975
}
29762976

2977+
if (!jsonb_partial_decompression)
2978+
returnDatumGetJson(datum,&jsonbContainerOps,tmp);
2979+
29772980
CompressedDatumInit(&cd,datum);
29782981

29792982
if (!cd.compressed)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ jsonb_object_field(PG_FUNCTION_ARGS)
638638
PG_GETARG_TEXT_PP(1));
639639

640640
if (res)
641-
PG_RETURN_JSONB_P(JsonbValueToJsonb(res));
641+
PG_RETURN_JSONB_VALUE(res);
642642
else
643643
PG_RETURN_NULL();
644644
}

‎src/include/utils/json_generic.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ typedef struct Json
9797
#defineJsonbPGetDatum(json)JsonFlattenToJsonbDatum(JsonGetUniquified(json))
9898
#defineJsontPGetDatum(json)CStringGetTextDatum(JsonToCString(JsonRoot(json), NULL))
9999

100+
#defineJsonValueGetJsonbDatum(json)PointerGetDatum(JsonValueFlatten(json, JsonbEncode, &jsonbContainerOps))
101+
100102
#ifdefJsonxPGetDatum
101103
# defineJsonGetDatum(json)JsonxPGetDatum(json)
102104
#else
@@ -117,6 +119,7 @@ typedef struct Json
117119
#undef PG_RETURN_JSONB_P
118120
#definePG_RETURN_JSONB_P(x)PG_RETURN_DATUM(JsonGetDatum(x))
119121
#definePG_RETURN_JSONT_P(x)PG_RETURN_DATUM(JsontPGetDatum(x))
122+
#definePG_RETURN_JSONB_VALUE(x)PG_RETURN_DATUM(JsonValueGetJsonbDatum(x))
120123

121124
#definePG_GETARG_JSONX_TMP(n,tmp)DatumGetJsonxTmp(PG_GETARG_DATUM(n), tmp)
122125

@@ -126,7 +129,7 @@ typedef struct Json
126129
#else
127130
#definePG_GETARG_JSONB_P(n)PG_GETARG_JSONX_TMP(n, alloca(sizeof(Json)))/* FIXME conditional alloca() */
128131
#endif
129-
#definePG_GETARG_JSONB_PC(n)DatumGetJsonbPC(PG_GETARG_DATUM(n),NULL/*alloca(sizeof(Json))*/, false)/* FIXMEconditional alloca() */
132+
#definePG_GETARG_JSONB_PC(n)DatumGetJsonbPC(PG_GETARG_DATUM(n), alloca(JsonAllocSize(16))/* FIXMEsizeof CompressedJsonb */, false)
130133
#definePG_GETARG_JSONT_P(n)DatumGetJsontP(PG_GETARG_DATUM(n))
131134

132135
#undefPG_GETARG_JSONB_P_COPY

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp