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

Commit2bcf6bf

Browse files
author
Nikita Glukhov
committed
Add const qualifiers for JsonbValue * parameters
1 parentc50bcbf commit2bcf6bf

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: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ struct JsonbParseState
4444
structJsonbIterator
4545
{
4646
/* Container being iterated */
47-
JsonbContainer*container;
47+
constJsonbContainer*container;
4848
uint32nElems;/* Number of elements in children array (will
4949
* be nPairs for objects) */
5050
boolisScalar;/* Pseudo-array scalar value? */
51-
JEntry*children;/* JEntrys for child nodes */
51+
constJEntry*children;/* JEntrys for child nodes */
5252
/* Data proper. This points to the beginning of the variable-length data */
5353
char*dataProper;
5454

@@ -71,16 +71,16 @@ struct JsonbIterator
7171
structJsonbIterator*parent;
7272
};
7373

74-
staticvoidfillJsonbValue(JsonbContainer*container,intindex,
74+
staticvoidfillJsonbValue(constJsonbContainer*container,intindex,
7575
char*base_addr,uint32offset,
7676
JsonbValue*result);
77-
staticboolequalsJsonbScalarValue(JsonbValue*a,JsonbValue*b);
78-
staticintcompareJsonbScalarValue(JsonbValue*a,JsonbValue*b);
79-
staticJsonb*convertToJsonb(JsonbValue*val);
80-
staticvoidconvertJsonbValue(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel);
81-
staticvoidconvertJsonbArray(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel);
82-
staticvoidconvertJsonbObject(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel);
83-
staticvoidconvertJsonbScalar(StringInfobuffer,JEntry*header,JsonbValue*scalarVal);
77+
staticboolequalsJsonbScalarValue(constJsonbValue*a,constJsonbValue*b);
78+
staticintcompareJsonbScalarValue(constJsonbValue*a,constJsonbValue*b);
79+
staticJsonb*convertToJsonb(constJsonbValue*val);
80+
staticvoidconvertJsonbValue(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel);
81+
staticvoidconvertJsonbArray(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel);
82+
staticvoidconvertJsonbObject(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel);
83+
staticvoidconvertJsonbScalar(StringInfobuffer,JEntry*header,constJsonbValue*scalarVal);
8484

8585
staticintreserveFromBuffer(StringInfobuffer,intlen);
8686
staticvoidappendToBuffer(StringInfobuffer,constchar*data,intlen);
@@ -90,17 +90,17 @@ static short padBufferToInt(StringInfo buffer);
9090
staticJsonbIterator*iteratorFromContainer(JsonbContainer*container,JsonbIterator*parent);
9191
staticJsonbIterator*freeAndGetParent(JsonbIterator*it);
9292
staticJsonbParseState*pushState(JsonbParseState**pstate);
93-
staticvoidappendKey(JsonbParseState*pstate,JsonbValue*scalarVal);
94-
staticvoidappendValue(JsonbParseState*pstate,JsonbValue*scalarVal);
95-
staticvoidappendElement(JsonbParseState*pstate,JsonbValue*scalarVal);
93+
staticvoidappendKey(JsonbParseState*pstate,constJsonbValue*scalarVal);
94+
staticvoidappendValue(JsonbParseState*pstate,constJsonbValue*scalarVal);
95+
staticvoidappendElement(JsonbParseState*pstate,constJsonbValue*scalarVal);
9696
staticintlengthCompareJsonbStringValue(constvoid*a,constvoid*b);
9797
staticintlengthCompareJsonbPair(constvoid*a,constvoid*b,void*arg);
9898
staticvoiduniqueifyJsonbObject(JsonbValue*object);
99-
staticJsonbValue*pushJsonbValueScalar(JsonbParseState**pstate,
100-
JsonbIteratorTokenseq,
101-
JsonbValue*scalarVal);
99+
externJsonbValue*pushJsonbValueScalar(JsonbParseState**pstate,
100+
JsonbIteratorTokenseq,
101+
constJsonbValue*scalarVal);
102102
staticJsonbValue*pushSingleScalarJsonbValue(JsonbParseState**pstate,
103-
JsonbValue*jbval);
103+
constJsonbValue*jbval);
104104

