* truncate_useless_pathkeys * Shorten the given pathkey list to just the useful pathkeys. */
| 2471 | * Shorten the given pathkey list to just the useful pathkeys. |
| 2472 | */ |
| 2473 | List * |
| 2474 | truncate_useless_pathkeys(PlannerInfo *root, |
| 2475 | RelOptInfo *rel, |
| 2476 | List *pathkeys) |
| 2477 | { |
| 2478 | int nuseful; |
| 2479 | int nuseful2; |
| 2480 | |
| 2481 | nuseful = pathkeys_useful_for_merging(root, rel, pathkeys); |
| 2482 | nuseful2 = pathkeys_useful_for_ordering(root, pathkeys); |
| 2483 | if (nuseful2 > nuseful) |
| 2484 | nuseful = nuseful2; |
| 2485 | |
| 2486 | /* |
| 2487 | * Note: not safe to modify input list destructively, but we can avoid |
| 2488 | * copying the list if we're not actually going to change it |
| 2489 | */ |
| 2490 | if (nuseful == 0) |
| 2491 | return NIL; |
| 2492 | else if (nuseful == list_length(pathkeys)) |
| 2493 | return pathkeys; |
| 2494 | else |
| 2495 | return list_truncate(list_copy(pathkeys), nuseful); |
| 2496 | } |
| 2497 | |
| 2498 | /* |
| 2499 | * has_useful_pathkeys |
no test coverage detected