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

Commit7ace019

Browse files
author
Nikita Glukhov
committed
Add const qualifiers for JsonbValue * parameters
1 parente30954c commit7ace019

File tree

2 files changed

+41
-39
lines changed

2 files changed

+41
-39
lines changed

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

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ struct JsonbParseState
5151
structJsonbIterator
5252
{
5353
/* Container being iterated */
54-
JsonbContainer*container;
54+
constJsonbContainer*container;
5555
uint32nElems;/* Number of elements in children array (will
5656
* be nPairs for objects) */
5757
boolisScalar;/* Pseudo-array scalar value? */
58-
JEntry*children;/* JEntrys for child nodes */
58+
constJEntry*children;/* JEntrys for child nodes */
5959
/* Data proper. This points to the beginning of the variable-length data */
6060
char*dataProper;
6161

@@ -78,16 +78,16 @@ struct JsonbIterator
7878
structJsonbIterator*parent;
7979
};
8080

81-
staticvoidfillJsonbValue(JsonbContainer*container,intindex,
81+
staticvoidfillJsonbValue(constJsonbContainer*container,intindex,
8282
char*base_addr,uint32offset,
8383
JsonbValue*result);
84-
staticboolequalsJsonbScalarValue(JsonbValue*a,JsonbValue*b);
85-
staticintcompareJsonbScalarValue(JsonbValue*a,JsonbValue*b);
86-
staticJsonb*convertToJsonb(JsonbValue*val);
87-
staticvoidconvertJsonbValue(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel);
88-
staticvoidconvertJsonbArray(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel);
89-
staticvoidconvertJsonbObject(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel);
90-
staticvoidconvertJsonbScalar(StringInfobuffer,JEntry*header,JsonbValue*scalarVal);
84+
staticboolequalsJsonbScalarValue(constJsonbValue*a,constJsonbValue*b);
85+
staticintcompareJsonbScalarValue(constJsonbValue*a,constJsonbValue*b);
86+
staticJsonb*convertToJsonb(constJsonbValue*val);
87+
staticvoidconvertJsonbValue(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel);
88+
staticvoidconvertJsonbArray(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel);
89+
staticvoidconvertJsonbObject(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel);
90+
staticvoidconvertJsonbScalar(StringInfobuffer,JEntry*header,constJsonbValue*scalarVal);
9191

9292
staticintreserveFromBuffer(StringInfobuffer,intlen);
9393
staticvoidappendToBuffer(StringInfobuffer,constchar*data,intlen);
@@ -97,9 +97,9 @@ static short padBufferToInt(StringInfo buffer);
9797
staticJsonbIterator*iteratorFromContainer(JsonbContainer*container,JsonbIterator*parent);
9898
staticJsonbIterator*freeAndGetParent(JsonbIterator*it);
9999
staticJsonbParseState*pushState(JsonbParseState**pstate);
100-
staticvoidappendKey(JsonbParseState*pstate,JsonbValue*scalarVal);
101-
staticvoidappendValue(JsonbParseState*pstate,JsonbValue*scalarVal);
102-
staticvoidappendElement(JsonbParseState*pstate,JsonbValue*scalarVal);
100+
staticvoidappendKey(JsonbParseState*pstate,constJsonbValue*scalarVal);
101+
staticvoidappendValue(JsonbParseState*pstate,constJsonbValue*scalarVal);
102+
staticvoidappendElement(JsonbParseState*pstate,constJsonbValue*scalarVal);
103103
staticintlengthCompareJsonbStringValue(constvoid*a,constvoid*b);
104104
staticintlengthCompareJsonbString(constchar*val1,intlen1,
105105
constchar*val2,intlen2);
@@ -108,9 +108,9 @@ static void uniqueifyJsonbObject(JsonbValue *object, bool unique_keys,
108108
boolskip_nulls);
109109
staticJsonbValue*pushJsonbValueScalar(JsonbParseState**pstate,
110110
JsonbIteratorTokenseq,
111-
JsonbValue*scalarVal);
111+
constJsonbValue*scalarVal);
112112
staticJsonbValue*pushSingleScalarJsonbValue(JsonbParseState**pstate,
113-
JsonbValue*jbval);
113+
constJsonbValue*jbval);
114114

