mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
SEARCH and CYCLE clauses
This adds the SQL standard feature that adds the SEARCH and CYCLE clauses to recursive queries to be able to do produce breadth- or depth-first search orders and detect cycles. These clauses can be rewritten into queries using existing syntax, and that is what this patch does in the rewriter. Reviewed-by: Vik Fearing <vik@postgresfriends.org> Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/db80ceee-6f97-9b4a-8ee8-3ba0c58e5be2@2ndquadrant.com
This commit is contained in:
@@ -2841,6 +2841,34 @@ _equalOnConflictClause(const OnConflictClause *a, const OnConflictClause *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalCTESearchClause(const CTESearchClause *a, const CTESearchClause *b)
|
||||
{
|
||||
COMPARE_NODE_FIELD(search_col_list);
|
||||
COMPARE_SCALAR_FIELD(search_breadth_first);
|
||||
COMPARE_STRING_FIELD(search_seq_column);
|
||||
COMPARE_LOCATION_FIELD(location);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalCTECycleClause(const CTECycleClause *a, const CTECycleClause *b)
|
||||
{
|
||||
COMPARE_NODE_FIELD(cycle_col_list);
|
||||
COMPARE_STRING_FIELD(cycle_mark_column);
|
||||
COMPARE_NODE_FIELD(cycle_mark_value);
|
||||
COMPARE_NODE_FIELD(cycle_mark_default);
|
||||
COMPARE_STRING_FIELD(cycle_path_column);
|
||||
COMPARE_LOCATION_FIELD(location);
|
||||
COMPARE_SCALAR_FIELD(cycle_mark_type);
|
||||
COMPARE_SCALAR_FIELD(cycle_mark_typmod);
|
||||
COMPARE_SCALAR_FIELD(cycle_mark_collation);
|
||||
COMPARE_SCALAR_FIELD(cycle_mark_neop);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalCommonTableExpr(const CommonTableExpr *a, const CommonTableExpr *b)
|
||||
{
|
||||
@@ -2848,6 +2876,8 @@ _equalCommonTableExpr(const CommonTableExpr *a, const CommonTableExpr *b)
|
||||
COMPARE_NODE_FIELD(aliascolnames);
|
||||
COMPARE_SCALAR_FIELD(ctematerialized);
|
||||
COMPARE_NODE_FIELD(ctequery);
|
||||
COMPARE_NODE_FIELD(search_clause);
|
||||
COMPARE_NODE_FIELD(cycle_clause);
|
||||
COMPARE_LOCATION_FIELD(location);
|
||||
COMPARE_SCALAR_FIELD(cterecursive);
|
||||
COMPARE_SCALAR_FIELD(cterefcount);
|
||||
@@ -3735,6 +3765,12 @@ equal(const void *a, const void *b)
|
||||
case T_OnConflictClause:
|
||||
retval = _equalOnConflictClause(a, b);
|
||||
break;
|
||||
case T_CTESearchClause:
|
||||
retval = _equalCTESearchClause(a, b);
|
||||
break;
|
||||
case T_CTECycleClause:
|
||||
retval = _equalCTECycleClause(a, b);
|
||||
break;
|
||||
case T_CommonTableExpr:
|
||||
retval = _equalCommonTableExpr(a, b);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user