mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Avoid recursion when processing simple lists of AND'ed or OR'ed clauses.
Since most of the system thinks AND and OR are N-argument expressions anyway, let's have the grammar generate a representation of that form when dealing with input like "x AND y AND z AND ...", rather than generating a deeply-nested binary tree that just has to be flattened later by the planner. This avoids stack overflow in parse analysis when dealing with queries having more than a few thousand such clauses; and in any case it removes some rather unsightly inconsistencies, since some parts of parse analysis were generating N-argument ANDs/ORs already. It's still possible to get a stack overflow with weirdly parenthesized input, such as "x AND (y AND (z AND ( ... )))", but such cases are not mainstream usage. The maximum depth of parenthesization is already limited by Bison's stack in such cases, anyway, so that the limit is probably fairly platform-independent. Patch originally by Gurjeet Singh, heavily revised by me
This commit is contained in:
@ -2437,15 +2437,6 @@ _outAExpr(StringInfo str, const A_Expr *node)
|
||||
appendStringInfoChar(str, ' ');
|
||||
WRITE_NODE_FIELD(name);
|
||||
break;
|
||||
case AEXPR_AND:
|
||||
appendStringInfoString(str, " AND");
|
||||
break;
|
||||
case AEXPR_OR:
|
||||
appendStringInfoString(str, " OR");
|
||||
break;
|
||||
case AEXPR_NOT:
|
||||
appendStringInfoString(str, " NOT");
|
||||
break;
|
||||
case AEXPR_OP_ANY:
|
||||
appendStringInfoChar(str, ' ');
|
||||
WRITE_NODE_FIELD(name);
|
||||
|
Reference in New Issue
Block a user