* postgresGetForeignRelSize * Estimate # of rows and width of the result of the scan * * We should consider the effect of all baserestrictinfo clauses here, but * not any join clauses. */
| 620 | * not any join clauses. |
| 621 | */ |
| 622 | static void |
| 623 | postgresGetForeignRelSize(PlannerInfo *root, |
| 624 | RelOptInfo *baserel, |
| 625 | Oid foreigntableid) |
| 626 | { |
| 627 | PgFdwRelationInfo *fpinfo; |
| 628 | ListCell *lc; |
| 629 | RangeTblEntry *rte = planner_rt_fetch(baserel->relid, root); |
| 630 | |
| 631 | /* |
| 632 | * We use PgFdwRelationInfo to pass various information to subsequent |
| 633 | * functions. |
| 634 | */ |
| 635 | fpinfo = (PgFdwRelationInfo *) palloc0(sizeof(PgFdwRelationInfo)); |
| 636 | baserel->fdw_private = (void *) fpinfo; |
| 637 | |
| 638 | /* Base foreign tables need to be pushed down always. */ |
| 639 | fpinfo->pushdown_safe = true; |
| 640 | |
| 641 | /* Look up foreign-table catalog info. */ |
| 642 | fpinfo->table = GetForeignTable(foreigntableid); |
| 643 | fpinfo->server = GetForeignServer(fpinfo->table->serverid); |
| 644 | |
| 645 | /* |
| 646 | * Extract user-settable option values. Note that per-table settings of |
| 647 | * use_remote_estimate, fetch_size and async_capable override per-server |
| 648 | * settings of them, respectively. |
| 649 | */ |
| 650 | fpinfo->use_remote_estimate = false; |
| 651 | fpinfo->fdw_startup_cost = DEFAULT_FDW_STARTUP_COST; |
| 652 | fpinfo->fdw_tuple_cost = DEFAULT_FDW_TUPLE_COST; |
| 653 | fpinfo->shippable_extensions = NIL; |
| 654 | fpinfo->fetch_size = 100; |
| 655 | fpinfo->async_capable = false; |
| 656 | |
| 657 | apply_server_options(fpinfo); |
| 658 | apply_table_options(fpinfo); |
| 659 | |
| 660 | /* |
| 661 | * If the table or the server is configured to use remote estimates, |
| 662 | * identify which user to do remote access as during planning. This |
| 663 | * should match what ExecCheckRTEPerms() does. If we fail due to lack of |
| 664 | * permissions, the query would have failed at runtime anyway. |
| 665 | */ |
| 666 | if (fpinfo->use_remote_estimate) |
| 667 | { |
| 668 | Oid userid = rte->checkAsUser ? rte->checkAsUser : GetUserId(); |
| 669 | |
| 670 | fpinfo->user = GetUserMapping(userid, fpinfo->server->serverid); |
| 671 | } |
| 672 | else |
| 673 | fpinfo->user = NULL; |
| 674 | |
| 675 | /* |
| 676 | * Identify which baserestrictinfo clauses can be sent to the remote |
| 677 | * server and which can't. |
| 678 | */ |
| 679 | classifyConditions(root, baserel, baserel->baserestrictinfo, |
nothing calls this directly
no test coverage detected