115115
void
116116
JsonbToJsonbValue(Jsonb*jsonb,JsonbValue*val)
@@ -375,10 +375,10 @@ compareJsonbContainers(JsonbContainer *a, JsonbContainer *b)
375375
* return NULL. Otherwise, return palloc()'d copy of value.
376376
*/
377377
JsonbValue*
378-
findJsonbValueFromContainer(JsonbContainer*container,uint32flags,
378+
findJsonbValueFromContainer(constJsonbContainer*container,uint32flags,
379379
JsonbValue*key)
380380
{
381-
JEntry*children=container->children;
381+
constJEntry*children=container->children;
382382
intcount=JsonContainerSize(container);
383383

384384
Assert((flags& ~(JB_FARRAY |JB_FOBJECT))==0);
@@ -429,10 +429,10 @@ findJsonbValueFromContainer(JsonbContainer *container, uint32 flags,
429429
* 'res' can be passed in as NULL, in which case it's newly palloc'ed here.
430430
*/
431431
JsonbValue*
432-
getKeyJsonValueFromContainer(JsonbContainer*container,
432+
getKeyJsonValueFromContainer(constJsonbContainer*container,
433433
constchar*keyVal,intkeyLen,JsonbValue*res)
434434
{
435-
JEntry*children=container->children;
435+
constJEntry*children=container->children;
436436
intcount=JsonContainerSize(container);
437437
char*baseAddr;
438438
uint32stopLow,
@@ -536,7 +536,7 @@ getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
536536
* expanded.
537537
*/
538538
staticvoid
539-
fillJsonbValue(JsonbContainer*container,intindex,
539+
fillJsonbValue(constJsonbContainer*container,intindex,
540540
char*base_addr,uint32offset,
541541
JsonbValue*result)
542542
{
@@ -638,7 +638,7 @@ JsonbParseStateSetSkipNulls(JsonbParseState *state, bool skip_nulls)
638638
*/
639639
JsonbValue*
640640
pushJsonbValue(JsonbParseState**pstate,JsonbIteratorTokenseq,
641-
JsonbValue*jbval)
641+
constJsonbValue*jbval)
642642
{
643643
JsonbIterator*it;
644644
JsonbValue*res=NULL;
@@ -712,7 +712,7 @@ pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
712712
*/
713713
staticJsonbValue*
714714
pushJsonbValueScalar(JsonbParseState**pstate,JsonbIteratorTokenseq,
715-
JsonbValue*scalarVal)
715+
constJsonbValue*scalarVal)
716716
{
717717
JsonbValue*result=NULL;
718718

@@ -799,7 +799,7 @@ pushJsonbValueScalar(JsonbParseState **pstate, JsonbIteratorToken seq,
799799
}
800800

801801
staticJsonbValue*
802-
pushSingleScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval)
802+
pushSingleScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval)
803803
{
804804
/* single root scalar */
805805
JsonbValueva;
@@ -814,7 +814,7 @@ pushSingleScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval)
814814
}
815815

816816
staticJsonbValue*
817-
pushNestedScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval,
817+
pushNestedScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval,
818818
boolisKey)
819819
{
820820
switch ((*pstate)->contVal.type)
@@ -830,7 +830,8 @@ pushNestedScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval,
830830
}
831831

832832
JsonbValue*
833-
pushScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval,boolisKey)
833+
pushScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval,
834+
boolisKey)
834835
{
835836
return*pstate==NULL
836837
?pushSingleScalarJsonbValue(pstate,jbval)
@@ -857,7 +858,7 @@ pushState(JsonbParseState **pstate)
857858
* pushJsonbValue() worker: Append a pair key to state when generating a Jsonb
858859
*/
859860
staticvoid
860-
appendKey(JsonbParseState*pstate,JsonbValue*string)
861+
appendKey(JsonbParseState*pstate,constJsonbValue*string)
861862
{
862863
JsonbValue*object=&pstate->contVal;
863864

@@ -886,7 +887,7 @@ appendKey(JsonbParseState *pstate, JsonbValue *string)
886887
* Jsonb
887888
*/
888889
staticvoid
889-
appendValue(JsonbParseState*pstate,JsonbValue*scalarVal)
890+
appendValue(JsonbParseState*pstate,constJsonbValue*scalarVal)
890891
{
891892
JsonbValue*object=&pstate->contVal;
892893

@@ -899,7 +900,7 @@ appendValue(JsonbParseState *pstate, JsonbValue *scalarVal)
899900
* pushJsonbValue() worker: Append an element to state when generating a Jsonb
900901
*/
901902
staticvoid
902-
appendElement(JsonbParseState*pstate,JsonbValue*scalarVal)
903+
appendElement(JsonbParseState*pstate,constJsonbValue*scalarVal)
903904
{
904905
JsonbValue*array=&pstate->contVal;
905906

@@ -1512,7 +1513,7 @@ JsonbHashScalarValueExtended(const JsonbValue *scalarVal, uint64 *hash,
15121513
* Are two scalar JsonbValues of the same type a and b equal?
15131514
*/
15141515
staticbool
1515-
equalsJsonbScalarValue(JsonbValue*aScalar,JsonbValue*bScalar)
1516+
equalsJsonbScalarValue(constJsonbValue*aScalar,constJsonbValue*bScalar)
15161517
{
15171518
if (aScalar->type==bScalar->type)
15181519
{
@@ -1544,7 +1545,7 @@ equalsJsonbScalarValue(JsonbValue *aScalar, JsonbValue *bScalar)
15441545
* operators, where a lexical sort order is generally expected.
15451546
*/
15461547
staticint
1547-
compareJsonbScalarValue(JsonbValue*aScalar,JsonbValue*bScalar)
1548+
compareJsonbScalarValue(constJsonbValue*aScalar,constJsonbValue*bScalar)
15481549
{
15491550
if (aScalar->type==bScalar->type)
15501551
{
@@ -1659,7 +1660,7 @@ padBufferToInt(StringInfo buffer)
16591660
* Given a JsonbValue, convert to Jsonb. The result is palloc'd.
16601661
*/
16611662
staticJsonb*
1662-
convertToJsonb(JsonbValue*val)
1663+
convertToJsonb(constJsonbValue*val)
16631664
{
16641665
StringInfoDatabuffer;
16651666
JEntryjentry;
@@ -1701,7 +1702,7 @@ convertToJsonb(JsonbValue *val)
17011702
* for debugging purposes.
17021703
*/
17031704
staticvoid
1704-
convertJsonbValue(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel)
1705+
convertJsonbValue(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel)
17051706
{
17061707
check_stack_depth();
17071708

@@ -1726,7 +1727,7 @@ convertJsonbValue(StringInfo buffer, JEntry *header, JsonbValue *val, int level)
17261727
}
17271728

17281729
staticvoid
1729-
convertJsonbArray(StringInfobuffer,JEntry*pheader,JsonbValue*val,intlevel)
1730+
convertJsonbArray(StringInfobuffer,JEntry*pheader,constJsonbValue*val,intlevel)
17301731
{
17311732
intbase_offset;
17321733
intjentry_offset;
@@ -1810,7 +1811,7 @@ convertJsonbArray(StringInfo buffer, JEntry *pheader, JsonbValue *val, int level
18101811
}
18111812

18121813
staticvoid
1813-
convertJsonbObject(StringInfobuffer,JEntry*pheader,JsonbValue*val,intlevel)
1814+
convertJsonbObject(StringInfobuffer,JEntry*pheader,constJsonbValue*val,intlevel)
18141815
{
18151816
intbase_offset;
18161817
intjentry_offset;
@@ -1926,7 +1927,7 @@ convertJsonbObject(StringInfo buffer, JEntry *pheader, JsonbValue *val, int leve
19261927
}
19271928

19281929
staticvoid
1929-
convertJsonbScalar(StringInfobuffer,JEntry*jentry,JsonbValue*scalarVal)
1930+
convertJsonbScalar(StringInfobuffer,JEntry*jentry,constJsonbValue*scalarVal)
19301931
{
19311932
intnumlen;
19321933
shortpadlen;

‎src/include/utils/jsonb.h‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,18 +360,19 @@ typedef enum/* type categories for datum_to_jsonb */
360360

361361
/* Support functions */
362362
externintcompareJsonbContainers(JsonbContainer*a,JsonbContainer*b);
363-
externJsonbValue*findJsonbValueFromContainer(JsonbContainer*sheader,
363+
externJsonbValue*findJsonbValueFromContainer(constJsonbContainer*sheader,
364364
uint32flags,
365365
JsonbValue*key);
366-
externJsonbValue*getKeyJsonValueFromContainer(JsonbContainer*container,
366+
externJsonbValue*getKeyJsonValueFromContainer(constJsonbContainer*container,
367367
constchar*keyVal,intkeyLen,
368368
JsonbValue*res);
369369
externJsonbValue*getIthJsonbValueFromContainer(JsonbContainer*sheader,
370370
uint32i);
371371
externJsonbValue*pushJsonbValue(JsonbParseState**pstate,
372-
JsonbIteratorTokenseq,JsonbValue*jbval);
372+
JsonbIteratorTokenseq,
373+
constJsonbValue*jbval);
373374
externJsonbValue*pushScalarJsonbValue(JsonbParseState**pstate,
374-
JsonbValue*jbval,boolisKey);
375+
constJsonbValue*jbval,boolisKey);
375376
externJsonbParseState*JsonbParseStateClone(JsonbParseState*state);
376377
externvoidJsonbParseStateSetUniqueKeys(JsonbParseState*state,boolunique_keys);
377378
externvoidJsonbParseStateSetSkipNulls(JsonbParseState*state,boolskip_nulls);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp