Datum
jsonb_exists_all(PG_FUNCTION_ARGS)
{
- Jsonb *js = PG_GETARG_JSONB(0);
- ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1);
- JsonbValue *v = arrayToJsonbSortedArray(keys);
+ Jsonb *js = PG_GETARG_JSONB(0);
+ ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1);
+ JsonbValue *v = arrayToJsonbSortedArray(keys);
+ uint32 *plowbound = NULL;
+ uint32 lowbound = 0;
+ bool res = true;
int i;
- uint32 *plowbound = NULL, lowbound = 0;
- bool res = false;
if (JB_ISEMPTY(js) || v == NULL || v->array.nelems == 0)
{
plowbound = &lowbound;
/*
- * we exploit the fact that the pairs list is already sorted into strictly
+ * We exploit the fact that the pairs list is already sorted into strictly
* increasing order to narrow the findUncompressedJsonbValue search; each
* search can start one entry past the previous "found" entry, or at the
* lower bound of the last search.
if (findUncompressedJsonbValueByValue(VARDATA(js),
JB_FLAG_OBJECT | JB_FLAG_ARRAY,
plowbound,
- v->array.elems + i) != NULL)
+ v->array.elems + i) == NULL)
{
- res = true;
+ res = false;
break;
}
}
return res;
}
-/****************************************************************************
- * find string key in object or element by value in array *
- ****************************************************************************/
+/*
+ * Find string key in object or element by value in array
+ */
JsonbValue *
findUncompressedJsonbValueByValue(char *buffer, uint32 flags,
uint32 *lowbound, JsonbValue *key)
{
- uint32 header = *(uint32 *) buffer;
- static JsonbValue r;
+ uint32 header = *(uint32 *) buffer;
+ static JsonbValue r;
Assert((header & (JB_FLAG_ARRAY | JB_FLAG_OBJECT)) !=
(JB_FLAG_ARRAY | JB_FLAG_OBJECT));