@@ -48,11 +48,11 @@ struct JsonbParseState
4848struct JsonbIterator
4949{
5050 /* Container being iterated */
51- JsonbContainer * container ;
51+ const JsonbContainer * container ;
5252 uint32 nElems ; /* Number of elements in children array (will
5353 * be nPairs for objects) */
5454 bool isScalar ; /* Pseudo-array scalar value? */
55- JEntry * children ; /* JEntrys for child nodes */
55+ const JEntry * 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 struct JsonbIterator * parent ;
7676};
7777
78- static void fillJsonbValue (JsonbContainer * container , int index ,
78+ static void fillJsonbValue (const JsonbContainer * container , int index ,
7979 char * base_addr , uint32 offset ,
8080 JsonbValue * result );
81- static bool equalsJsonbScalarValue (JsonbValue * a , JsonbValue * b );
82- static int compareJsonbScalarValue (JsonbValue * a , JsonbValue * b );
83- static Jsonb * convertToJsonb (JsonbValue * val );
84- static void convertJsonbValue (StringInfo buffer , JEntry * header , JsonbValue * val , int level );
85- static void convertJsonbArray (StringInfo buffer , JEntry * header , JsonbValue * val , int level );
86- static void convertJsonbObject (StringInfo buffer , JEntry * header , JsonbValue * val , int level );
87- static void convertJsonbScalar (StringInfo buffer , JEntry * header , JsonbValue * scalarVal );
81+ static bool equalsJsonbScalarValue (const JsonbValue * a , const JsonbValue * b );
82+ static int compareJsonbScalarValue (const JsonbValue * a , const JsonbValue * b );
83+ static Jsonb * convertToJsonb (const JsonbValue * val );
84+ static void convertJsonbValue (StringInfo buffer , JEntry * header , const JsonbValue * val , int level );
85+ static void convertJsonbArray (StringInfo buffer , JEntry * header , const JsonbValue * val , int level );
86+ static void convertJsonbObject (StringInfo buffer , JEntry * header , const JsonbValue * val , int level );
87+ static void convertJsonbScalar (StringInfo buffer , JEntry * header , const JsonbValue * scalarVal );
8888
8989static int reserveFromBuffer (StringInfo buffer , int len );
9090static void appendToBuffer (StringInfo buffer , const char * data , int len );
@@ -94,19 +94,19 @@ static short padBufferToInt(StringInfo buffer);
9494static JsonbIterator * iteratorFromContainer (JsonbContainer * container , JsonbIterator * parent );
9595static JsonbIterator * freeAndGetParent (JsonbIterator * it );
9696static JsonbParseState * pushState (JsonbParseState * * pstate );
97- static void appendKey (JsonbParseState * pstate , JsonbValue * scalarVal );
98- static void appendValue (JsonbParseState * pstate , JsonbValue * scalarVal );
99- static void appendElement (JsonbParseState * pstate , JsonbValue * scalarVal );
97+ static void appendKey (JsonbParseState * pstate , const JsonbValue * scalarVal );
98+ static void appendValue (JsonbParseState * pstate , const JsonbValue * scalarVal );
99+ static void appendElement (JsonbParseState * pstate , const JsonbValue * scalarVal );
100100static int lengthCompareJsonbStringValue (const void * a , const void * b );
101101static int lengthCompareJsonbString (const char * val1 , int len1 ,
102102 const char * val2 , int len2 );
103103static int lengthCompareJsonbPair (const void * a , const void * b , void * arg );
104104static void uniqueifyJsonbObject (JsonbValue * object );
105105static JsonbValue * pushJsonbValueScalar (JsonbParseState * * pstate ,
106106 JsonbIteratorToken seq ,
107- JsonbValue * scalarVal );
107+ const JsonbValue * scalarVal );
108108static JsonbValue * pushSingleScalarJsonbValue (JsonbParseState * * pstate ,
109- JsonbValue * jbval );
109+ const JsonbValue * 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 */
420420JsonbValue *
421- getKeyJsonValueFromContainer (JsonbContainer * container ,
421+ getKeyJsonValueFromContainer (const JsonbContainer * container ,
422422 const char * keyVal , int keyLen , JsonbValue * res )
423423{
424424 JEntry * children = container -> children ;
@@ -525,7 +525,7 @@ getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
525525 * expanded.
526526 */
527527static void
528- fillJsonbValue (JsonbContainer * container , int index ,
528+ fillJsonbValue (const JsonbContainer * container , int index ,
529529 char * base_addr , uint32 offset ,
530530 JsonbValue * result )
531531{
@@ -613,7 +613,7 @@ JsonbParseStateClone(JsonbParseState *state)
613613 */
614614JsonbValue *
615615pushJsonbValue (JsonbParseState * * pstate , JsonbIteratorToken seq ,
616- JsonbValue * jbval )
616+ const JsonbValue * jbval )
617617{
618618 JsonbIterator * it ;
619619 JsonbValue * res = NULL ;
@@ -642,7 +642,7 @@ pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
642642 */
643643static JsonbValue *
644644pushJsonbValueScalar (JsonbParseState * * pstate , JsonbIteratorToken seq ,
645- JsonbValue * scalarVal )
645+ const JsonbValue * scalarVal )
646646{
647647 JsonbValue * result = NULL ;
648648
@@ -727,7 +727,7 @@ pushJsonbValueScalar(JsonbParseState **pstate, JsonbIteratorToken seq,
727727}
728728
729729static JsonbValue *
730- pushSingleScalarJsonbValue (JsonbParseState * * pstate , JsonbValue * jbval )
730+ pushSingleScalarJsonbValue (JsonbParseState * * pstate , const JsonbValue * jbval )
731731{
732732 /* single root scalar */
733733 JsonbValue va ;
@@ -742,8 +742,8 @@ pushSingleScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval)
742742}
743743
744744static JsonbValue *
745- pushNestedScalarJsonbValue (JsonbParseState * * pstate , JsonbValue * jbval ,
746- bool isKey )
745+ pushNestedScalarJsonbValue (JsonbParseState * * pstate , const JsonbValue * jbval ,
746+ bool isKey )
747747{
748748 switch ((* pstate )-> contVal .type )
749749 {
@@ -758,7 +758,8 @@ pushNestedScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval,
758758}
759759
760760JsonbValue *
761- pushScalarJsonbValue (JsonbParseState * * pstate , JsonbValue * jbval , bool isKey )
761+ pushScalarJsonbValue (JsonbParseState * * pstate , const JsonbValue * jbval ,
762+ bool isKey )
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 */
784785static void
785- appendKey (JsonbParseState * pstate , JsonbValue * string )
786+ appendKey (JsonbParseState * pstate , const JsonbValue * string )
786787{
787788 JsonbValue * object = & pstate -> contVal ;
788789
@@ -811,7 +812,7 @@ appendKey(JsonbParseState *pstate, JsonbValue *string)
811812 * Jsonb
812813 */
813814static void
814- appendValue (JsonbParseState * pstate , JsonbValue * scalarVal )
815+ appendValue (JsonbParseState * pstate , const JsonbValue * 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 */
826827static void
827- appendElement (JsonbParseState * pstate , JsonbValue * scalarVal )
828+ appendElement (JsonbParseState * pstate , const JsonbValue * 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 */
14391440static bool
1440- equalsJsonbScalarValue (JsonbValue * aScalar , JsonbValue * bScalar )
1441+ equalsJsonbScalarValue (const JsonbValue * aScalar , const JsonbValue * 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 */
14711472static int
1472- compareJsonbScalarValue (JsonbValue * aScalar , JsonbValue * bScalar )
1473+ compareJsonbScalarValue (const JsonbValue * aScalar , const JsonbValue * 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 */
15861587static Jsonb *
1587- convertToJsonb (JsonbValue * val )
1588+ convertToJsonb (const JsonbValue * val )
15881589{
15891590 StringInfoData buffer ;
15901591 JEntry jentry ;
@@ -1626,7 +1627,7 @@ convertToJsonb(JsonbValue *val)
16261627 * for debugging purposes.
16271628 */
16281629static void
1629- convertJsonbValue (StringInfo buffer , JEntry * header , JsonbValue * val , int level )
1630+ convertJsonbValue (StringInfo buffer , JEntry * header , const JsonbValue * val , int level )
16301631{
16311632 check_stack_depth ();
16321633
@@ -1651,7 +1652,7 @@ convertJsonbValue(StringInfo buffer, JEntry *header, JsonbValue *val, int level)
16511652}
16521653
16531654static void
1654- convertJsonbArray (StringInfo buffer , JEntry * pheader , JsonbValue * val , int level )
1655+ convertJsonbArray (StringInfo buffer , JEntry * pheader , const JsonbValue * val , int level )
16551656{
16561657 int base_offset ;
16571658 int jentry_offset ;
@@ -1735,7 +1736,7 @@ convertJsonbArray(StringInfo buffer, JEntry *pheader, JsonbValue *val, int level
17351736}
17361737
17371738static void
1738- convertJsonbObject (StringInfo buffer , JEntry * pheader , JsonbValue * val , int level )
1739+ convertJsonbObject (StringInfo buffer , JEntry * pheader , const JsonbValue * val , int level )
17391740{
17401741 int base_offset ;
17411742 int jentry_offset ;
@@ -1851,7 +1852,7 @@ convertJsonbObject(StringInfo buffer, JEntry *pheader, JsonbValue *val, int leve
18511852}
18521853
18531854static void
1854- convertJsonbScalar (StringInfo buffer , JEntry * jentry , JsonbValue * scalarVal )
1855+ convertJsonbScalar (StringInfo buffer , JEntry * jentry , const JsonbValue * scalarVal )
18551856{
18561857 int numlen ;
18571858 short padlen ;
0 commit comments