- * set_plain_rel_pathlist
- * Build access paths for a plain relation (no subquery, no inheritance)
- *
- * This function was copied and edited from set_plain_rel_pathlist() in
- * src/backend/optimizer/path/allpaths.c
- *
- * - removed parallel stuff.
- */
-static void
-set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
-{
- Relids required_outer;
-
- /*
- * We don't support pushing join clauses into the quals of a seqscan, but
- * it could still have required parameterization due to LATERAL refs in
- * its tlist.
- */
- required_outer = rel->lateral_relids;
-
- /* Consider sequential scan */
- add_path(rel, create_seqscan_path(root, rel, required_outer, 0));
-
- /* If appropriate, consider parallel sequential scan */
- if (rel->consider_parallel && required_outer == NULL)
- {
- ParallelHint *phint = find_parallel_hint(root, rel->relid, rel);
-
- /* Consider parallel paths only if not inhibited by hint */
- if (!phint || phint->nworkers > 0)
- create_plain_partial_paths(root, rel);
-
- /*
- * Overwirte parallel_workers if requested. partial_pathlist seems to
- * have up to one path but looping over all possible paths don't harm.
- */
- if (phint && phint->nworkers > 0 && phint->force_parallel)
- {
- ListCell *l;
- foreach (l, rel->partial_pathlist)
- {
- Path *ppath = (Path *) lfirst(l);
-
- Assert(ppath->parallel_workers > 0);
- ppath->parallel_workers = phint->nworkers;
- }
- }
- }
-
- /* Consider index scans */
- create_index_paths(root, rel);
-
- /* Consider TID scans */
- create_tidscan_paths(root, rel);
-}
-
-/*
- * Clear exiting access paths and create new ones applying hints.
- * This does the similar to set_rel_pathlist
- */
-static void
-rebuild_scan_path(HintState *hstate, PlannerInfo *root, int level,
- List *initial_rels)
-{
- ListCell *l;
-
- foreach(l, initial_rels)
- {
- RelOptInfo *rel = (RelOptInfo *) lfirst(l);
- RangeTblEntry *rte;
-
- /* Skip relations which we can't choose scan method. */
- if (rel->reloptkind != RELOPT_BASEREL || rel->rtekind != RTE_RELATION)
- continue;
-
- rte = root->simple_rte_array[rel->relid];
-
- /* We can't force scan method of foreign tables */
- if (rte->relkind == RELKIND_FOREIGN_TABLE)
- continue;
-
- /*
- * Create scan paths with GUC parameters which are at the beginning of
- * planner if scan method hint is not specified, otherwise use
- * specified hints and mark the hint as used.
- */
- setup_scan_method_enforcement(find_scan_hint(root, rel->relid, rel),
- hstate);
-
- /* Setup parallel environment according to the hint */
- setup_parallel_plan_enfocement(
- find_parallel_hint(root, rel->relid, rel), current_hint_state);
-
- /* remove existing partial paths from this baserel */
- list_free_deep(rel->partial_pathlist);
- rel->partial_pathlist = NIL;
-
- /* remove existing paths from this baserel */
- list_free_deep(rel->pathlist);
- rel->pathlist = NIL;
-
- if (rte->inh)
- {
- ListCell *l;
-
- /* remove partial paths from all chlidren */
- foreach (l, root->append_rel_list)
- {
- AppendRelInfo *appinfo = (AppendRelInfo *) lfirst(l);
- RelOptInfo *childrel;
-
- if (appinfo->parent_relid != rel->relid)
- continue;
-
- childrel = root->simple_rel_array[appinfo->child_relid];
- list_free_deep(childrel->partial_pathlist);
- childrel->partial_pathlist = NIL;
- }
- /* It's an "append relation", process accordingly */
- set_append_rel_pathlist(root, rel, rel->relid, rte);
- }
- else
- {
- set_plain_rel_pathlist(root, rel, rte);
- }
-
- /*
- * If this is a baserel, consider gathering any partial paths we may
- * hinthave created for it.
- */
- if (rel->reloptkind == RELOPT_BASEREL)
- generate_gather_paths(root, rel);
-
- /* Now find the cheapest of the paths for this rel */
- set_cheapest(rel);
- }
-
- /*
- * Restore the GUC variables we set above.
- */
- setup_scan_method_enforcement(NULL, hstate);
-}
-
-/*