diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 09c28dca03..76282f4009 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -25,6 +25,7 @@ #include "postgres.h" #include "catalog/pg_type.h" +#include "miscadmin.h" #include "nodes/makefuncs.h" #include "optimizer/clauses.h" #include "optimizer/var.h" @@ -1238,6 +1239,9 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) Assert(stmt && IsA(stmt, SelectStmt)); + /* Guard against stack overflow due to overly complex set-expressions */ + check_stack_depth(); + /* * Validity-check both leaf and internal SELECTs for disallowed ops. */