* flatten_logic_exprs * This function is only used by ExecPrefetchJoinQual. * ExecPrefetchJoinQual need to prefetch subplan in join * qual that contains motion to materialize it to avoid * motion deadlock. This function is going to flatten * the bool exprs to avoid shortcut of bool logic. * An example is: * (a and b or c) or (d or e and f or g) and (h and i or j) * will be transformed to
| 1421 | * (a, b, c, d, e, f, g, h, i, j). |
| 1422 | */ |
| 1423 | static List * |
| 1424 | flatten_logic_exprs(Node *node) |
| 1425 | { |
| 1426 | if (node == NULL) |
| 1427 | return NIL; |
| 1428 | |
| 1429 | if (IsA(node, BoolExpr)) |
| 1430 | { |
| 1431 | BoolExpr *be = (BoolExpr *) node; |
| 1432 | return flatten_logic_exprs((Node *) (be->args)); |
| 1433 | } |
| 1434 | |
| 1435 | if (IsA(node, List)) |
| 1436 | { |
| 1437 | List *es = (List *) node; |
| 1438 | List *result = NIL; |
| 1439 | ListCell *lc = NULL; |
| 1440 | |
| 1441 | foreach(lc, es) |
| 1442 | { |
| 1443 | Node *n = (Node *) lfirst(lc); |
| 1444 | result = list_concat(result, |
| 1445 | flatten_logic_exprs(n)); |
| 1446 | } |
| 1447 | |
| 1448 | return result; |
| 1449 | } |
| 1450 | |
| 1451 | return list_make1(node); |
| 1452 | } |
| 1453 | |
| 1454 | /* |
| 1455 | * fake_outer_params |
no test coverage detected