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

Commite39c094

Browse files
author
Nikita Glukhov
committed
Add GUC jsonb_sort_field_values
1 parent7b8069b commite39c094

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
#include"utils/memutils.h"
3232
#include"utils/varlena.h"
3333

34-
#defineJSONB_SORTED_VALUES 1
35-
3634
/*
3735
* Maximum number of elements in an array (or key/value pairs in an object).
3836
* This is limited by two things: the size of the JEntry array must fit
@@ -140,6 +138,7 @@ static JsonbValue *fillCompressedJsonbValue(CompressedJsonb *cjb,
140138
uint32offset,JsonValue*result);
141139
staticJsonbContainer*jsonbzDecompress(JsonContainer*jc);
142140

141+
booljsonb_sort_field_values= true;/* GUC */
143142

144143
JsonValue*
145144
JsonValueUnpackBinary(constJsonValue*jbv)
@@ -2022,7 +2021,7 @@ convertJsonbObject(StringInfo buffer, JEntry *pheader, const JsonbValue *val, in
20222021
uint32header;
20232022
intnPairs=val->val.object.nPairs;
20242023
intreserved_size;
2025-
boolsorted_values=JSONB_SORTED_VALUES&&nPairs>1;
2024+
boolsorted_values=jsonb_sort_field_values&&nPairs>1;
20262025
struct
20272026
{
20282027
intsize;

‎src/backend/utils/misc/guc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#include"utils/bytea.h"
9292
#include"utils/float.h"
9393
#include"utils/guc_tables.h"
94+
#include"utils/jsonb.h"
9495
#include"utils/memutils.h"
9596
#include"utils/pg_locale.h"
9697
#include"utils/pg_lsn.h"
@@ -2084,6 +2085,15 @@ static struct config_bool ConfigureNamesBool[] =
20842085
NULL,NULL,NULL
20852086
},
20862087

2088+
{
2089+
{"jsonb_sort_field_values",PGC_USERSET,DEVELOPER_OPTIONS,
2090+
gettext_noop("Use special binary jsonb format for objects when their field values sorted by length."),
2091+
},
2092+
&jsonb_sort_field_values,
2093+
true,
2094+
NULL,NULL,NULL
2095+
},
2096+
20872097
/* End-of-list marker */
20882098
{
20892099
{NULL,0,0,NULL,NULL},NULL, false,NULL,NULL,NULL

‎src/include/utils/jsonb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,6 @@ extern void JsonbHashScalarValueExtended(const JsonbValue *scalarVal,
413413
externintreserveFromBuffer(StringInfobuffer,intlen);
414414
externvoidappendToBuffer(StringInfobuffer,constvoid*data,intlen);
415415

416+
externbooljsonb_sort_field_values;/* GUC */
417+
416418
#endif/* __JSONB_H__ */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp