Adds SEARCH and CYCLE clauses to ruleutils_14.c

Relevant PG commit:
3696a600e2292d43c00949ddf0352e4ebb487e5b
pull/5209/head
Halil Ozan Akgul 2021-08-16 15:21:32 +03:00 committed by Sait Talha Nisanci
parent 1174046a33
commit 12b3c04fe3
1 changed files with 47 additions and 0 deletions

View File

@ -2011,6 +2011,53 @@ get_with_clause(Query *query, deparse_context *context)
if (PRETTY_INDENT(context))
appendContextKeyword(context, "", 0, 0, 0);
appendStringInfoChar(buf, ')');
if (cte->search_clause)
{
bool first = true;
ListCell *lc;
appendStringInfo(buf, " SEARCH %s FIRST BY ",
cte->search_clause->search_breadth_first ? "BREADTH" : "DEPTH");
foreach(lc, cte->search_clause->search_col_list)
{
if (first)
first = false;
else
appendStringInfoString(buf, ", ");
appendStringInfoString(buf,
quote_identifier(strVal(lfirst(lc))));
}
appendStringInfo(buf, " SET %s", quote_identifier(cte->search_clause->search_seq_column));
}
if (cte->cycle_clause)
{
bool first = true;
ListCell *lc;
appendStringInfoString(buf, " CYCLE ");
foreach(lc, cte->cycle_clause->cycle_col_list)
{
if (first)
first = false;
else
appendStringInfoString(buf, ", ");
appendStringInfoString(buf,
quote_identifier(strVal(lfirst(lc))));
}
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);
appendStringInfo(buf, " USING %s", quote_identifier(cte->cycle_clause->cycle_path_column));
}
sep = ", ";
}