}
/*
- * Get i-th value of array or object.
+ * Get i-th value of Jsonb array from superheader.
*
- * Returns palloc()'d copy of value, or NULL if it cannot be found. "flags"
- * allows caller to specify which container types are of interest.
+ * Returns palloc()'d copy of value, or NULL if it cannot be found.
+ *
+ * This only works with Jsonb arrays, and
*/
JsonbValue *
-getIthJsonbValueFromSuperHeader(JsonbSuperHeader sheader, uint32 flags,
- uint32 i)
+getIthJsonbValueFromSuperHeader(JsonbSuperHeader sheader, uint32 i)
{
uint32 superheader = *(uint32 *) sheader;
JsonbValue *r;
*e;
char *data;
- Assert((flags & ~(JB_FARRAY | JB_FOBJECT)) == 0);
-
r = palloc(sizeof(JsonbValue));
if (i >= (superheader & JB_CMASK))
array = (JEntry *) (sheader + sizeof(uint32));
- if (flags & JB_FARRAY & superheader)
+ if (superheader & JB_FARRAY)
{
e = array + i;
data = (char *) (array + (superheader & JB_CMASK));
}
- else if (flags & JB_FOBJECT & superheader)
- {
- e = array + i * 2 + 1;
- data = (char *) (array + (superheader & JB_CMASK) * 2);
- }
else
{
- return NULL;
+ elog(ERROR, "not a jsonb array");
}
if (JBE_ISSTRING(*e))
uint32 *lowbound,
JsonbValue *key);
extern JsonbValue *getIthJsonbValueFromSuperHeader(JsonbSuperHeader sheader,
- uint32 flags, uint32 i);
+ uint32 i);
extern JsonbValue *pushJsonbValue(ToJsonbState ** state, int r, JsonbValue *v);
extern JsonbIterator *JsonbIteratorInit(JsonbSuperHeader buffer);
extern int JsonbIteratorNext(JsonbIterator **it, JsonbValue *v,