105105
/*
106106
* Turn an in-memory JsonbValue into a Jsonb for on-disk storage.
@@ -483,7 +483,7 @@ getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
483483
* expanded.
484484
*/
485485
staticvoid
486-
fillJsonbValue(JsonbContainer*container,intindex,
486+
fillJsonbValue(constJsonbContainer*container,intindex,
487487
char*base_addr,uint32offset,
488488
JsonbValue*result)
489489
{
@@ -571,7 +571,7 @@ JsonbParseStateClone(JsonbParseState *state)
571571
*/
572572
JsonbValue*
573573
pushJsonbValue(JsonbParseState**pstate,JsonbIteratorTokenseq,
574-
JsonbValue*jbval)
574+
constJsonbValue*jbval)
575575
{
576576
JsonbIterator*it;
577577
JsonbValue*res=NULL;
@@ -600,7 +600,7 @@ pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
600600
*/
601601
staticJsonbValue*
602602
pushJsonbValueScalar(JsonbParseState**pstate,JsonbIteratorTokenseq,
603-
JsonbValue*scalarVal)
603+
constJsonbValue*scalarVal)
604604
{
605605
JsonbValue*result=NULL;
606606

@@ -685,7 +685,7 @@ pushJsonbValueScalar(JsonbParseState **pstate, JsonbIteratorToken seq,
685685
}
686686

687687
staticJsonbValue*
688-
pushSingleScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval)
688+
pushSingleScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval)
689689
{
690690
/* single root scalar */
691691
JsonbValueva;
@@ -700,8 +700,8 @@ pushSingleScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval)
700700
}
701701

