Relocate some support functions
authorPeter Geoghegan <[email protected]>
Wed, 12 Mar 2014 05:17:46 +0000 (22:17 -0700)
committerPeter Geoghegan <[email protected]>
Wed, 12 Mar 2014 05:17:46 +0000 (22:17 -0700)
src/backend/utils/adt/jsonb_support.c

index 3040ea7e522b4f7cb0506320a98f19bf028d3345..e0d2d0bdd142bd3f613b55216f4030e4de3d57c4 100644 (file)
@@ -279,6 +279,29 @@ compareJsonbBinaryValue(char *a, char *b)
    return res;
 }
 
+/*
+ * findUncompressedJsonbValueByValue() wrapper that sets up JsonbValue key.
+ */
+JsonbValue *
+findUncompressedJsonbValue(char *buffer, uint32 flags, uint32 *lowbound,
+                          char *key, uint32 keylen)
+{
+   JsonbValue  v;
+
+   if (key == NULL)
+   {
+       v.type = jbvNull;
+   }
+   else
+   {
+       v.type = jbvString;
+       v.string.val = key;
+       v.string.len = keylen;
+   }
+
+   return findUncompressedJsonbValueByValue(buffer, flags, lowbound, &v);
+}
+
 /*
  * Find string key in object or element by value in array (packed format)
  */
@@ -450,29 +473,6 @@ findUncompressedJsonbValueByValue(char *buffer, uint32 flags,
    return NULL;
 }
 
-/*
- * findUncompressedJsonbValueByValue() wrapper that sets up JsonbValue key.
- */
-JsonbValue *
-findUncompressedJsonbValue(char *buffer, uint32 flags, uint32 *lowbound,
-                          char *key, uint32 keylen)
-{
-   JsonbValue  v;
-
-   if (key == NULL)
-   {
-       v.type = jbvNull;
-   }
-   else
-   {
-       v.type = jbvString;
-       v.string.val = key;
-       v.string.len = keylen;
-   }
-
-   return findUncompressedJsonbValueByValue(buffer, flags, lowbound, &v);
-}
-
 /*
  * Get i-th value of array or object.  If i < 0, then it counts from the end of
  * array/object. Note: returns pointer to statically allocated JsonbValue.
@@ -679,7 +679,6 @@ JsonbIteratorNext(JsonbIterator ** it, JsonbValue * v, bool skipNested)
    if (*it == NULL)
        return 0;
 
-
    /*
     * Encode all possible states in the "type" integer.  This is possible
     * because enum members of JsonbIterator->state use different bit values
@@ -977,8 +976,8 @@ up(JsonbIterator * it)
 /*
  * Transformation from tree to binary representation of jsonb
  */
-#define curLevelState  state->lptr
-#define prevLevelState state->pptr
+#define curLevelState  (state->lptr)
+#define prevLevelState (state->pptr)
 
 static void
 compressJsonbValue(CompressState * state, JsonbValue * value, uint32 flags,