* Can the target list of a Plan node safely be replaced? */
| 480 | * Can the target list of a Plan node safely be replaced? |
| 481 | */ |
| 482 | static bool |
| 483 | can_replace_tlist(Plan *plan) |
| 484 | { |
| 485 | if (!plan) |
| 486 | return false; |
| 487 | |
| 488 | /* |
| 489 | * SRFs in targetlists are quite funky. Don't mess with them. |
| 490 | * We could probably be smarter about them, but doesn't seem |
| 491 | * worth the trouble. |
| 492 | */ |
| 493 | if (expression_returns_set((Node *) plan->targetlist)) |
| 494 | return false; |
| 495 | |
| 496 | if (!is_projection_capable_plan(plan)) |
| 497 | return false; |
| 498 | |
| 499 | /* |
| 500 | * The Hash Filter column indexes in a Result node are based on |
| 501 | * the output target list. Can't change the target list if there's |
| 502 | * a Hash Filter, or it would mess up the column indexes. |
| 503 | */ |
| 504 | if (IsA(plan, Result)) |
| 505 | { |
| 506 | Result *rplan = (Result *) plan; |
| 507 | |
| 508 | if (rplan->numHashFilterCols > 0) |
| 509 | return false; |
| 510 | } |
| 511 | |
| 512 | /* |
| 513 | * Split Update node also calculates a hash based on the output |
| 514 | * targetlist, like a Result with a Hash Filter. |
| 515 | */ |
| 516 | if (IsA(plan, SplitUpdate)) |
| 517 | return false; |
| 518 | |
| 519 | return true; |
| 520 | } |
| 521 | |
| 522 | /* |
| 523 | * Fix up a target list, by replacing outer-Vars with the exprs from |
no test coverage detected