@@ -51,11 +51,11 @@ struct JsonbParseState
51
51
struct JsonbIterator
52
52
{
53
53
/* Container being iterated */
54
- JsonbContainer * container ;
54
+ const JsonbContainer * container ;
55
55
uint32 nElems ; /* Number of elements in children array (will
56
56
* be nPairs for objects) */
57
57
bool isScalar ; /* Pseudo-array scalar value? */
58
- JEntry * children ; /* JEntrys for child nodes */
58
+ const JEntry * children ; /* JEntrys for child nodes */
59
59
/* Data proper. This points to the beginning of the variable-length data */
60
60
char * dataProper ;
61
61
@@ -78,16 +78,16 @@ struct JsonbIterator
78
78
struct JsonbIterator * parent ;
79
79
};
80
80
81
- static void fillJsonbValue (JsonbContainer * container , int index ,
81
+ static void fillJsonbValue (const JsonbContainer * container , int index ,
82
82
char * base_addr , uint32 offset ,
83
83
JsonbValue * result );
84
- static bool equalsJsonbScalarValue (JsonbValue * a , JsonbValue * b );
85
- static int compareJsonbScalarValue (JsonbValue * a , JsonbValue * b );
86
- static Jsonb * convertToJsonb (JsonbValue * val );
87
- static void convertJsonbValue (StringInfo buffer , JEntry * header , JsonbValue * val , int level );
88
- static void convertJsonbArray (StringInfo buffer , JEntry * header , JsonbValue * val , int level );
89
- static void convertJsonbObject (StringInfo buffer , JEntry * header , JsonbValue * val , int level );
90
- static void convertJsonbScalar (StringInfo buffer , JEntry * header , JsonbValue * scalarVal );
84
+ static bool equalsJsonbScalarValue (const JsonbValue * a , const JsonbValue * b );
85
+ static int compareJsonbScalarValue (const JsonbValue * a , const JsonbValue * b );
86
+ static Jsonb * convertToJsonb (const JsonbValue * val );
87
+ static void convertJsonbValue (StringInfo buffer , JEntry * header , const JsonbValue * val , int level );
88
+ static void convertJsonbArray (StringInfo buffer , JEntry * header , const JsonbValue * val , int level );
89
+ static void convertJsonbObject (StringInfo buffer , JEntry * header , const JsonbValue * val , int level );
90
+ static void convertJsonbScalar (StringInfo buffer , JEntry * header , const JsonbValue * scalarVal );
91
91
92
92
static int reserveFromBuffer (StringInfo buffer , int len );
93
93
static void appendToBuffer (StringInfo buffer , const char * data , int len );
@@ -97,9 +97,9 @@ static short padBufferToInt(StringInfo buffer);
97
97
static JsonbIterator * iteratorFromContainer (JsonbContainer * container , JsonbIterator * parent );
98
98
static JsonbIterator * freeAndGetParent (JsonbIterator * it );
99
99
static JsonbParseState * pushState (JsonbParseState * * pstate );
100
- static void appendKey (JsonbParseState * pstate , JsonbValue * scalarVal );
101
- static void appendValue (JsonbParseState * pstate , JsonbValue * scalarVal );
102
- static void appendElement (JsonbParseState * pstate , JsonbValue * scalarVal );
100
+ static void appendKey (JsonbParseState * pstate , const JsonbValue * scalarVal );
101
+ static void appendValue (JsonbParseState * pstate , const JsonbValue * scalarVal );
102
+ static void appendElement (JsonbParseState * pstate , const JsonbValue * scalarVal );
103
103
static int lengthCompareJsonbStringValue (const void * a , const void * b );
104
104
static int lengthCompareJsonbString (const char * val1 , int len1 ,
105
105
const char * val2 , int len2 );
@@ -108,9 +108,9 @@ static void uniqueifyJsonbObject(JsonbValue *object, bool unique_keys,
108
108
bool skip_nulls );
109
109
static JsonbValue * pushJsonbValueScalar (JsonbParseState * * pstate ,
110
110
JsonbIteratorToken seq ,
111
- JsonbValue * scalarVal );
111
+ const JsonbValue * scalarVal );
112
112
static JsonbValue * pushSingleScalarJsonbValue (JsonbParseState * * pstate ,
113
- JsonbValue * jbval );
113
+ const JsonbValue * jbval );
114
114
115
115
void
116
116
JsonbToJsonbValue (Jsonb * jsonb , JsonbValue * val )
@@ -375,10 +375,10 @@ compareJsonbContainers(JsonbContainer *a, JsonbContainer *b)
375
375
* return NULL. Otherwise, return palloc()'d copy of value.
376
376
*/
377
377
JsonbValue *
378
- findJsonbValueFromContainer (JsonbContainer * container , uint32 flags ,
378
+ findJsonbValueFromContainer (const JsonbContainer * container , uint32 flags ,
379
379
JsonbValue * key )
380
380
{
381
- JEntry * children = container -> children ;
381
+ const JEntry * children = container -> children ;
382
382
int count = JsonContainerSize (container );
383
383
384
384
Assert ((flags & ~(JB_FARRAY | JB_FOBJECT )) == 0 );
@@ -429,10 +429,10 @@ findJsonbValueFromContainer(JsonbContainer *container, uint32 flags,
429
429
* 'res' can be passed in as NULL, in which case it's newly palloc'ed here.
430
430
*/
431
431
JsonbValue *
432
- getKeyJsonValueFromContainer (JsonbContainer * container ,
432
+ getKeyJsonValueFromContainer (const JsonbContainer * container ,
433
433
const char * keyVal , int keyLen , JsonbValue * res )
434
434
{
435
- JEntry * children = container -> children ;
435
+ const JEntry * children = container -> children ;
436
436
int count = JsonContainerSize (container );
437
437
char * baseAddr ;
438
438
uint32 stopLow ,
@@ -536,7 +536,7 @@ getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
536
536
* expanded.
537
537
*/
538
538
static void
539
- fillJsonbValue (JsonbContainer * container , int index ,
539
+ fillJsonbValue (const JsonbContainer * container , int index ,
540
540
char * base_addr , uint32 offset ,
541
541
JsonbValue * result )
542
542
{
@@ -638,7 +638,7 @@ JsonbParseStateSetSkipNulls(JsonbParseState *state, bool skip_nulls)
638
638
*/
639
639
JsonbValue *
640
640
pushJsonbValue (JsonbParseState * * pstate , JsonbIteratorToken seq ,
641
- JsonbValue * jbval )
641
+ const JsonbValue * jbval )
642
642
{
643
643
JsonbIterator * it ;
644
644
JsonbValue * res = NULL ;
@@ -712,7 +712,7 @@ pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
712
712
*/
713
713
static JsonbValue *
714
714
pushJsonbValueScalar (JsonbParseState * * pstate , JsonbIteratorToken seq ,
715
- JsonbValue * scalarVal )
715
+ const JsonbValue * scalarVal )
716
716
{
717
717
JsonbValue * result = NULL ;
718
718
@@ -799,7 +799,7 @@ pushJsonbValueScalar(JsonbParseState **pstate, JsonbIteratorToken seq,
799
799
}
800
800
801
801
static JsonbValue *
802
- pushSingleScalarJsonbValue (JsonbParseState * * pstate , JsonbValue * jbval )
802
+ pushSingleScalarJsonbValue (JsonbParseState * * pstate , const JsonbValue * jbval )
803
803
{
804
804
/* single root scalar */
805
805
JsonbValue va ;
@@ -814,7 +814,7 @@ pushSingleScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval)
814
814
}
815
815
816
816
static JsonbValue *
817
- pushNestedScalarJsonbValue (JsonbParseState * * pstate , JsonbValue * jbval ,
817
+ pushNestedScalarJsonbValue (JsonbParseState * * pstate , const JsonbValue * jbval ,
818
818
bool isKey )
819
819
{
820
820
switch ((* pstate )-> contVal .type )
@@ -830,7 +830,8 @@ pushNestedScalarJsonbValue(JsonbParseState **pstate, JsonbValue *jbval,
830
830
}
831
831
832
832
JsonbValue *
833
- pushScalarJsonbValue (JsonbParseState * * pstate , JsonbValue * jbval , bool isKey )
833
+ pushScalarJsonbValue (JsonbParseState * * pstate , const JsonbValue * jbval ,
834
+ bool isKey )
834
835
{
835
836
return * pstate == NULL
836
837
? pushSingleScalarJsonbValue (pstate , jbval )
@@ -857,7 +858,7 @@ pushState(JsonbParseState **pstate)
857
858
* pushJsonbValue() worker: Append a pair key to state when generating a Jsonb
858
859
*/
859
860
static void
860
- appendKey (JsonbParseState * pstate , JsonbValue * string )
861
+ appendKey (JsonbParseState * pstate , const JsonbValue * string )
861
862
{
862
863
JsonbValue * object = & pstate -> contVal ;
863
864
@@ -886,7 +887,7 @@ appendKey(JsonbParseState *pstate, JsonbValue *string)
886
887
* Jsonb
887
888
*/
888
889
static void
889
- appendValue (JsonbParseState * pstate , JsonbValue * scalarVal )
890
+ appendValue (JsonbParseState * pstate , const JsonbValue * scalarVal )
890
891
{
891
892
JsonbValue * object = & pstate -> contVal ;
892
893
@@ -899,7 +900,7 @@ appendValue(JsonbParseState *pstate, JsonbValue *scalarVal)
899
900
* pushJsonbValue() worker: Append an element to state when generating a Jsonb
900
901
*/
901
902
static void
902
- appendElement (JsonbParseState * pstate , JsonbValue * scalarVal )
903
+ appendElement (JsonbParseState * pstate , const JsonbValue * scalarVal )
903
904
{
904
905
JsonbValue * array = & pstate -> contVal ;
905
906
@@ -1512,7 +1513,7 @@ JsonbHashScalarValueExtended(const JsonbValue *scalarVal, uint64 *hash,
1512
1513
* Are two scalar JsonbValues of the same type a and b equal?
1513
1514
*/
1514
1515
static bool
1515
- equalsJsonbScalarValue (JsonbValue * aScalar , JsonbValue * bScalar )
1516
+ equalsJsonbScalarValue (const JsonbValue * aScalar , const JsonbValue * bScalar )
1516
1517
{
1517
1518
if (aScalar -> type == bScalar -> type )
1518
1519
{
@@ -1544,7 +1545,7 @@ equalsJsonbScalarValue(JsonbValue *aScalar, JsonbValue *bScalar)
1544
1545
* operators, where a lexical sort order is generally expected.
1545
1546
*/
1546
1547
static int
1547
- compareJsonbScalarValue (JsonbValue * aScalar , JsonbValue * bScalar )
1548
+ compareJsonbScalarValue (const JsonbValue * aScalar , const JsonbValue * bScalar )
1548
1549
{
1549
1550
if (aScalar -> type == bScalar -> type )
1550
1551
{
@@ -1659,7 +1660,7 @@ padBufferToInt(StringInfo buffer)
1659
1660
* Given a JsonbValue, convert to Jsonb. The result is palloc'd.
1660
1661
*/
1661
1662
static Jsonb *
1662
- convertToJsonb (JsonbValue * val )
1663
+ convertToJsonb (const JsonbValue * val )
1663
1664
{
1664
1665
StringInfoData buffer ;
1665
1666
JEntry jentry ;
@@ -1701,7 +1702,7 @@ convertToJsonb(JsonbValue *val)
1701
1702
* for debugging purposes.
1702
1703
*/
1703
1704
static void
1704
- convertJsonbValue (StringInfo buffer , JEntry * header , JsonbValue * val , int level )
1705
+ convertJsonbValue (StringInfo buffer , JEntry * header , const JsonbValue * val , int level )
1705
1706
{
1706
1707
check_stack_depth ();
1707
1708
@@ -1726,7 +1727,7 @@ convertJsonbValue(StringInfo buffer, JEntry *header, JsonbValue *val, int level)
1726
1727
}
1727
1728
1728
1729
static void
1729
- convertJsonbArray (StringInfo buffer , JEntry * pheader , JsonbValue * val , int level )
1730
+ convertJsonbArray (StringInfo buffer , JEntry * pheader , const JsonbValue * val , int level )
1730
1731
{
1731
1732
int base_offset ;
1732
1733
int jentry_offset ;
@@ -1810,7 +1811,7 @@ convertJsonbArray(StringInfo buffer, JEntry *pheader, JsonbValue *val, int level
1810
1811
}
1811
1812
1812
1813
static void
1813
- convertJsonbObject (StringInfo buffer , JEntry * pheader , JsonbValue * val , int level )
1814
+ convertJsonbObject (StringInfo buffer , JEntry * pheader , const JsonbValue * val , int level )
1814
1815
{
1815
1816
int base_offset ;
1816
1817
int jentry_offset ;
@@ -1926,7 +1927,7 @@ convertJsonbObject(StringInfo buffer, JEntry *pheader, JsonbValue *val, int leve
1926
1927
}
1927
1928
1928
1929
static void
1929
- convertJsonbScalar (StringInfo buffer , JEntry * jentry , JsonbValue * scalarVal )
1930
+ convertJsonbScalar (StringInfo buffer , JEntry * jentry , const JsonbValue * scalarVal )
1930
1931
{
1931
1932
int numlen ;
1932
1933
short padlen ;
0 commit comments