PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/htup_details.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/cost.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/planner.h"
#include "optimizer/prep.h"
#include "optimizer/tlist.h"
#include "parser/parse_coerce.h"
#include "utils/selfuncs.h"
Go to the source code of this file.
Functions | |
static RelOptInfo * | recurse_set_operations (Node *setOp, PlannerInfo *root, List *colTypes, List *colCollations, bool junkOK, int flag, List *refnames_tlist, List **pTargetList, bool *istrivial_tlist) |
static RelOptInfo * | generate_recursion_path (SetOperationStmt *setOp, PlannerInfo *root, List *refnames_tlist, List **pTargetList) |
static void | build_setop_child_paths (PlannerInfo *root, RelOptInfo *rel, bool trivial_tlist, List *child_tlist, List *interesting_pathkeys, double *pNumGroups) |
static RelOptInfo * | generate_union_paths (SetOperationStmt *op, PlannerInfo *root, List *refnames_tlist, List **pTargetList) |
static RelOptInfo * | generate_nonunion_paths (SetOperationStmt *op, PlannerInfo *root, List *refnames_tlist, List **pTargetList) |
static List * | plan_union_children (PlannerInfo *root, SetOperationStmt *top_union, List *refnames_tlist, List **tlist_list, List **istrivial_tlist) |
static void | postprocess_setop_rel (PlannerInfo *root, RelOptInfo *rel) |
static bool | choose_hashed_setop (PlannerInfo *root, List *groupClauses, Path *input_path, double dNumGroups, double dNumOutputRows, const char *construct) |
static List * | generate_setop_tlist (List *colTypes, List *colCollations, int flag, Index varno, bool hack_constants, List *input_tlist, List *refnames_tlist, bool *trivial_tlist) |
static List * | generate_append_tlist (List *colTypes, List *colCollations, bool flag, List *input_tlists, List *refnames_tlist) |
static List * | generate_setop_grouplist (SetOperationStmt *op, List *targetlist) |
RelOptInfo * | plan_set_operations (PlannerInfo *root) |
bool | set_operation_ordered_results_useful (SetOperationStmt *setop) |
|
static |
Definition at line 504 of file prepunion.c.
References add_partial_path(), add_path(), add_setop_child_rel_equivalences(), Assert, bms_is_empty, RelOptInfo::cheapest_total_path, RelOptInfo::consider_parallel, convert_subquery_pathkeys(), create_incremental_sort_path(), create_sort_path(), create_subqueryscan_path(), Query::distinctClause, enable_incremental_sort, estimate_num_groups(), fetch_upper_rel(), get_tlist_exprs(), Query::groupClause, Query::groupingSets, PlannerInfo::hasHavingQual, RelOptInfo::lateral_relids, lfirst, PlannerInfo::limit_tuples, linitial, make_tlist_from_pathtarget(), NIL, PlannerInfo::parse, RelOptInfo::partial_pathlist, pathkeys_count_contained_in(), RelOptInfo::pathlist, postprocess_setop_rel(), root, Path::rows, RTE_SUBQUERY, RelOptInfo::rtekind, set_subquery_size_estimates(), PlannerInfo::setop_pathkeys, subpath(), RelOptInfo::subroot, Query::targetList, and UPPERREL_FINAL.
Referenced by generate_nonunion_paths(), generate_recursion_path(), and generate_union_paths().
|
static |
Definition at line 1290 of file prepunion.c.
References AGG_HASHED, compare_fractional_path_costs(), cost_agg(), cost_group(), cost_sort(), Path::disabled_nodes, enable_hashagg, ereport, errcode(), errdetail(), errmsg(), ERROR, get_hash_memory_limit(), grouping_is_hashable(), grouping_is_sortable(), list_length(), MAXALIGN, NIL, root, Path::rows, SizeofMinimalTupleHeader, Path::startup_cost, Path::total_cost, and work_mem.
Referenced by generate_nonunion_paths().
|
static |
Definition at line 1550 of file prepunion.c.
References Assert, TargetEntry::expr, exprType(), exprTypmod(), flag(), forthree, InvalidOid, lappend(), lfirst, lfirst_oid, list_head(), list_length(), lnext(), makeTargetEntry(), makeVar(), NIL, palloc(), pfree(), pstrdup(), TargetEntry::resno, and TargetEntry::ressortgroupref.
Referenced by generate_nonunion_paths(), generate_recursion_path(), and generate_union_paths().
|
static |
Definition at line 1018 of file prepunion.c.
References add_path(), SetOperationStmt::all, bms_union(), build_setop_child_paths(), RelOptInfo::cheapest_total_path, choose_hashed_setop(), create_append_path(), create_pathtarget, create_setop_path(), create_sort_path(), elog, ERROR, fetch_upper_rel(), generate_append_tlist(), generate_setop_grouplist(), SetOperationStmt::larg, list_length(), list_make2, make_pathkeys_for_sortclauses(), Min, NIL, SetOperationStmt::op, SetOperationStmt::rarg, recurse_set_operations(), RelOptInfo::relids, RelOptInfo::reltarget, root, RelOptInfo::rows, Path::rows, RTE_SUBQUERY, RelOptInfo::rtekind, SETOP_EXCEPT, SETOP_HASHED, SETOP_INTERSECT, SETOP_SORTED, SETOPCMD_EXCEPT, SETOPCMD_EXCEPT_ALL, SETOPCMD_INTERSECT, SETOPCMD_INTERSECT_ALL, and UPPERREL_SETOP.
Referenced by recurse_set_operations().
|
static |
Definition at line 384 of file prepunion.c.
References add_path(), SetOperationStmt::all, Assert, bms_union(), build_setop_child_paths(), RelOptInfo::cheapest_total_path, create_pathtarget, create_recursiveunion_path(), elog, ereport, errcode(), errdetail(), errmsg(), ERROR, fetch_upper_rel(), generate_append_tlist(), generate_setop_grouplist(), grouping_is_hashable(), SetOperationStmt::larg, list_make2, NIL, SetOperationStmt::op, postprocess_setop_rel(), SetOperationStmt::rarg, recurse_set_operations(), RelOptInfo::relids, RelOptInfo::reltarget, root, Path::rows, RTE_SUBQUERY, RelOptInfo::rtekind, SETOP_UNION, and UPPERREL_SETOP.
Referenced by plan_set_operations().
|
static |
Definition at line 1678 of file prepunion.c.
References Assert, copyObject, lfirst, list_head(), lnext(), TargetEntry::resno, TargetEntry::ressortgroupref, and SortGroupClause::tleSortGroupRef.
Referenced by generate_nonunion_paths(), generate_recursion_path(), and generate_union_paths().
|
static |
Definition at line 1401 of file prepunion.c.
References applyRelabelType(), Assert, COERCE_IMPLICIT_CAST, coerce_to_common_type(), TargetEntry::expr, exprCollation(), exprType(), exprTypmod(), flag(), forfour, Int32GetDatum(), InvalidOid, IsA, lappend(), lfirst, lfirst_oid, makeConst(), makeTargetEntry(), makeVar(), NIL, pstrdup(), TargetEntry::resno, and TargetEntry::ressortgroupref.
Referenced by recurse_set_operations().
|
static |
Definition at line 696 of file prepunion.c.
References add_path(), AGG_HASHED, AGGSPLIT_SIMPLE, SetOperationStmt::all, Assert, bms_union(), build_setop_child_paths(), RelOptInfo::cheapest_total_path, RelOptInfo::consider_parallel, RelOptInfo::consider_startup, create_agg_path(), create_append_path(), create_gather_path(), create_merge_append_path(), create_pathtarget, create_sort_path(), create_upper_unique_path(), enable_parallel_append, fetch_upper_rel(), forthree, generate_append_tlist(), generate_setop_grouplist(), get_cheapest_path_for_pathkeys(), grouping_is_hashable(), grouping_is_sortable(), lappend(), lfirst, lfirst_int, lfirst_node, linitial, list_length(), make_pathkeys_for_sortclauses(), Max, max_parallel_workers_per_gather, Min, NIL, RelOptInfo::partial_pathlist, Path::pathkeys, RelOptInfo::pathlist, pg_leftmost_one_pos32(), plan_union_children(), RelOptInfo::relids, RelOptInfo::reltarget, root, RelOptInfo::rows, Path::rows, RTE_SUBQUERY, RelOptInfo::rtekind, subpath(), TOTAL_COST, and UPPERREL_SETOP.
Referenced by recurse_set_operations().
RelOptInfo* plan_set_operations | ( | PlannerInfo * | root | ) |
Definition at line 99 of file prepunion.c.
References Assert, castNode, generate_recursion_path(), IsA, SetOperationStmt::larg, NIL, parse(), recurse_set_operations(), root, setup_simple_rel_arrays(), RangeTblEntry::subquery, and Query::targetList.
Referenced by grouping_planner().
|
static |
Definition at line 1208 of file prepunion.c.
References SetOperationStmt::all, equal(), IsA, lappend(), lappend_int(), SetOperationStmt::larg, lcons(), linitial, list_delete_first(), list_make1, NIL, SetOperationStmt::op, SetOperationStmt::rarg, recurse_set_operations(), and root.
Referenced by generate_union_paths().
|
static |
Definition at line 1272 of file prepunion.c.
References create_upper_paths_hook, root, set_cheapest(), and UPPERREL_SETOP.
Referenced by build_setop_child_paths(), generate_recursion_path(), and recurse_set_operations().
|
static |
Definition at line 230 of file prepunion.c.
References apply_projection_to_path(), Assert, build_simple_rel(), castNode, check_stack_depth(), create_pathtarget, create_projection_path(), elog, ERROR, flag(), generate_nonunion_paths(), generate_setop_tlist(), generate_union_paths(), IsA, lfirst, NIL, nodeTag, SetOperationStmt::op, RelOptInfo::partial_pathlist, RelOptInfo::pathlist, postprocess_setop_rel(), PlannerInfo::processed_tlist, RelOptInfo::reltarget, root, RangeTblRef::rtindex, SETOP_UNION, subpath(), RangeTblEntry::subquery, subquery_planner(), RelOptInfo::subroot, tlist_same_collations(), and tlist_same_datatypes().
Referenced by generate_nonunion_paths(), generate_recursion_path(), plan_set_operations(), and plan_union_children().
bool set_operation_ordered_results_useful | ( | SetOperationStmt * | setop | ) |
Definition at line 188 of file prepunion.c.
References SetOperationStmt::all, SetOperationStmt::op, and SETOP_UNION.
Referenced by standard_qp_callback().