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

Commit5fb585e

Browse files
author
Nikita Glukhov
committed
Add const qualifiers for JsonbValue * parameters
1 parent71595a6 commit5fb585e

File tree

2 files changed

+39
-37
lines changed

2 files changed

+39
-37
lines changed

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

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ struct JsonbParseState
4848
structJsonbIterator
4949
{
5050
/* Container being iterated */
51-
JsonbContainer*container;
51+
constJsonbContainer*container;
5252
uint32nElems;/* Number of elements in children array (will
5353
* be nPairs for objects) */
5454
boolisScalar;/* Pseudo-array scalar value? */
55-
JEntry*children;/* JEntrys for child nodes */
55+
constJEntry*children;/* JEntrys for child nodes */
5656
/* Data proper. This points to the beginning of the variable-length data */
5757
char*dataProper;
5858

@@ -75,16 +75,16 @@ struct JsonbIterator
7575
structJsonbIterator*parent;
7676
};
7777

78-
staticvoidfillJsonbValue(JsonbContainer*container,intindex,
78+
staticvoidfillJsonbValue(constJsonbContainer*container,intindex,
7979
char*base_addr,uint32offset,
8080
JsonbValue*result);
81-
staticboolequalsJsonbScalarValue(JsonbValue*a,JsonbValue*b);
82-
staticintcompareJsonbScalarValue(JsonbValue*a,JsonbValue*b);
83-
staticJsonb*convertToJsonb(JsonbValue*val);
84-
staticvoidconvertJsonbValue(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel);
85-
staticvoidconvertJsonbArray(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel);
86-
staticvoidconvertJsonbObject(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel);
87-
staticvoidconvertJsonbScalar(StringInfobuffer,JEntry*header,JsonbValue*scalarVal);
81+
staticboolequalsJsonbScalarValue(constJsonbValue*a,constJsonbValue*b);
82+
staticintcompareJsonbScalarValue(constJsonbValue*a,constJsonbValue*b);
83+
staticJsonb*convertToJsonb(constJsonbValue*val);
84+
staticvoidconvertJsonbValue(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel);
85+
staticvoidconvertJsonbArray(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel);
86+
staticvoidconvertJsonbObject(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel);
87+
staticvoidconvertJsonbScalar(StringInfobuffer,JEntry*header,constJsonbValue*scalarVal);
8888

8989
staticintreserveFromBuffer(StringInfobuffer,intlen);
9090
staticvoidappendToBuffer(StringInfobuffer,constchar*data,intlen);
@@ -94,19 +94,19 @@ static short padBufferToInt(StringInfo buffer);
9494
staticJsonbIterator*iteratorFromContainer(JsonbContainer*container,JsonbIterator*parent);
9595
staticJsonbIterator*freeAndGetParent(JsonbIterator*it);
9696
staticJsonbParseState*pushState(JsonbParseState**pstate);
97-
staticvoidappendKey(JsonbParseState*pstate,JsonbValue*scalarVal);
98-
staticvoidappendValue(JsonbParseState*pstate,JsonbValue*scalarVal);
99-
staticvoidappendElement(JsonbParseState*pstate,JsonbValue*scalarVal);
97+
staticvoidappendKey(JsonbParseState*pstate,constJsonbValue*scalarVal);
98+
staticvoidappendValue(JsonbParseState*pstate,constJsonbValue*scalarVal);
99+
staticvoidappendElement(JsonbParseState*pstate,constJsonbValue*scalarVal);
100100
staticintlengthCompareJsonbStringValue(constvoid*a,constvoid*b);
101101
staticintlengthCompareJsonbString(constchar*val1,intlen1,
102102
constchar*val2,intlen2);
103103
staticintlengthCompareJsonbPair(constvoid*a,constvoid*b,void*arg);
104104
staticvoiduniqueifyJsonbObject(JsonbValue*object);
105105
staticJsonbValue*pushJsonbValueScalar(JsonbParseState**pstate,
106106
JsonbIteratorTokenseq,
107-
JsonbValue*scalarVal);
107+
constJsonbValue*scalarVal);
108108
staticJsonbValue*pushSingleScalarJsonbValue(JsonbParseState**pstate,
109-
JsonbValue*jbval);
109+
constJsonbValue*jbval);
110110

111111
/*
112112
* Turn an in-memory JsonbValue into a Jsonb for on-disk storage.
@@ -418,7 +418,7 @@ findJsonbValueFromContainer(JsonbContainer *container, uint32 flags,
418418
* 'res' can be passed in as NULL, in which case it's newly palloc'ed here.
419419
*/
420420
JsonbValue*
421-
getKeyJsonValueFromContainer(JsonbContainer*container,
421+
getKeyJsonValueFromContainer(constJsonbContainer*container,
422422
constchar*keyVal,intkeyLen,JsonbValue*res)
423423
{
424424
JEntry*children=container->children;
@@ -525,7 +525,7 @@ getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
525525
* expanded.
526526
*/
527527
staticvoid
528-
fillJsonbValue(JsonbContainer*container,intindex,
528+
fillJsonbValue(constJsonbContainer*container,intindex,
529529
char*base_addr,uint32offset,
530530
JsonbValue*result)
531531
{
@@ -613,7 +613,7 @@ JsonbParseStateClone(JsonbParseState *state)
613613
*/
614614
JsonbValue*
615615
pushJsonbValue(JsonbParseState**pstate,JsonbIteratorTokenseq,
616-
JsonbValue*jbval)
616+
constJsonbValue*jbval)
617617
{
618618
JsonbIterator*it;
619619
JsonbValue*res=NULL;
@@ -642,7 +642,7 @@ pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
642642
*/
643643
staticJsonbValue*
644644
pushJsonbValueScalar(JsonbParseState**pstate,JsonbIteratorTokenseq,
645-
JsonbValue*scalarVal)
645+
constJsonbValue*scalarVal)
646646
{
647647
JsonbValue*result=NULL;
648648

@@ -727,7 +727,7 @@ pushJsonbValueScalar(JsonbParseState **pstate, JsonbIteratorToken seq,
727727
}
728728

729729
staticJsonbValue*
730-
pushSingleScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval)
730+
pushSingleScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval)
731731
{
732732
/* single root scalar */
733733
JsonbValueva;
@@ -742,8 +742,8 @@ pushSingleScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval)
742742
}
743743

744744
staticJsonbValue*
745-
pushNestedScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval,
746-
boolisKey)
745+
pushNestedScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval,
746+
boolisKey)
747747
{
748748
switch ((*pstate)->contVal.type)
749749
{
@@ -758,7 +758,8 @@ pushNestedScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval,
758758
}
759759

760760
JsonbValue*
761-
pushScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval,boolisKey)
761+
pushScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval,
762+
boolisKey)
762763
{
763764
return*pstate==NULL
764765
?pushSingleScalarJsonbValue(pstate,jbval)
@@ -782,7 +783,7 @@ pushState(JsonbParseState **pstate)
782783
* pushJsonbValue() worker: Append a pair key to state when generating a Jsonb
783784
*/
784785
staticvoid
785-
appendKey(JsonbParseState*pstate,JsonbValue*string)
786+
appendKey(JsonbParseState*pstate,constJsonbValue*string)
786787
{
787788
JsonbValue*object=&pstate->contVal;
788789

@@ -811,7 +812,7 @@ appendKey(JsonbParseState *pstate, JsonbValue *string)
811812
* Jsonb
812813
*/
813814
staticvoid
814-
appendValue(JsonbParseState*pstate,JsonbValue*scalarVal)
815+
appendValue(JsonbParseState*pstate,constJsonbValue*scalarVal)
815816
{
816817
JsonbValue*object=&pstate->contVal;
817818

@@ -824,7 +825,7 @@ appendValue(JsonbParseState *pstate, JsonbValue *scalarVal)
824825
* pushJsonbValue() worker: Append an element to state when generating a Jsonb
825826
*/
826827
staticvoid
827-
appendElement(JsonbParseState*pstate,JsonbValue*scalarVal)
828+
appendElement(JsonbParseState*pstate,constJsonbValue*scalarVal)
828829
{
829830
JsonbValue*array=&pstate->contVal;
830831

@@ -1437,7 +1438,7 @@ JsonbHashScalarValueExtended(const JsonbValue *scalarVal, uint64 *hash,
14371438
* Are two scalar JsonbValues of the same type a and b equal?
14381439
*/
14391440
staticbool
1440-
equalsJsonbScalarValue(JsonbValue*aScalar,JsonbValue*bScalar)
1441+
equalsJsonbScalarValue(constJsonbValue*aScalar,constJsonbValue*bScalar)
14411442
{
14421443
if (aScalar->type==bScalar->type)
14431444
{
@@ -1469,7 +1470,7 @@ equalsJsonbScalarValue(JsonbValue *aScalar, JsonbValue *bScalar)
14691470
* operators, where a lexical sort order is generally expected.
14701471
*/
14711472
staticint
1472-
compareJsonbScalarValue(JsonbValue*aScalar,JsonbValue*bScalar)
1473+
compareJsonbScalarValue(constJsonbValue*aScalar,constJsonbValue*bScalar)
14731474
{
14741475
if (aScalar->type==bScalar->type)
14751476
{
@@ -1584,7 +1585,7 @@ padBufferToInt(StringInfo buffer)
15841585
* Given a JsonbValue, convert to Jsonb. The result is palloc'd.
15851586
*/
15861587
staticJsonb*
1587-
convertToJsonb(JsonbValue*val)
1588+
convertToJsonb(constJsonbValue*val)
15881589
{
15891590
StringInfoDatabuffer;
15901591
JEntryjentry;
@@ -1626,7 +1627,7 @@ convertToJsonb(JsonbValue *val)
16261627
* for debugging purposes.
16271628
*/
16281629
staticvoid
1629-
convertJsonbValue(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel)
1630+
convertJsonbValue(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel)
16301631
{
16311632
check_stack_depth();
16321633

@@ -1651,7 +1652,7 @@ convertJsonbValue(StringInfo buffer, JEntry *header, JsonbValue *val, int level)
16511652
}
16521653

16531654
staticvoid
1654-
convertJsonbArray(StringInfobuffer,JEntry*pheader,JsonbValue*val,intlevel)
1655+
convertJsonbArray(StringInfobuffer,JEntry*pheader,constJsonbValue*val,intlevel)
16551656
{
16561657
intbase_offset;
16571658
intjentry_offset;
@@ -1735,7 +1736,7 @@ convertJsonbArray(StringInfo buffer, JEntry *pheader, JsonbValue *val, int level
17351736
}
17361737

17371738
staticvoid
1738-
convertJsonbObject(StringInfobuffer,JEntry*pheader,JsonbValue*val,intlevel)
1739+
convertJsonbObject(StringInfobuffer,JEntry*pheader,constJsonbValue*val,intlevel)
17391740
{
17401741
intbase_offset;
17411742
intjentry_offset;
@@ -1851,7 +1852,7 @@ convertJsonbObject(StringInfo buffer, JEntry *pheader, JsonbValue *val, int leve
18511852
}
18521853

18531854
staticvoid
1854-
convertJsonbScalar(StringInfobuffer,JEntry*jentry,JsonbValue*scalarVal)
1855+
convertJsonbScalar(StringInfobuffer,JEntry*jentry,constJsonbValue*scalarVal)
18551856
{
18561857
intnumlen;
18571858
shortpadlen;

‎src/include/utils/jsonb.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,18 +344,19 @@ typedef struct JsonbIterator JsonbIterator;
344344

345345
/* Support functions */
346346
externintcompareJsonbContainers(JsonbContainer*a,JsonbContainer*b);
347-
externJsonbValue*findJsonbValueFromContainer(JsonbContainer*sheader,
347+
externJsonbValue*findJsonbValueFromContainer(constJsonbContainer*sheader,
348348
uint32flags,
349349
JsonbValue*key);
350-
externJsonbValue*getKeyJsonValueFromContainer(JsonbContainer*container,
350+
externJsonbValue*getKeyJsonValueFromContainer(constJsonbContainer*container,
351351
constchar*keyVal,intkeyLen,
352352
JsonbValue*res);
353353
externJsonbValue*getIthJsonbValueFromContainer(JsonbContainer*sheader,
354354
uint32i);
355355
externJsonbValue*pushJsonbValue(JsonbParseState**pstate,
356-
JsonbIteratorTokenseq,JsonbValue*jbval);
356+
JsonbIteratorTokenseq,
357+
constJsonbValue*jbval);
357358
externJsonbValue*pushScalarJsonbValue(JsonbParseState**pstate,
358-
JsonbValue*jbval,boolisKey);
359+
constJsonbValue*jbval,boolisKey);
359360
externJsonbParseState*JsonbParseStateClone(JsonbParseState*state);
360361
externJsonbIterator*JsonbIteratorInit(JsonbContainer*container);
361362
externJsonbIteratorTokenJsonbIteratorNext(JsonbIterator**it,JsonbValue*val,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp