Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Use JsonbIteratorToken consistently in automatic variable declarations.
authorNoah Misch <noah@leadboat.com>
Mon, 12 Oct 2015 03:53:35 +0000 (23:53 -0400)
committerNoah Misch <noah@leadboat.com>
Mon, 12 Oct 2015 14:12:44 +0000 (10:12 -0400)
Many functions stored JsonbIteratorToken values in variables of other
integer types.  Also, standardize order relative to other declarations.
Expect compilers to generate the same code before and after this change.

src/backend/utils/adt/jsonb.c
src/backend/utils/adt/jsonb_gin.c
src/backend/utils/adt/jsonb_op.c
src/backend/utils/adt/jsonb_util.c
src/backend/utils/adt/jsonfuncs.c

index 1d65b251895c372e164f86ce763fb81a4539d20d..b8a3772573810134ecd3186c6e0fc84352d9e5de 100644 (file)
@@ -372,8 +372,8 @@ JsonbToCString(StringInfo out, JsonbContainer *in, int estimated_len)
 {
    bool        first = true;
    JsonbIterator *it;
-   JsonbIteratorToken type = WJB_DONE;
    JsonbValue  v;
+   JsonbIteratorToken type = WJB_DONE;
    int         level = 0;
    bool        redo_switch = false;
 
index 069ee03080308c28425021a948f201d40d144ef4..86dbfdb4f23bfd4fcbd3a873096952121b095795 100644 (file)
@@ -70,8 +70,8 @@ gin_extract_jsonb(PG_FUNCTION_ARGS)
    int         total = 2 * JB_ROOT_COUNT(jb);
    JsonbIterator *it;
    JsonbValue  v;
-   int         i = 0,
-               r;
+   JsonbIteratorToken r;
+   int         i = 0;
    Datum      *entries;
 
    /* If the root level is empty, we certainly have no keys */
@@ -333,10 +333,10 @@ gin_extract_jsonb_path(PG_FUNCTION_ARGS)
    int         total = 2 * JB_ROOT_COUNT(jb);
    JsonbIterator *it;
    JsonbValue  v;
+   JsonbIteratorToken r;
    PathHashStack tail;
    PathHashStack *stack;
-   int         i = 0,
-               r;
+   int         i = 0;
    Datum      *entries;
 
    /* If the root level is empty, we certainly have no keys */
@@ -429,7 +429,7 @@ gin_extract_jsonb_path(PG_FUNCTION_ARGS)
                stack = parent;
                break;
            default:
-               elog(ERROR, "invalid JsonbIteratorNext rc: %d", r);
+               elog(ERROR, "invalid JsonbIteratorNext rc: %d", (int) r);
        }
    }
 
index d9aaac9ac2791f4b61f01bbe0aab52f22b14a7a0..17a4d271ec15cf64efe7439fe737e0fc6b915e29 100644 (file)
@@ -254,8 +254,8 @@ jsonb_hash(PG_FUNCTION_ARGS)
 {
    Jsonb      *jb = PG_GETARG_JSONB(0);
    JsonbIterator *it;
-   int32       r;
    JsonbValue  v;
+   JsonbIteratorToken r;
    uint32      hash = 0;
 
    if (JB_ROOT_COUNT(jb) == 0)
@@ -283,7 +283,7 @@ jsonb_hash(PG_FUNCTION_ARGS)
            case WJB_END_OBJECT:
                break;
            default:
-               elog(ERROR, "invalid JsonbIteratorNext rc: %d", r);
+               elog(ERROR, "invalid JsonbIteratorNext rc: %d", (int) r);
        }
    }
 
index e94c4ccb0bb7ea6d6e07a0d3de062c7c22704f96..0b526cb72686dd4bcc61521b884d85ebee4fb13b 100644 (file)
@@ -187,7 +187,7 @@ compareJsonbContainers(JsonbContainer *a, JsonbContainer *b)
    {
        JsonbValue  va,
                    vb;
-       int         ra,
+       JsonbIteratorToken ra,
                    rb;
 
        ra = JsonbIteratorNext(&ita, &va, false);
@@ -961,10 +961,10 @@ freeAndGetParent(JsonbIterator *it)
 bool
 JsonbDeepContains(JsonbIterator **val, JsonbIterator **mContained)
 {
-   uint32      rval,
-               rcont;
    JsonbValue  vval,
                vcontained;
+   JsonbIteratorToken rval,
+               rcont;
 
    /*
     * Guard against stack overflow due to overly complex Jsonb.
index 1a9a060d4eb1482c792d78dc074b4d1eb3a63656..b49a5dd61e4f6e9a6e2accad6c70c1b44aef0586 100644 (file)
@@ -255,7 +255,7 @@ jsonb_object_keys(PG_FUNCTION_ARGS)
        bool        skipNested = false;
        JsonbIterator *it;
        JsonbValue  v;
-       int         r;
+       JsonbIteratorToken r;
 
        if (JB_ROOT_IS_SCALAR(jb))
            ereport(ERROR,
@@ -1195,7 +1195,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
        if (jbvp->type == jbvBinary)
        {
            JsonbIterator *it = JsonbIteratorInit((JsonbContainer *) jbvp->val.binary.data);
-           int         r;
+           JsonbIteratorToken r;
 
            r = JsonbIteratorNext(&it, &tv, true);
            container = (JsonbContainer *) jbvp->val.binary.data;
@@ -1368,7 +1368,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
    bool        skipNested = false;
    JsonbIterator *it;
    JsonbValue  v;
-   int         r;
+   JsonbIteratorToken r;
 
    if (!JB_ROOT_IS_OBJECT(jb))
        ereport(ERROR,
@@ -1687,7 +1687,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname,
    bool        skipNested = false;
    JsonbIterator *it;
    JsonbValue  v;
-   int         r;
+   JsonbIteratorToken r;
 
    if (JB_ROOT_IS_SCALAR(jb))
        ereport(ERROR,
@@ -2704,7 +2704,7 @@ populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname,
        JsonbIterator *it;
        JsonbValue  v;
        bool        skipNested = false;
-       int         r;
+       JsonbIteratorToken r;
 
        Assert(jtype == JSONBOID);