jsquery_extract.c
static int
compareJsQueryItem(JsQueryItem *v1, JsQueryItem *v2)
{
	char	*s1, *s2;
	int32	len1, len2, cmp;

	if (v1->type != v2->type)
		return (v1->type < v2->type) ? -1 : 1;

	switch(v1->type)
	{
		case jqiNull:
			return 0;
		case jqiString:
			s1 = jsqGetString(v1, &len1);
			s2 = jsqGetString(v2, &len2);
			cmp = memcmp(s1, s2, Min(len1, len2));
			if (cmp != 0 || len1 == len2)
				return cmp;
			return (len1 < len2) ? -1 : 1;
		case jqiBool:
			len1 = jsqGetBool(v1);
			len2 = jsqGetBool(v2);

			return (len1 - len2);
		case jqiNumeric:
			return DatumGetInt32(DirectFunctionCall2(numeric_cmp,
					 PointerGetDatum(jsqGetNumeric(v1)),
					 PointerGetDatum(jsqGetNumeric(v2))));
		default:
			elog(ERROR, "Wrong state");
	}

	return 0; /* make compiler happy */
}
/*
 * Compare json values represented by JsQueryItems.
 */
Compare json values represented by JsQueryItems.
Compare json values represented by JsQueryItems .
static int
compareJsQueryItem(JsQueryItem *v1, JsQueryItem *v2)
{
	char	*s1, *s2;
	int32	len1, len2, cmp;
	if (v1->type != v2->type)
		return (v1->type < v2->type) ? -1 : 1;
	switch(v1->type)
	{
		case jqiNull:
			return 0;
		case jqiString:
			s1 = jsqGetString(v1, &len1);
			s2 = jsqGetString(v2, &len2);
			cmp = memcmp(s1, s2, Min(len1, len2));
			if (cmp != 0 || len1 == len2)
				return cmp;
			return (len1 < len2) ? -1 : 1;
		case jqiBool:
			len1 = jsqGetBool(v1);
			len2 = jsqGetBool(v2);
			return (len1 - len2);
		case jqiNumeric:
			return DatumGetInt32(DirectFunctionCall2(numeric_cmp,
					 PointerGetDatum(jsqGetNumeric(v1)),
					 PointerGetDatum(jsqGetNumeric(v2))));
		default:
			elog(ERROR, "Wrong state");
	}
	return 0; 
}
static int compareJsQueryItem ( JsQueryItem * v1 , JsQueryItem * v2 ) { char * s1 , * s2 ; int32 len1 , len2 , cmp ; if ( v1 -> type != v2 -> type ) return ( v1 -> type < v2 -> type ) ? -1 : 1 ; switch ( v1 -> type ) { case jqiNull : return 0 ; case jqiString : s1 = jsqGetString ( v1 , & len1 ) ; s2 = jsqGetString ( v2 , & len2 ) ; cmp = memcmp ( s1 , s2 , Min ( len1 , len2 ) ) ; if ( cmp != 0 || len1 == len2 ) return cmp ; return ( len1 < len2 ) ? -1 : 1 ; case jqiBool : len1 = jsqGetBool ( v1 ) ; len2 = jsqGetBool ( v2 ) ; return ( len1 - len2 ) ; case jqiNumeric : return DatumGetInt32 ( DirectFunctionCall2 ( numeric_cmp , PointerGetDatum ( jsqGetNumeric ( v1 ) ) , PointerGetDatum ( jsqGetNumeric ( v2 ) ) ) ) ; default : elog ( ERROR , " " ) ; } return 0 ; }
Compare json values represented by JsQueryItems.
Compare json values represented by JsQueryItems .
/* make compiler happy */