mirror of https://github.com/citusdata/citus.git
Adds grammar support for SQL/JSON clauses in ruleutils_15.c
Relevant PG commit: f79b803dcc98d707450e158db3638dc67ff8380bpg_15_iso_fix
parent
c61abcdbe1
commit
0a62294569
|
@ -5019,6 +5019,11 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case T_JsonValueExpr:
|
||||||
|
/* maybe simple, check args */
|
||||||
|
return isSimpleNode((Node *) ((JsonValueExpr *) node)->raw_expr,
|
||||||
|
node, prettyFlags);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5124,6 +5129,48 @@ get_rule_expr_paren(Node *node, deparse_context *context,
|
||||||
appendStringInfoChar(context->buf, ')');
|
appendStringInfoChar(context->buf, ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get_json_format - Parse back a JsonFormat node
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
get_json_format(JsonFormat *format, deparse_context *context)
|
||||||
|
{
|
||||||
|
if (format->format_type == JS_FORMAT_DEFAULT)
|
||||||
|
return;
|
||||||
|
|
||||||
|
appendStringInfoString(context->buf,
|
||||||
|
format->format_type == JS_FORMAT_JSONB ?
|
||||||
|
" FORMAT JSONB" : " FORMAT JSON");
|
||||||
|
|
||||||
|
if (format->encoding != JS_ENC_DEFAULT)
|
||||||
|
{
|
||||||
|
const char *encoding =
|
||||||
|
format->encoding == JS_ENC_UTF16 ? "UTF16" :
|
||||||
|
format->encoding == JS_ENC_UTF32 ? "UTF32" : "UTF8";
|
||||||
|
|
||||||
|
appendStringInfo(context->buf, " ENCODING %s", encoding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get_json_returning - Parse back a JsonReturning structure
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
get_json_returning(JsonReturning *returning, deparse_context *context,
|
||||||
|
bool json_format_by_default)
|
||||||
|
{
|
||||||
|
if (!OidIsValid(returning->typid))
|
||||||
|
return;
|
||||||
|
|
||||||
|
appendStringInfo(context->buf, " RETURNING %s",
|
||||||
|
format_type_with_typemod(returning->typid,
|
||||||
|
returning->typmod));
|
||||||
|
|
||||||
|
if (!json_format_by_default ||
|
||||||
|
returning->format->format_type !=
|
||||||
|
(returning->typid == JSONBOID ? JS_FORMAT_JSONB : JS_FORMAT_JSON))
|
||||||
|
get_json_format(returning->format, context);
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------
|
/* ----------
|
||||||
* get_rule_expr - Parse back an expression
|
* get_rule_expr - Parse back an expression
|
||||||
|
@ -6306,6 +6353,15 @@ get_rule_expr(Node *node, deparse_context *context,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_JsonValueExpr:
|
||||||
|
{
|
||||||
|
JsonValueExpr *jve = (JsonValueExpr *) node;
|
||||||
|
|
||||||
|
get_rule_expr((Node *) jve->raw_expr, context, false);
|
||||||
|
get_json_format(jve->format, context);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case T_List:
|
case T_List:
|
||||||
{
|
{
|
||||||
char *sep;
|
char *sep;
|
||||||
|
|
Loading…
Reference in New Issue