}
/*
- * Are two JsonbValues a and b equal?
+ * Are two scalar JsonbValues a and b equal?
*
* Does not use lexical comparisons. Therefore, it is essentially that this
* never be used for anything other than searching for values within a single
* this for sorting. This is just for "contains" style searching.
*/
bool
-compareJsonbValue(JsonbValue * a, JsonbValue * b)
+compareJsonbScalarValue(JsonbValue * a, JsonbValue * b)
{
- int i;
-
check_stack_depth();
if (a->type == b->type)
return DatumGetBool(DirectFunctionCall2(numeric_eq,
PointerGetDatum(a->numeric),
PointerGetDatum(b->numeric)));
- case jbvArray:
- if (a->array.nElems == b->array.nElems)
- {
- for (i = 0; i < a->array.nElems; i++)
- if (compareJsonbValue(a->array.elems + i,
- b->array.elems + i))
- return true;
- }
- break;
- case jbvObject:
- if (a->object.nPairs == b->object.nPairs)
- {
- for (i = 0; i < a->object.nPairs; i++)
- {
- if (lengthCompareJsonbStringValue(&a->object.pairs[i].key,
- &b->object.pairs[i].key,
- NULL) == 0)
- return true;
- if (compareJsonbValue(&a->object.pairs[i].value,
- &b->object.pairs[i].value))
- return true;
- }
- }
- break;
- case jbvBinary:
- /* This wastes a few cycles on unneeded lexical comparisons */
- return compareJsonbSuperHeaderValue(a->binary.data, b->binary.data) == 0;
default:
elog(ERROR, "invalid jsonb scalar type");
}
/* Support functions */
extern int compareJsonbSuperHeaderValue(JsonbSuperHeader a,
JsonbSuperHeader b);
-extern bool compareJsonbValue(JsonbValue *a, JsonbValue *b);
+extern bool compareJsonbScalarValue(JsonbValue *a, JsonbValue *b);
extern JsonbValue *findJsonbValueFromSuperHeaderLen(JsonbSuperHeader sheader,
uint32 flags,
uint32 *lowbound,