{
text *json = DatumGetTextP(js);
- if (pred->value_type == JS_TYPE_ANY)
+ if (pred->item_type == JS_TYPE_ANY)
res = true;
else
{
switch (json_get_first_token(json, false))
{
case JSON_TOKEN_OBJECT_START:
- res = pred->value_type == JS_TYPE_OBJECT;
+ res = pred->item_type == JS_TYPE_OBJECT;
break;
case JSON_TOKEN_ARRAY_START:
- res = pred->value_type == JS_TYPE_ARRAY;
+ res = pred->item_type == JS_TYPE_ARRAY;
break;
case JSON_TOKEN_STRING:
case JSON_TOKEN_NUMBER:
case JSON_TOKEN_TRUE:
case JSON_TOKEN_FALSE:
case JSON_TOKEN_NULL:
- res = pred->value_type == JS_TYPE_SCALAR;
+ res = pred->item_type == JS_TYPE_SCALAR;
break;
default:
res = false;
}
else if (exprtype == JSONBOID)
{
- if (pred->value_type == JS_TYPE_ANY)
+ if (pred->item_type == JS_TYPE_ANY)
res = true;
else
{
Jsonb *jb = DatumGetJsonbP(js);
- switch (pred->value_type)
+ switch (pred->item_type)
{
case JS_TYPE_OBJECT:
res = JB_ROOT_IS_OBJECT(jb);
COPY_NODE_FIELD(result_coercion);
COPY_NODE_FIELD(format);
COPY_NODE_FIELD(path_spec);
- COPY_NODE_FIELD(passing_values);
COPY_NODE_FIELD(passing_names);
+ COPY_NODE_FIELD(passing_values);
COPY_NODE_FIELD(returning);
- COPY_NODE_FIELD(on_error);
COPY_NODE_FIELD(on_empty);
+ COPY_NODE_FIELD(on_error);
COPY_NODE_FIELD(coercions);
COPY_SCALAR_FIELD(wrapper);
COPY_SCALAR_FIELD(omit_quotes);
JsonIsPredicate *newnode = makeNode(JsonIsPredicate);
COPY_NODE_FIELD(expr);
- COPY_SCALAR_FIELD(format);
- COPY_SCALAR_FIELD(value_type);
+ COPY_NODE_FIELD(format);
+ COPY_SCALAR_FIELD(item_type);
COPY_SCALAR_FIELD(unique_keys);
COPY_LOCATION_FIELD(location);
COPY_SCALAR_FIELD(outerJoin);
COPY_SCALAR_FIELD(colMin);
COPY_SCALAR_FIELD(colMax);
+ COPY_SCALAR_FIELD(errorOnError);
return newnode;
}
COMPARE_SCALAR_FIELD(outerJoin);
COMPARE_SCALAR_FIELD(colMin);
COMPARE_SCALAR_FIELD(colMax);
+ COMPARE_SCALAR_FIELD(errorOnError);
return true;
}
const JsonIsPredicate *b)
{
COMPARE_NODE_FIELD(expr);
- COMPARE_SCALAR_FIELD(value_type);
+ COMPARE_NODE_FIELD(format);
+ COMPARE_SCALAR_FIELD(item_type);
COMPARE_SCALAR_FIELD(unique_keys);
COMPARE_LOCATION_FIELD(location);
COMPARE_NODE_FIELD(result_coercion);
COMPARE_NODE_FIELD(format);
COMPARE_NODE_FIELD(path_spec);
- COMPARE_NODE_FIELD(passing_values);
COMPARE_NODE_FIELD(passing_names);
+ COMPARE_NODE_FIELD(passing_values);
COMPARE_NODE_FIELD(returning);
- COMPARE_NODE_FIELD(on_error);
COMPARE_NODE_FIELD(on_empty);
+ COMPARE_NODE_FIELD(on_error);
COMPARE_NODE_FIELD(coercions);
COMPARE_SCALAR_FIELD(wrapper);
COMPARE_SCALAR_FIELD(omit_quotes);
* creates a JsonIsPredicate node
*/
Node *
-makeJsonIsPredicate(Node *expr, JsonFormat *format, JsonValueType value_type,
+makeJsonIsPredicate(Node *expr, JsonFormat *format, JsonValueType item_type,
bool unique_keys, int location)
{
JsonIsPredicate *n = makeNode(JsonIsPredicate);
n->expr = expr;
n->format = format;
- n->value_type = value_type;
+ n->item_type = item_type;
n->unique_keys = unique_keys;
n->location = location;
{
WRITE_NODE_TYPE("JSONCONSTRUCTOREXPR");
+ WRITE_ENUM_FIELD(type, JsonConstructorType);
WRITE_NODE_FIELD(args);
WRITE_NODE_FIELD(func);
WRITE_NODE_FIELD(coercion);
- WRITE_ENUM_FIELD(type, JsonConstructorType);
WRITE_NODE_FIELD(returning);
- WRITE_BOOL_FIELD(unique);
WRITE_BOOL_FIELD(absent_on_null);
+ WRITE_BOOL_FIELD(unique);
WRITE_LOCATION_FIELD(location);
}
WRITE_NODE_TYPE("JSONISPREDICATE");
WRITE_NODE_FIELD(expr);
- WRITE_ENUM_FIELD(value_type, JsonValueType);
+ WRITE_NODE_FIELD(format);
+ WRITE_ENUM_FIELD(item_type, JsonValueType);
WRITE_BOOL_FIELD(unique_keys);
WRITE_LOCATION_FIELD(location);
}
WRITE_NODE_FIELD(result_coercion);
WRITE_NODE_FIELD(format);
WRITE_NODE_FIELD(path_spec);
- WRITE_NODE_FIELD(passing_values);
WRITE_NODE_FIELD(passing_names);
+ WRITE_NODE_FIELD(passing_values);
WRITE_NODE_FIELD(returning);
- WRITE_NODE_FIELD(on_error);
WRITE_NODE_FIELD(on_empty);
+ WRITE_NODE_FIELD(on_error);
WRITE_NODE_FIELD(coercions);
WRITE_ENUM_FIELD(wrapper, JsonWrapper);
WRITE_BOOL_FIELD(omit_quotes);
static void
_outJsonTableParent(StringInfo str, const JsonTableParent *node)
{
- WRITE_NODE_TYPE("JSONTABPNODE");
+ WRITE_NODE_TYPE("JSONTABLEPARENT");
WRITE_NODE_FIELD(path);
WRITE_STRING_FIELD(name);
WRITE_BOOL_FIELD(outerJoin);
WRITE_INT_FIELD(colMin);
WRITE_INT_FIELD(colMax);
+ WRITE_BOOL_FIELD(errorOnError);
}
static void
_outJsonTableSibling(StringInfo str, const JsonTableSibling *node)
{
- WRITE_NODE_TYPE("JSONTABSNODE");
+ WRITE_NODE_TYPE("JSONTABLESIBLING");
WRITE_NODE_FIELD(larg);
WRITE_NODE_FIELD(rarg);
{
READ_LOCALS(JsonConstructorExpr);
+ READ_ENUM_FIELD(type, JsonConstructorType);
READ_NODE_FIELD(args);
READ_NODE_FIELD(func);
READ_NODE_FIELD(coercion);
- READ_INT_FIELD(type);
READ_NODE_FIELD(returning);
- READ_BOOL_FIELD(unique);
READ_BOOL_FIELD(absent_on_null);
+ READ_BOOL_FIELD(unique);
READ_LOCATION_FIELD(location);
READ_DONE();
READ_NODE_FIELD(result_coercion);
READ_NODE_FIELD(format);
READ_NODE_FIELD(path_spec);
- READ_NODE_FIELD(passing_values);
READ_NODE_FIELD(passing_names);
+ READ_NODE_FIELD(passing_values);
READ_NODE_FIELD(returning);
- READ_NODE_FIELD(on_error);
READ_NODE_FIELD(on_empty);
+ READ_NODE_FIELD(on_error);
READ_NODE_FIELD(coercions);
READ_ENUM_FIELD(wrapper, JsonWrapper);
READ_BOOL_FIELD(omit_quotes);
READ_BOOL_FIELD(outerJoin);
READ_INT_FIELD(colMin);
READ_INT_FIELD(colMax);
+ READ_BOOL_FIELD(errorOnError);
READ_DONE();
}
READ_LOCALS(JsonIsPredicate);
READ_NODE_FIELD(expr);
- READ_ENUM_FIELD(value_type, JsonValueType);
+ READ_NODE_FIELD(format);
+ READ_ENUM_FIELD(item_type, JsonValueType);
READ_BOOL_FIELD(unique_keys);
READ_LOCATION_FIELD(location);
return_value = _readJsonCoercion();
else if (MATCH("JSONITEMCOERCIONS", 17))
return_value = _readJsonItemCoercions();
- else if (MATCH("JSONTABPNODE", 12))
+ else if (MATCH("JSONTABLEPARENT", 15))
return_value = _readJsonTableParent();
- else if (MATCH("JSONTABSNODE", 12))
+ else if (MATCH("JSONTABLESIBLING", 16))
return_value = _readJsonTableSibling();
else
{
}
/*
- * Transform IS JSON predicate into
- * json[b]_is_valid(json, value_type [, check_key_uniqueness]) call.
+ * Transform IS JSON predicate.
*/
static Node *
transformJsonIsPredicate(ParseState *pstate, JsonIsPredicate *pred)
errmsg("cannot use type %s in IS JSON predicate",
format_type_be(exprtype))));
- return makeJsonIsPredicate(expr, NULL, pred->value_type,
+ /* This intentionally(?) drops the format clause. */
+ return makeJsonIsPredicate(expr, NULL, pred->item_type,
pred->unique_keys, pred->location);
}
appendStringInfoString(context->buf, " IS JSON");
- switch (pred->value_type)
+ /* TODO: handle FORMAT clause */
+
+ switch (pred->item_type)
{
case JS_TYPE_SCALAR:
appendStringInfoString(context->buf, " SCALAR");
{
JsonFormat *format = (JsonFormat *) node;
- APP_JUMB(format->type);
+ APP_JUMB(format->format_type);
APP_JUMB(format->encoding);
}
break;
{
JsonConstructorExpr *ctor = (JsonConstructorExpr *) node;
+ APP_JUMB(ctor->type);
+ JumbleExpr(jstate, (Node *) ctor->args);
JumbleExpr(jstate, (Node *) ctor->func);
JumbleExpr(jstate, (Node *) ctor->coercion);
JumbleExpr(jstate, (Node *) ctor->returning);
- APP_JUMB(ctor->type);
- APP_JUMB(ctor->unique);
APP_JUMB(ctor->absent_on_null);
+ APP_JUMB(ctor->unique);
}
break;
case T_JsonIsPredicate:
JumbleExpr(jstate, (Node *) pred->expr);
JumbleExpr(jstate, (Node *) pred->format);
+ APP_JUMB(pred->item_type);
APP_JUMB(pred->unique_keys);
- APP_JUMB(pred->value_type);
}
break;
case T_JsonExpr:
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 202205121
+#define CATALOG_VERSION_NO 202205131
#endif
Node *plan1, Node *plan2, int location);
extern Node *makeJsonKeyValue(Node *key, Node *value);
extern Node *makeJsonIsPredicate(Node *expr, JsonFormat *format,
- JsonValueType vtype, bool unique_keys,
+ JsonValueType item_type, bool unique_keys,
int location);
extern JsonEncoding makeJsonEncoding(char *name);
/*
* JsonIsPredicate -
- * untransformed representation of IS JSON predicate
+ * representation of IS JSON predicate
*/
typedef struct JsonIsPredicate
{
NodeTag type;
- Node *expr; /* untransformed expression */
+ Node *expr; /* subject expression */
JsonFormat *format; /* FORMAT clause, if specified */
- JsonValueType value_type; /* JSON item type */
+ JsonValueType item_type; /* JSON item type */
bool unique_keys; /* check key uniqueness? */
int location; /* token location, or -1 if unknown */
} JsonIsPredicate;