Formalize enum value assert pattern
authorPeter Geoghegan <[email protected]>
Wed, 12 Mar 2014 05:11:00 +0000 (22:11 -0700)
committerPeter Geoghegan <[email protected]>
Wed, 12 Mar 2014 05:11:00 +0000 (22:11 -0700)
src/backend/utils/adt/jsonb_op.c
src/backend/utils/adt/jsonb_support.c
src/include/utils/jsonb.h

index 3ba57f4f9d0d39fafcdc46b43e6a0ae1d8b0f1e4..b7ab4ec827684a67101ffe75e07ef92f62decb12 100644 (file)
@@ -380,8 +380,7 @@ deepContains(JsonbIterator ** it1, JsonbIterator ** it2)
                res = false;
                break;
            }
-           else if (v->type == jbvString || v->type == jbvNull ||
-                    v->type == jbvBool || v->type == jbvNumeric)
+           else if (v->type >= jbvNull && v->type < jbvArray)
            {
                if (!compareJsonbValue(v, &v2))
                {
index 15cf7611d4b4dfbe47d5ef0dcb4a9466d7789c7f..3040ea7e522b4f7cb0506320a98f19bf028d3345 100644 (file)
@@ -599,11 +599,11 @@ pushJsonbValue(ToJsonbState ** state, int r, JsonbValue * v)
            appendKey(*state, v);
            break;
        case WJB_VALUE:
-           Assert((v->type >= jbvNull && v->type <= jbvBool) || v->type == jbvBinary);
+           Assert((v->type >= jbvNull && v->type < jbvArray) || v->type == jbvBinary);
            appendValue(*state, v);
            break;
        case WJB_ELEM:
-           Assert((v->type >= jbvNull && v->type <= jbvBool) || v->type == jbvBinary);
+           Assert((v->type >= jbvNull && v->type < jbvArray) || v->type == jbvBinary);
            appendElement(*state, v);
            break;
        case WJB_END_OBJECT:
index 7ff9cc92ddea41be53a13dab72bab4d65269957b..87e50a40b070873807578027b50b6a6bf34e07c8 100644 (file)
@@ -104,7 +104,7 @@ struct JsonbValue
        jbvNumeric,
        jbvBool,
        /* Composite types */
-       jbvArray,
+       jbvArray = 4,
        jbvObject,
        /* Binary form of jbvArray/jbvObject */
        jbvBinary