@@ -48,11 +48,11 @@ struct JsonbParseState
48
48
struct JsonbIterator
49
49
{
50
50
/* Container being iterated */
51
- JsonbContainer * container ;
51
+ const JsonbContainer * container ;
52
52
uint32 nElems ; /* Number of elements in children array (will
53
53
* be nPairs for objects) */
54
54
bool isScalar ; /* Pseudo-array scalar value? */
55
- JEntry * children ; /* JEntrys for child nodes */
55
+ const JEntry * children ; /* JEntrys for child nodes */
56
56
/* Data proper. This points to the beginning of the variable-length data */
57
57
char * dataProper ;
58
58
@@ -75,16 +75,16 @@ struct JsonbIterator
75
75
struct JsonbIterator * parent ;
76
76
};
77
77
78
- static void fillJsonbValue (JsonbContainer * container , int index ,
78
+ static void fillJsonbValue (const JsonbContainer * container , int index ,
79
79
char * base_addr , uint32 offset ,
80
80
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 );
88
88
89
89
static int reserveFromBuffer (StringInfo buffer , int len );
90
90
static void appendToBuffer (StringInfo buffer , const char * data , int len );
@@ -94,19 +94,19 @@ static short padBufferToInt(StringInfo buffer);
94
94
static JsonbIterator * iteratorFromContainer (JsonbContainer * container , JsonbIterator * parent );
95
95
static JsonbIterator * freeAndGetParent (JsonbIterator * it );
96
96
static 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 );
100
100
static int lengthCompareJsonbStringValue (const void * a , const void * b );
101
101
static int lengthCompareJsonbString (const char * val1 , int len1 ,
102
102
const char * val2 , int len2 );
103
103
static int lengthCompareJsonbPair (const void * a , const void * b , void * arg );
104
104
static void uniqueifyJsonbObject (JsonbValue * object );
105
105
static JsonbValue * pushJsonbValueScalar (JsonbParseState * * pstate ,
106
106
JsonbIteratorToken seq ,
107
- JsonbValue * scalarVal );
107
+ const JsonbValue * scalarVal );
108
108
static JsonbValue * pushSingleScalarJsonbValue (JsonbParseState * * pstate ,
109
- JsonbValue * jbval );
109
+ const JsonbValue * jbval );
110
110
111
111
/*
112
112
* Turn an in-memory JsonbValue into a Jsonb for on-disk storage.
@@ -418,7 +418,7 @@ findJsonbValueFromContainer(JsonbContainer *container, uint32 flags,
418
418
* 'res' can be passed in as NULL, in which case it's newly palloc'ed here.
419
419
*/
420
420
JsonbValue *
421
- getKeyJsonValueFromContainer (JsonbContainer * container ,
421
+ getKeyJsonValueFromContainer (const JsonbContainer * container ,
422
422
const char * keyVal , int keyLen , JsonbValue * res )
423
423
{
424
424
JEntry * children = container -> children ;
@@ -525,7 +525,7 @@ getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
525
525
* expanded.
526
526
*/
527
527
static void
528
- fillJsonbValue (JsonbContainer * container , int index ,
528
+ fillJsonbValue (const JsonbContainer * container , int index ,
529
529
char * base_addr , uint32 offset ,
530
530
JsonbValue * result )
531
531
{
@@ -613,7 +613,7 @@ JsonbParseStateClone(JsonbParseState *state)
613
613
*/
614
614
JsonbValue *
615
615
pushJsonbValue (JsonbParseState * * pstate , JsonbIteratorToken seq ,
616
- JsonbValue * jbval )
616
+ const JsonbValue * jbval )
617
617
{
618
618
JsonbIterator * it ;
619
619
JsonbValue * res = NULL ;
@@ -642,7 +642,7 @@ pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
642
642
*/
643
643
static JsonbValue *
644
644
pushJsonbValueScalar (JsonbParseState * * pstate , JsonbIteratorToken seq ,
645
- JsonbValue * scalarVal )
645
+ const JsonbValue * scalarVal )
646
646
{
647
647
JsonbValue * result = NULL ;
648
648
@@ -727,7 +727,7 @@ pushJsonbValueScalar(JsonbParseState **pstate, JsonbIteratorToken seq,
727
727
}
728
728
729
729
static JsonbValue *
730
- pushSingleScalarJsonbValue (JsonbParseState * * pstate , JsonbValue * jbval )
730
+ pushSingleScalarJsonbValue (JsonbParseState * * pstate , const JsonbValue * jbval )
731
731
{
732
732
/* single root scalar */
733
733
JsonbValue va ;
@@ -742,8 +742,8 @@ pushSingleScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval)
742
742
}
743
743
744
744
static JsonbValue *
745
- pushNestedScalarJsonbValue (JsonbParseState * * pstate , JsonbValue * jbval ,
746
- bool isKey )
745
+ pushNestedScalarJsonbValue (JsonbParseState * * pstate , const JsonbValue * jbval ,
746
+ bool isKey )
747
747
{
748
748
switch ((* pstate )-> contVal .type )
749
749
{
@@ -758,7 +758,8 @@ pushNestedScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval,
758
758
}
759
759
760
760
JsonbValue *
761
- pushScalarJsonbValue (JsonbParseState * * pstate , JsonbValue * jbval , bool isKey )
761
+ pushScalarJsonbValue (JsonbParseState * * pstate , const JsonbValue * jbval ,
762
+ bool isKey )
762
763
{
763
764
return * pstate == NULL
764
765
? pushSingleScalarJsonbValue (pstate , jbval )
@@ -782,7 +783,7 @@ pushState(JsonbParseState **pstate)
782
783
* pushJsonbValue() worker: Append a pair key to state when generating a Jsonb
783
784
*/
784
785
static void
785
- appendKey (JsonbParseState * pstate , JsonbValue * string )
786
+ appendKey (JsonbParseState * pstate , const JsonbValue * string )
786
787
{
787
788
JsonbValue * object = & pstate -> contVal ;
788
789
@@ -811,7 +812,7 @@ appendKey(JsonbParseState *pstate, JsonbValue *string)
811
812
* Jsonb
812
813
*/
813
814
static void
814
- appendValue (JsonbParseState * pstate , JsonbValue * scalarVal )
815
+ appendValue (JsonbParseState * pstate , const JsonbValue * scalarVal )
815
816
{
816
817
JsonbValue * object = & pstate -> contVal ;
817
818
@@ -824,7 +825,7 @@ appendValue(JsonbParseState *pstate, JsonbValue *scalarVal)
824
825
* pushJsonbValue() worker: Append an element to state when generating a Jsonb
825
826
*/
826
827
static void
827
- appendElement (JsonbParseState * pstate , JsonbValue * scalarVal )
828
+ appendElement (JsonbParseState * pstate , const JsonbValue * scalarVal )
828
829
{
829
830
JsonbValue * array = & pstate -> contVal ;
830
831
@@ -1437,7 +1438,7 @@ JsonbHashScalarValueExtended(const JsonbValue *scalarVal, uint64 *hash,
1437
1438
* Are two scalar JsonbValues of the same type a and b equal?
1438
1439
*/
1439
1440
static bool
1440
- equalsJsonbScalarValue (JsonbValue * aScalar , JsonbValue * bScalar )
1441
+ equalsJsonbScalarValue (const JsonbValue * aScalar , const JsonbValue * bScalar )
1441
1442
{
1442
1443
if (aScalar -> type == bScalar -> type )
1443
1444
{
@@ -1469,7 +1470,7 @@ equalsJsonbScalarValue(JsonbValue *aScalar, JsonbValue *bScalar)
1469
1470
* operators, where a lexical sort order is generally expected.
1470
1471
*/
1471
1472
static int
1472
- compareJsonbScalarValue (JsonbValue * aScalar , JsonbValue * bScalar )
1473
+ compareJsonbScalarValue (const JsonbValue * aScalar , const JsonbValue * bScalar )
1473
1474
{
1474
1475
if (aScalar -> type == bScalar -> type )
1475
1476
{
@@ -1584,7 +1585,7 @@ padBufferToInt(StringInfo buffer)
1584
1585
* Given a JsonbValue, convert to Jsonb. The result is palloc'd.
1585
1586
*/
1586
1587
static Jsonb *
1587
- convertToJsonb (JsonbValue * val )
1588
+ convertToJsonb (const JsonbValue * val )
1588
1589
{
1589
1590
StringInfoData buffer ;
1590
1591
JEntry jentry ;
@@ -1626,7 +1627,7 @@ convertToJsonb(JsonbValue *val)
1626
1627
* for debugging purposes.
1627
1628
*/
1628
1629
static void
1629
- convertJsonbValue (StringInfo buffer , JEntry * header , JsonbValue * val , int level )
1630
+ convertJsonbValue (StringInfo buffer , JEntry * header , const JsonbValue * val , int level )
1630
1631
{
1631
1632
check_stack_depth ();
1632
1633
@@ -1651,7 +1652,7 @@ convertJsonbValue(StringInfo buffer, JEntry *header, JsonbValue *val, int level)
1651
1652
}
1652
1653
1653
1654
static void
1654
- convertJsonbArray (StringInfo buffer , JEntry * pheader , JsonbValue * val , int level )
1655
+ convertJsonbArray (StringInfo buffer , JEntry * pheader , const JsonbValue * val , int level )
1655
1656
{
1656
1657
int base_offset ;
1657
1658
int jentry_offset ;
@@ -1735,7 +1736,7 @@ convertJsonbArray(StringInfo buffer, JEntry *pheader, JsonbValue *val, int level
1735
1736
}
1736
1737
1737
1738
static void
1738
- convertJsonbObject (StringInfo buffer , JEntry * pheader , JsonbValue * val , int level )
1739
+ convertJsonbObject (StringInfo buffer , JEntry * pheader , const JsonbValue * val , int level )
1739
1740
{
1740
1741
int base_offset ;
1741
1742
int jentry_offset ;
@@ -1851,7 +1852,7 @@ convertJsonbObject(StringInfo buffer, JEntry *pheader, JsonbValue *val, int leve
1851
1852
}
1852
1853
1853
1854
static void
1854
- convertJsonbScalar (StringInfo buffer , JEntry * jentry , JsonbValue * scalarVal )
1855
+ convertJsonbScalar (StringInfo buffer , JEntry * jentry , const JsonbValue * scalarVal )
1855
1856
{
1856
1857
int numlen ;
1857
1858
short padlen ;
0 commit comments