mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Enhanced cycle mark values
Per SQL:202x draft, in the CYCLE clause of a recursive query, the cycle mark values can be of type boolean and can be omitted, in which case they default to TRUE and FALSE. Reviewed-by: Vik Fearing <vik@postgresfriends.org> Discussion: https://www.postgresql.org/message-id/flat/db80ceee-6f97-9b4a-8ee8-3ba0c58e5be2@2ndquadrant.com
This commit is contained in:
@ -5208,10 +5208,21 @@ get_with_clause(Query *query, deparse_context *context)
|
||||
}
|
||||
|
||||
appendStringInfo(buf, " SET %s", quote_identifier(cte->cycle_clause->cycle_mark_column));
|
||||
appendStringInfoString(buf, " TO ");
|
||||
get_rule_expr(cte->cycle_clause->cycle_mark_value, context, false);
|
||||
appendStringInfoString(buf, " DEFAULT ");
|
||||
get_rule_expr(cte->cycle_clause->cycle_mark_default, context, false);
|
||||
|
||||
{
|
||||
Const *cmv = castNode(Const, cte->cycle_clause->cycle_mark_value);
|
||||
Const *cmd = castNode(Const, cte->cycle_clause->cycle_mark_default);
|
||||
|
||||
if (!(cmv->consttype == BOOLOID && !cmv->constisnull && DatumGetBool(cmv->constvalue) == true &&
|
||||
cmd->consttype == BOOLOID && !cmd->constisnull && DatumGetBool(cmd->constvalue) == false))
|
||||
{
|
||||
appendStringInfoString(buf, " TO ");
|
||||
get_rule_expr(cte->cycle_clause->cycle_mark_value, context, false);
|
||||
appendStringInfoString(buf, " DEFAULT ");
|
||||
get_rule_expr(cte->cycle_clause->cycle_mark_default, context, false);
|
||||
}
|
||||
}
|
||||
|
||||
appendStringInfo(buf, " USING %s", quote_identifier(cte->cycle_clause->cycle_path_column));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user