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

Commitd03a62e

Browse files
author
Nikita Glukhov
committed
Optimize jsonb returning, Json allocation
1 parent7beaa1e commitd03a62e

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
@@ -2911,6 +2911,9 @@ DatumGetJsonbPC(Datum datum, Json *tmp, bool copy)
29112911
datum=PointerGetDatum(pg_detoast_datum_copy(src));
29122912
}
29132913

2914+
if (!jsonb_partial_decompression)
2915+
returnDatumGetJson(datum,&jsonbContainerOps,tmp);
2916+
29142917
CompressedDatumInit(&cd,datum);
29152918

29162919
if (!cd.compressed)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ jsonb_object_field(PG_FUNCTION_ARGS)
644644
PG_GETARG_TEXT_PP(1));
645645

646646
if (res)
647-
PG_RETURN_JSONB_P(JsonbValueToJsonb(res));
647+
PG_RETURN_JSONB_VALUE(res);
648648
else
649649
PG_RETURN_NULL();
650650
}

‎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