702702
staticJsonbValue*
703-
pushNestedScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval,
704-
boolisKey)
703+
pushNestedScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval,
704+
boolisKey)
705705
{
706706
switch ((*pstate)->contVal.type)
707707
{
@@ -716,7 +716,8 @@ pushNestedScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval,
716716
}
717717

718718
JsonbValue*
719-
pushScalarJsonbValue(JsonbParseState**pstate,JsonbValue*jbval,boolisKey)
719+
pushScalarJsonbValue(JsonbParseState**pstate,constJsonbValue*jbval,
720+
boolisKey)
720721
{
721722
return*pstate==NULL
722723
?pushSingleScalarJsonbValue(pstate,jbval)
@@ -740,7 +741,7 @@ pushState(JsonbParseState **pstate)
740741
* pushJsonbValue() worker: Append a pair key to state when generating a Jsonb
741742
*/
742743
staticvoid
743-
appendKey(JsonbParseState*pstate,JsonbValue*string)
744+
appendKey(JsonbParseState*pstate,constJsonbValue*string)
744745
{
745746
JsonbValue*object=&pstate->contVal;
746747

@@ -769,7 +770,7 @@ appendKey(JsonbParseState *pstate, JsonbValue *string)
769770
* Jsonb
770771
*/
771772
staticvoid
772-
appendValue(JsonbParseState*pstate,JsonbValue*scalarVal)
773+
appendValue(JsonbParseState*pstate,constJsonbValue*scalarVal)
773774
{
774775
JsonbValue*object=&pstate->contVal;
775776

@@ -782,7 +783,7 @@ appendValue(JsonbParseState *pstate, JsonbValue *scalarVal)
782783
* pushJsonbValue() worker: Append an element to state when generating a Jsonb
783784
*/
784785
staticvoid
785-
appendElement(JsonbParseState*pstate,JsonbValue*scalarVal)
786+
appendElement(JsonbParseState*pstate,constJsonbValue*scalarVal)
786787
{
787788
JsonbValue*array=&pstate->contVal;
788789

@@ -1349,7 +1350,7 @@ JsonbHashScalarValue(const JsonbValue *scalarVal, uint32 *hash)
13491350
* Are two scalar JsonbValues of the same type a and b equal?
13501351
*/
13511352
staticbool
1352-
equalsJsonbScalarValue(JsonbValue*aScalar,JsonbValue*bScalar)
1353+
equalsJsonbScalarValue(constJsonbValue*aScalar,constJsonbValue*bScalar)
13531354
{
13541355
if (aScalar->type==bScalar->type)
13551356
{
@@ -1381,7 +1382,7 @@ equalsJsonbScalarValue(JsonbValue *aScalar, JsonbValue *bScalar)
13811382
* operators, where a lexical sort order is generally expected.
13821383
*/
13831384
staticint
1384-
compareJsonbScalarValue(JsonbValue*aScalar,JsonbValue*bScalar)
1385+
compareJsonbScalarValue(constJsonbValue*aScalar,constJsonbValue*bScalar)
13851386
{
13861387
if (aScalar->type==bScalar->type)
13871388
{
@@ -1496,7 +1497,7 @@ padBufferToInt(StringInfo buffer)
14961497
* Given a JsonbValue, convert to Jsonb. The result is palloc'd.
14971498
*/
14981499
staticJsonb*
1499-
convertToJsonb(JsonbValue*val)
1500+
convertToJsonb(constJsonbValue*val)
15001501
{
15011502
StringInfoDatabuffer;
15021503
JEntryjentry;
@@ -1538,7 +1539,7 @@ convertToJsonb(JsonbValue *val)
15381539
* for debugging purposes.
15391540
*/
15401541
staticvoid
1541-
convertJsonbValue(StringInfobuffer,JEntry*header,JsonbValue*val,intlevel)
1542+
convertJsonbValue(StringInfobuffer,JEntry*header,constJsonbValue*val,intlevel)
15421543
{
15431544
check_stack_depth();
15441545

@@ -1563,7 +1564,7 @@ convertJsonbValue(StringInfo buffer, JEntry *header, JsonbValue *val, int level)
15631564
}
15641565

15651566
staticvoid
1566-
convertJsonbArray(StringInfobuffer,JEntry*pheader,JsonbValue*val,intlevel)
1567+
convertJsonbArray(StringInfobuffer,JEntry*pheader,constJsonbValue*val,intlevel)
15671568
{
15681569
intbase_offset;
15691570
intjentry_offset;
@@ -1647,7 +1648,7 @@ convertJsonbArray(StringInfo buffer, JEntry *pheader, JsonbValue *val, int level
16471648
}
16481649

16491650
staticvoid
1650-
convertJsonbObject(StringInfobuffer,JEntry*pheader,JsonbValue*val,intlevel)
1651+
convertJsonbObject(StringInfobuffer,JEntry*pheader,constJsonbValue*val,intlevel)
16511652
{
16521653
intbase_offset;
16531654
intjentry_offset;
@@ -1763,7 +1764,7 @@ convertJsonbObject(StringInfo buffer, JEntry *pheader, JsonbValue *val, int leve
17631764
}
17641765

17651766
staticvoid
1766-
convertJsonbScalar(StringInfobuffer,JEntry*jentry,JsonbValue*scalarVal)
1767+
convertJsonbScalar(StringInfobuffer,JEntry*jentry,constJsonbValue*scalarVal)
17671768
{
17681769
intnumlen;
17691770
shortpadlen;

‎src/include/utils/jsonb.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,16 @@ typedef struct JsonbIterator JsonbIterator;
321321

322322
/* Support functions */
323323
externintcompareJsonbContainers(JsonbContainer*a,JsonbContainer*b);
324-
externJsonbValue*findJsonbValueFromContainer(JsonbContainer*sheader,
324+
externJsonbValue*findJsonbValueFromContainer(constJsonbContainer*sheader,
325325
uint32flags,
326326
JsonbValue*key);
327327
externJsonbValue*getIthJsonbValueFromContainer(JsonbContainer*sheader,
328328
uint32i);
329329
externJsonbValue*pushJsonbValue(JsonbParseState**pstate,
330-
JsonbIteratorTokenseq,JsonbValue*jbVal);
330+
JsonbIteratorTokenseq,
331+
constJsonbValue*jbVal);
331332
externJsonbValue*pushScalarJsonbValue(JsonbParseState**pstate,
332-
JsonbValue*jbval,boolisKey);
333+
constJsonbValue*jbval,boolisKey);
333334
externJsonbParseState*JsonbParseStateClone(JsonbParseState*state);
334335
externJsonbIterator*JsonbIteratorInit(JsonbContainer*container);
335336
externJsonbIteratorTokenJsonbIteratorNext(JsonbIterator**it,JsonbValue*val,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp