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

Commit7619b18

Browse files
author
Nikita Glukhov
committed
Add const qualifiers for JsonbValue * parameters
1 parente3a5760 commit7619b18

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
@@ -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
void
112112
JsonbToJsonbValue(Jsonb*jsonb,JsonbValue*val)
@@ -371,10 +371,10 @@ compareJsonbContainers(JsonbContainer *a, JsonbContainer *b)
371371
* return NULL. Otherwise, return palloc()'d copy of value.
372372
*/
373373
JsonbValue*
374-
findJsonbValueFromContainer(JsonbContainer*container,uint32flags,
374+
findJsonbValueFromContainer(constJsonbContainer*container,uint32flags,
375375
JsonbValue*key)
376376
{
377-
JEntry*children=container->children;
377+
constJEntry*children=container->children;
378378
intcount=JsonContainerSize(container);
379379

380380
Assert((flags& ~(JB_FARRAY |JB_FOBJECT))==0);
@@ -425,10 +425,10 @@ findJsonbValueFromContainer(JsonbContainer *container, uint32 flags,
425425
* 'res' can be passed in as NULL, in which case it's newly palloc'ed here.
426426
*/
427427
JsonbValue*
428-
getKeyJsonValueFromContainer(JsonbContainer*container,
428+
getKeyJsonValueFromContainer(constJsonbContainer*container,
429429
constchar*keyVal,intkeyLen,JsonbValue*res)
430430
{
431-
JEntry*children=container->children;
431+
constJEntry*children=container->children;
432432
intcount=JsonContainerSize(container);
433433
char*baseAddr;
434434
uint32stopLow,
@@ -532,7 +532,7 @@ getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
532532
* expanded.
533533
*/
534534
staticvoid
535-
fillJsonbValue(JsonbContainer*container,intindex,
535+
fillJsonbValue(constJsonbContainer*container,intindex,
536536
char*base_addr,uint32offset,
537537
JsonbValue*result)
538538
{
@@ -620,7 +620,7 @@ JsonbParseStateClone(JsonbParseState *state)
620620
*/
621621
JsonbValue*
622622
pushJsonbValue(JsonbParseState**pstate,JsonbIteratorTokenseq,
623-
JsonbValue*jbval)
623+
constJsonbValue*jbval)
624624
{
625625
JsonbIterator*it;
626626
JsonbValue*res=NULL;
@@ -694,7 +694,7 @@ pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
694694
*/
695695
staticJsonbValue*
696696
pushJsonbValueScalar(JsonbParseState**pstate,JsonbIteratorTokenseq,
697-
JsonbValue*scalarVal)
697+
constJsonbValue*scalarVal)
698698
{
699699
JsonbValue*result=NULL;
700700

@@ -779,7 +779,7 @@ pushJsonbValueScalar(JsonbParseState **pstate, JsonbIteratorToken seq,
779779
}
780780

781781
staticJsonbValue*
782-
pushSingleScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval)
782+
pushSingleScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval)
783783
{
784784
/* single root scalar */
785785
JsonbValueva;
@@ -794,7 +794,7 @@ pushSingleScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval)
794794
}
795795

796796
staticJsonbValue*
797-
pushNestedScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval,
797+
pushNestedScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval,
798798
boolisKey)
799799
{
800800
switch ((*pstate)->contVal.type)
@@ -810,7 +810,8 @@ pushNestedScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval,
810810
}
811811

812812
JsonbValue*
813-
pushScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval,boolisKey)
813+
pushScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval,
814+
boolisKey)
814815
{
815816
return*pstate==NULL
816817
?pushSingleScalarJsonbValue(pstate,jbval)
@@ -834,7 +835,7 @@ pushState(JsonbParseState **pstate)
834835
* pushJsonbValue() worker: Append a pair key to state when generating a Jsonb
835836
*/
836837
staticvoid
837-
appendKey(JsonbParseState*pstate,JsonbValue*string)
838+
appendKey(JsonbParseState*pstate,constJsonbValue*string)
838839
{
839840
JsonbValue*object=&pstate->contVal;
840841

@@ -863,7 +864,7 @@ appendKey(JsonbParseState *pstate, JsonbValue *string)
863864
* Jsonb
864865
*/
865866
staticvoid
866-
appendValue(JsonbParseState*pstate,JsonbValue*scalarVal)
867+
appendValue(JsonbParseState*pstate,constJsonbValue*scalarVal)
867868
{
868869
JsonbValue*object=&pstate->contVal;
869870

@@ -876,7 +877,7 @@ appendValue(JsonbParseState *pstate, JsonbValue *scalarVal)
876877
* pushJsonbValue() worker: Append an element to state when generating a Jsonb
877878
*/
878879
staticvoid
879-
appendElement(JsonbParseState*pstate,JsonbValue*scalarVal)
880+
appendElement(JsonbParseState*pstate,constJsonbValue*scalarVal)
880881
{
881882
JsonbValue*array=&pstate->contVal;
882883

@@ -1489,7 +1490,7 @@ JsonbHashScalarValueExtended(const JsonbValue *scalarVal, uint64 *hash,
14891490
* Are two scalar JsonbValues of the same type a and b equal?
14901491
*/
14911492
staticbool
1492-
equalsJsonbScalarValue(JsonbValue*aScalar,JsonbValue*bScalar)
1493+
equalsJsonbScalarValue(constJsonbValue*aScalar,constJsonbValue*bScalar)
14931494
{
14941495
if (aScalar->type==bScalar->type)
14951496
{
@@ -1521,7 +1522,7 @@ equalsJsonbScalarValue(JsonbValue *aScalar, JsonbValue *bScalar)
15211522
* operators, where a lexical sort order is generally expected.
15221523
*/
15231524
staticint
1524-
compareJsonbScalarValue(JsonbValue*aScalar,JsonbValue*bScalar)
1525+
compareJsonbScalarValue(constJsonbValue*aScalar,constJsonbValue*bScalar)
15251526
{
15261527
if (aScalar->type==bScalar->type)
15271528
{
@@ -1636,7 +1637,7 @@ padBufferToInt(StringInfo buffer)
16361637
* Given a JsonbValue, convert to Jsonb. The result is palloc'd.
16371638
*/
16381639
staticJsonb*
1639-
convertToJsonb(JsonbValue*val)
1640+
convertToJsonb(constJsonbValue*val)
16401641
{
16411642
StringInfoDatabuffer;
16421643
JEntryjentry;
@@ -1678,7 +1679,7 @@ convertToJsonb(JsonbValue *val)
16781679
* for debugging purposes.
16791680
*/
16801681
staticvoid
1681-
convertJsonbValue(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel)
1682+
convertJsonbValue(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel)
16821683
{
16831684
check_stack_depth();
16841685

@@ -1703,7 +1704,7 @@ convertJsonbValue(StringInfo buffer, JEntry *header, JsonbValue *val, int level)
17031704
}
17041705

17051706
staticvoid
1706-
convertJsonbArray(StringInfobuffer,JEntry*pheader,JsonbValue*val,intlevel)
1707+
convertJsonbArray(StringInfobuffer,JEntry*pheader,constJsonbValue*val,intlevel)
17071708
{
17081709
intbase_offset;
17091710
intjentry_offset;
@@ -1787,7 +1788,7 @@ convertJsonbArray(StringInfo buffer, JEntry *pheader, JsonbValue *val, int level
17871788
}
17881789

17891790
staticvoid
1790-
convertJsonbObject(StringInfobuffer,JEntry*pheader,JsonbValue*val,intlevel)
1791+
convertJsonbObject(StringInfobuffer,JEntry*pheader,constJsonbValue*val,intlevel)
17911792
{
17921793
intbase_offset;
17931794
intjentry_offset;
@@ -1903,7 +1904,7 @@ convertJsonbObject(StringInfo buffer, JEntry *pheader, JsonbValue *val, int leve
19031904
}
19041905

19051906
staticvoid
1906-
convertJsonbScalar(StringInfobuffer,JEntry*jentry,JsonbValue*scalarVal)
1907+
convertJsonbScalar(StringInfobuffer,JEntry*jentry,constJsonbValue*scalarVal)
19071908
{
19081909
intnumlen;
19091910
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