mirror of
https://github.com/postgres/postgres.git
synced 2025-07-20 05:03:10 +03:00
pgindent run for 8.2.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.153 2006/09/19 22:49:52 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.154 2006/10/04 00:29:53 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -43,13 +43,13 @@ static void set_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti);
|
||||
static void set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
|
||||
RangeTblEntry *rte);
|
||||
static void set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
|
||||
Index rti, RangeTblEntry *rte);
|
||||
Index rti, RangeTblEntry *rte);
|
||||
static void set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel,
|
||||
Index rti, RangeTblEntry *rte);
|
||||
static void set_function_pathlist(PlannerInfo *root, RelOptInfo *rel,
|
||||
RangeTblEntry *rte);
|
||||
static void set_values_pathlist(PlannerInfo *root, RelOptInfo *rel,
|
||||
RangeTblEntry *rte);
|
||||
RangeTblEntry *rte);
|
||||
static RelOptInfo *make_rel_from_joinlist(PlannerInfo *root, List *joinlist);
|
||||
static RelOptInfo *make_one_rel_by_joins(PlannerInfo *root, int levels_needed,
|
||||
List *initial_rels);
|
||||
@ -253,7 +253,7 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
|
||||
* set_append_rel_pathlist
|
||||
* Build access paths for an "append relation"
|
||||
*
|
||||
* The passed-in rel and RTE represent the entire append relation. The
|
||||
* The passed-in rel and RTE represent the entire append relation. The
|
||||
* relation's contents are computed by appending together the output of
|
||||
* the individual member relations. Note that in the inheritance case,
|
||||
* the first member relation is actually the same table as is mentioned in
|
||||
@ -271,8 +271,8 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
|
||||
/*
|
||||
* XXX for now, can't handle inherited expansion of FOR UPDATE/SHARE; can
|
||||
* we do better? (This will take some redesign because the executor
|
||||
* currently supposes that every rowMark relation is involved in every
|
||||
* row returned by the query.)
|
||||
* currently supposes that every rowMark relation is involved in every row
|
||||
* returned by the query.)
|
||||
*/
|
||||
if (get_rowmark(root->parse, parentRTindex))
|
||||
ereport(ERROR,
|
||||
@ -336,16 +336,16 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
|
||||
childrel->max_attr);
|
||||
|
||||
/*
|
||||
* Compute the child's access paths, and add the cheapest one
|
||||
* to the Append path we are constructing for the parent.
|
||||
* Compute the child's access paths, and add the cheapest one to the
|
||||
* Append path we are constructing for the parent.
|
||||
*
|
||||
* It's possible that the child is itself an appendrel, in which
|
||||
* case we can "cut out the middleman" and just add its child
|
||||
* paths to our own list. (We don't try to do this earlier because
|
||||
* we need to apply both levels of transformation to the quals.)
|
||||
* This test also handles the case where the child rel need not
|
||||
* be scanned because of constraint exclusion: it'll have an
|
||||
* Append path with no subpaths, and will vanish from our list.
|
||||
* It's possible that the child is itself an appendrel, in which case
|
||||
* we can "cut out the middleman" and just add its child paths to our
|
||||
* own list. (We don't try to do this earlier because we need to
|
||||
* apply both levels of transformation to the quals.) This test also
|
||||
* handles the case where the child rel need not be scanned because of
|
||||
* constraint exclusion: it'll have an Append path with no subpaths,
|
||||
* and will vanish from our list.
|
||||
*/
|
||||
set_rel_pathlist(root, childrel, childRTindex);
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.81 2006/07/14 14:52:20 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.82 2006/10/04 00:29:53 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -429,16 +429,16 @@ clause_selectivity(PlannerInfo *root,
|
||||
rinfo = (RestrictInfo *) clause;
|
||||
|
||||
/*
|
||||
* If the clause is marked pseudoconstant, then it will be used as
|
||||
* a gating qual and should not affect selectivity estimates; hence
|
||||
* return 1.0. The only exception is that a constant FALSE may
|
||||
* be taken as having selectivity 0.0, since it will surely mean
|
||||
* no rows out of the plan. This case is simple enough that we
|
||||
* need not bother caching the result.
|
||||
* If the clause is marked pseudoconstant, then it will be used as a
|
||||
* gating qual and should not affect selectivity estimates; hence
|
||||
* return 1.0. The only exception is that a constant FALSE may be
|
||||
* taken as having selectivity 0.0, since it will surely mean no rows
|
||||
* out of the plan. This case is simple enough that we need not
|
||||
* bother caching the result.
|
||||
*/
|
||||
if (rinfo->pseudoconstant)
|
||||
{
|
||||
if (! IsA(rinfo->clause, Const))
|
||||
if (!IsA(rinfo->clause, Const))
|
||||
return s1;
|
||||
}
|
||||
|
||||
@ -529,7 +529,7 @@ clause_selectivity(PlannerInfo *root,
|
||||
else if (IsA(clause, Const))
|
||||
{
|
||||
/* bool constant is pretty easy... */
|
||||
Const *con = (Const *) clause;
|
||||
Const *con = (Const *) clause;
|
||||
|
||||
s1 = con->constisnull ? 0.0 :
|
||||
DatumGetBool(con->constvalue) ? 1.0 : 0.0;
|
||||
@ -542,7 +542,7 @@ clause_selectivity(PlannerInfo *root,
|
||||
if (IsA(subst, Const))
|
||||
{
|
||||
/* bool constant is pretty easy... */
|
||||
Const *con = (Const *) subst;
|
||||
Const *con = (Const *) subst;
|
||||
|
||||
s1 = con->constisnull ? 0.0 :
|
||||
DatumGetBool(con->constvalue) ? 1.0 : 0.0;
|
||||
|
@ -54,7 +54,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.166 2006/09/19 22:49:52 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.167 2006/10/04 00:29:53 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -92,7 +92,7 @@ double cpu_tuple_cost = DEFAULT_CPU_TUPLE_COST;
|
||||
double cpu_index_tuple_cost = DEFAULT_CPU_INDEX_TUPLE_COST;
|
||||
double cpu_operator_cost = DEFAULT_CPU_OPERATOR_COST;
|
||||
|
||||
int effective_cache_size = DEFAULT_EFFECTIVE_CACHE_SIZE;
|
||||
int effective_cache_size = DEFAULT_EFFECTIVE_CACHE_SIZE;
|
||||
|
||||
Cost disable_cost = 100000000.0;
|
||||
|
||||
@ -276,13 +276,13 @@ cost_index(IndexPath *path, PlannerInfo *root,
|
||||
if (outer_rel != NULL && outer_rel->rows > 1)
|
||||
{
|
||||
/*
|
||||
* For repeated indexscans, scale up the number of tuples fetched
|
||||
* in the Mackert and Lohman formula by the number of scans, so
|
||||
* that we estimate the number of pages fetched by all the scans.
|
||||
* Then pro-rate the costs for one scan. In this case we assume
|
||||
* all the fetches are random accesses. XXX it'd be good to
|
||||
* include correlation in this model, but it's not clear how to do
|
||||
* that without double-counting cache effects.
|
||||
* For repeated indexscans, scale up the number of tuples fetched in
|
||||
* the Mackert and Lohman formula by the number of scans, so that we
|
||||
* estimate the number of pages fetched by all the scans. Then
|
||||
* pro-rate the costs for one scan. In this case we assume all the
|
||||
* fetches are random accesses. XXX it'd be good to include
|
||||
* correlation in this model, but it's not clear how to do that
|
||||
* without double-counting cache effects.
|
||||
*/
|
||||
double num_scans = outer_rel->rows;
|
||||
|
||||
@ -385,7 +385,7 @@ cost_index(IndexPath *path, PlannerInfo *root,
|
||||
* computed for us by query_planner.
|
||||
*
|
||||
* Caller is expected to have ensured that tuples_fetched is greater than zero
|
||||
* and rounded to integer (see clamp_row_est). The result will likewise be
|
||||
* and rounded to integer (see clamp_row_est). The result will likewise be
|
||||
* greater than zero and integral.
|
||||
*/
|
||||
double
|
||||
@ -406,7 +406,8 @@ index_pages_fetched(double tuples_fetched, BlockNumber pages,
|
||||
Assert(T <= total_pages);
|
||||
|
||||
/* b is pro-rated share of effective_cache_size */
|
||||
b = (double) effective_cache_size * T / total_pages;
|
||||
b = (double) effective_cache_size *T / total_pages;
|
||||
|
||||
/* force it positive and integral */
|
||||
if (b <= 1.0)
|
||||
b = 1.0;
|
||||
@ -543,10 +544,10 @@ cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel,
|
||||
if (outer_rel != NULL && outer_rel->rows > 1)
|
||||
{
|
||||
/*
|
||||
* For repeated bitmap scans, scale up the number of tuples fetched
|
||||
* in the Mackert and Lohman formula by the number of scans, so
|
||||
* that we estimate the number of pages fetched by all the scans.
|
||||
* Then pro-rate for one scan.
|
||||
* For repeated bitmap scans, scale up the number of tuples fetched in
|
||||
* the Mackert and Lohman formula by the number of scans, so that we
|
||||
* estimate the number of pages fetched by all the scans. Then
|
||||
* pro-rate for one scan.
|
||||
*/
|
||||
double num_scans = outer_rel->rows;
|
||||
|
||||
@ -573,7 +574,7 @@ cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel,
|
||||
/*
|
||||
* For small numbers of pages we should charge random_page_cost apiece,
|
||||
* while if nearly all the table's pages are being read, it's more
|
||||
* appropriate to charge seq_page_cost apiece. The effect is nonlinear,
|
||||
* appropriate to charge seq_page_cost apiece. The effect is nonlinear,
|
||||
* too. For lack of a better idea, interpolate like this to determine the
|
||||
* cost per page.
|
||||
*/
|
||||
@ -748,7 +749,7 @@ cost_tidscan(Path *path, PlannerInfo *root,
|
||||
{
|
||||
/* Each element of the array yields 1 tuple */
|
||||
ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) lfirst(l);
|
||||
Node *arraynode = (Node *) lsecond(saop->args);
|
||||
Node *arraynode = (Node *) lsecond(saop->args);
|
||||
|
||||
ntuples += estimate_array_length(arraynode);
|
||||
}
|
||||
@ -849,8 +850,8 @@ cost_valuesscan(Path *path, PlannerInfo *root, RelOptInfo *baserel)
|
||||
Assert(baserel->rtekind == RTE_VALUES);
|
||||
|
||||
/*
|
||||
* For now, estimate list evaluation cost at one operator eval per
|
||||
* list (probably pretty bogus, but is it worth being smarter?)
|
||||
* For now, estimate list evaluation cost at one operator eval per list
|
||||
* (probably pretty bogus, but is it worth being smarter?)
|
||||
*/
|
||||
cpu_per_tuple = cpu_operator_cost;
|
||||
|
||||
@ -875,7 +876,7 @@ cost_valuesscan(Path *path, PlannerInfo *root, RelOptInfo *baserel)
|
||||
* If the total volume exceeds work_mem, we switch to a tape-style merge
|
||||
* algorithm. There will still be about t*log2(t) tuple comparisons in
|
||||
* total, but we will also need to write and read each tuple once per
|
||||
* merge pass. We expect about ceil(logM(r)) merge passes where r is the
|
||||
* merge pass. We expect about ceil(logM(r)) merge passes where r is the
|
||||
* number of initial runs formed and M is the merge order used by tuplesort.c.
|
||||
* Since the average initial run should be about twice work_mem, we have
|
||||
* disk traffic = 2 * relsize * ceil(logM(p / (2*work_mem)))
|
||||
@ -1745,7 +1746,7 @@ cost_qual_eval_walker(Node *node, QualCost *total)
|
||||
* array elements before the answer is determined.
|
||||
*/
|
||||
ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) node;
|
||||
Node *arraynode = (Node *) lsecond(saop->args);
|
||||
Node *arraynode = (Node *) lsecond(saop->args);
|
||||
|
||||
total->per_tuple +=
|
||||
cpu_operator_cost * estimate_array_length(arraynode) * 0.5;
|
||||
@ -1967,7 +1968,7 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
|
||||
*
|
||||
* If we are doing an outer join, take that into account: the output must
|
||||
* be at least as large as the non-nullable input. (Is there any chance
|
||||
* of being even smarter?) (XXX this is not really right, because it
|
||||
* of being even smarter?) (XXX this is not really right, because it
|
||||
* assumes all the restriction clauses are join clauses; we should figure
|
||||
* pushed-down clauses separately.)
|
||||
*
|
||||
@ -2132,10 +2133,10 @@ set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel)
|
||||
Assert(rte->rtekind == RTE_VALUES);
|
||||
|
||||
/*
|
||||
* Estimate number of rows the values list will return.
|
||||
* We know this precisely based on the list length (well,
|
||||
* barring set-returning functions in list items, but that's
|
||||
* a refinement not catered for anywhere else either).
|
||||
* Estimate number of rows the values list will return. We know this
|
||||
* precisely based on the list length (well, barring set-returning
|
||||
* functions in list items, but that's a refinement not catered for
|
||||
* anywhere else either).
|
||||
*/
|
||||
rel->tuples = list_length(rte->values_lists);
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.211 2006/07/22 15:41:55 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.212 2006/10/04 00:29:54 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -54,10 +54,10 @@ static List *find_saop_paths(PlannerInfo *root, RelOptInfo *rel,
|
||||
List *clauses, List *outer_clauses,
|
||||
bool istoplevel, RelOptInfo *outer_rel);
|
||||
static Path *choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel,
|
||||
List *paths, RelOptInfo *outer_rel);
|
||||
List *paths, RelOptInfo *outer_rel);
|
||||
static int bitmap_path_comparator(const void *a, const void *b);
|
||||
static Cost bitmap_and_cost_est(PlannerInfo *root, RelOptInfo *rel,
|
||||
List *paths, RelOptInfo *outer_rel);
|
||||
List *paths, RelOptInfo *outer_rel);
|
||||
static List *pull_indexpath_quals(Path *bitmapqual);
|
||||
static bool lists_intersect_ptr(List *list1, List *list2);
|
||||
static bool match_clause_to_indexcol(IndexOptInfo *index,
|
||||
@ -66,7 +66,7 @@ static bool match_clause_to_indexcol(IndexOptInfo *index,
|
||||
Relids outer_relids,
|
||||
SaOpControl saop_control);
|
||||
static bool is_indexable_operator(Oid expr_op, Oid opclass,
|
||||
bool indexkey_on_left);
|
||||
bool indexkey_on_left);
|
||||
static bool match_rowcompare_to_indexcol(IndexOptInfo *index,
|
||||
int indexcol,
|
||||
Oid opclass,
|
||||
@ -324,8 +324,8 @@ find_usable_indexes(PlannerInfo *root, RelOptInfo *rel,
|
||||
/*
|
||||
* 1. Match the index against the available restriction clauses.
|
||||
* found_clause is set true only if at least one of the current
|
||||
* clauses was used (and, if saop_control is SAOP_REQUIRE, it
|
||||
* has to have been a ScalarArrayOpExpr clause).
|
||||
* clauses was used (and, if saop_control is SAOP_REQUIRE, it has to
|
||||
* have been a ScalarArrayOpExpr clause).
|
||||
*/
|
||||
restrictclauses = group_clauses_by_indexkey(index,
|
||||
clauses,
|
||||
@ -422,8 +422,8 @@ find_saop_paths(PlannerInfo *root, RelOptInfo *rel,
|
||||
ListCell *l;
|
||||
|
||||
/*
|
||||
* Since find_usable_indexes is relatively expensive, don't bother to
|
||||
* run it unless there are some top-level ScalarArrayOpExpr clauses.
|
||||
* Since find_usable_indexes is relatively expensive, don't bother to run
|
||||
* it unless there are some top-level ScalarArrayOpExpr clauses.
|
||||
*/
|
||||
foreach(l, clauses)
|
||||
{
|
||||
@ -588,15 +588,15 @@ choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel,
|
||||
* In theory we should consider every nonempty subset of the given paths.
|
||||
* In practice that seems like overkill, given the crude nature of the
|
||||
* estimates, not to mention the possible effects of higher-level AND and
|
||||
* OR clauses. As a compromise, we sort the paths by selectivity. We
|
||||
* OR clauses. As a compromise, we sort the paths by selectivity. We
|
||||
* always take the first, and sequentially add on paths that result in a
|
||||
* lower estimated cost.
|
||||
*
|
||||
* We also make some effort to detect directly redundant input paths, as
|
||||
* can happen if there are multiple possibly usable indexes. (Another
|
||||
* way it can happen is that best_inner_indexscan will find the same OR
|
||||
* join clauses that create_or_index_quals has pulled OR restriction
|
||||
* clauses out of, and then both versions show up as duplicate paths.) We
|
||||
* can happen if there are multiple possibly usable indexes. (Another way
|
||||
* it can happen is that best_inner_indexscan will find the same OR join
|
||||
* clauses that create_or_index_quals has pulled OR restriction clauses
|
||||
* out of, and then both versions show up as duplicate paths.) We
|
||||
* consider an index redundant if any of its index conditions were already
|
||||
* used by earlier indexes. (We could use predicate_implied_by to have a
|
||||
* more intelligent, but much more expensive, check --- but in most cases
|
||||
@ -796,7 +796,7 @@ lists_intersect_ptr(List *list1, List *list2)
|
||||
|
||||
foreach(cell1, list1)
|
||||
{
|
||||
void *datum1 = lfirst(cell1);
|
||||
void *datum1 = lfirst(cell1);
|
||||
ListCell *cell2;
|
||||
|
||||
foreach(cell2, list2)
|
||||
@ -963,7 +963,7 @@ group_clauses_by_indexkey(IndexOptInfo *index,
|
||||
* It is also possible to match RowCompareExpr clauses to indexes (but
|
||||
* currently, only btree indexes handle this). In this routine we will
|
||||
* report a match if the first column of the row comparison matches the
|
||||
* target index column. This is sufficient to guarantee that some index
|
||||
* target index column. This is sufficient to guarantee that some index
|
||||
* condition can be constructed from the RowCompareExpr --- whether the
|
||||
* remaining columns match the index too is considered in
|
||||
* expand_indexqual_rowcompare().
|
||||
@ -1004,10 +1004,10 @@ match_clause_to_indexcol(IndexOptInfo *index,
|
||||
bool plain_op;
|
||||
|
||||
/*
|
||||
* Never match pseudoconstants to indexes. (Normally this could not
|
||||
* happen anyway, since a pseudoconstant clause couldn't contain a
|
||||
* Var, but what if someone builds an expression index on a constant?
|
||||
* It's not totally unreasonable to do so with a partial index, either.)
|
||||
* Never match pseudoconstants to indexes. (Normally this could not
|
||||
* happen anyway, since a pseudoconstant clause couldn't contain a Var,
|
||||
* but what if someone builds an expression index on a constant? It's not
|
||||
* totally unreasonable to do so with a partial index, either.)
|
||||
*/
|
||||
if (rinfo->pseudoconstant)
|
||||
return false;
|
||||
@ -1421,9 +1421,9 @@ best_inner_indexscan(PlannerInfo *root, RelOptInfo *rel,
|
||||
* NOTE: because we cache on outer_relids rather than outer_rel->relids,
|
||||
* we will report the same path and hence path cost for joins with
|
||||
* different sets of irrelevant rels on the outside. Now that cost_index
|
||||
* is sensitive to outer_rel->rows, this is not really right. However
|
||||
* the error is probably not large. Is it worth establishing a separate
|
||||
* cache entry for each distinct outer_rel->relids set to get this right?
|
||||
* is sensitive to outer_rel->rows, this is not really right. However the
|
||||
* error is probably not large. Is it worth establishing a separate cache
|
||||
* entry for each distinct outer_rel->relids set to get this right?
|
||||
*/
|
||||
foreach(l, rel->index_inner_paths)
|
||||
{
|
||||
@ -1442,11 +1442,11 @@ best_inner_indexscan(PlannerInfo *root, RelOptInfo *rel,
|
||||
*
|
||||
* Note: because we include restriction clauses, we will find indexscans
|
||||
* that could be plain indexscans, ie, they don't require the join context
|
||||
* at all. This may seem redundant, but we need to include those scans in
|
||||
* at all. This may seem redundant, but we need to include those scans in
|
||||
* the input given to choose_bitmap_and() to be sure we find optimal AND
|
||||
* combinations of join and non-join scans. Also, even if the "best
|
||||
* inner indexscan" is just a plain indexscan, it will have a different
|
||||
* cost estimate because of cache effects.
|
||||
* combinations of join and non-join scans. Also, even if the "best inner
|
||||
* indexscan" is just a plain indexscan, it will have a different cost
|
||||
* estimate because of cache effects.
|
||||
*/
|
||||
clause_list = find_clauses_for_join(root, rel, outer_relids, isouterjoin);
|
||||
|
||||
@ -2210,7 +2210,7 @@ expand_indexqual_conditions(IndexOptInfo *index, List *clausegroups)
|
||||
foreach(l, (List *) lfirst(clausegroup_item))
|
||||
{
|
||||
RestrictInfo *rinfo = (RestrictInfo *) lfirst(l);
|
||||
Expr *clause = rinfo->clause;
|
||||
Expr *clause = rinfo->clause;
|
||||
|
||||
/* First check for boolean cases */
|
||||
if (IsBooleanOpclass(curClass))
|
||||
@ -2240,7 +2240,7 @@ expand_indexqual_conditions(IndexOptInfo *index, List *clausegroups)
|
||||
{
|
||||
resultquals = list_concat(resultquals,
|
||||
expand_indexqual_opclause(rinfo,
|
||||
curClass));
|
||||
curClass));
|
||||
}
|
||||
else if (IsA(clause, ScalarArrayOpExpr))
|
||||
{
|
||||
@ -2340,6 +2340,7 @@ static List *
|
||||
expand_indexqual_opclause(RestrictInfo *rinfo, Oid opclass)
|
||||
{
|
||||
Expr *clause = rinfo->clause;
|
||||
|
||||
/* we know these will succeed */
|
||||
Node *leftop = get_leftop(clause);
|
||||
Node *rightop = get_rightop(clause);
|
||||
@ -2421,7 +2422,7 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opclass)
|
||||
* column matches) or a simple OpExpr (if the first-column match is all
|
||||
* there is). In these cases the modified clause is always "<=" or ">="
|
||||
* even when the original was "<" or ">" --- this is necessary to match all
|
||||
* the rows that could match the original. (We are essentially building a
|
||||
* the rows that could match the original. (We are essentially building a
|
||||
* lossy version of the row comparison when we do this.)
|
||||
*/
|
||||
static RestrictInfo *
|
||||
@ -2430,18 +2431,18 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
|
||||
int indexcol)
|
||||
{
|
||||
RowCompareExpr *clause = (RowCompareExpr *) rinfo->clause;
|
||||
bool var_on_left;
|
||||
int op_strategy;
|
||||
Oid op_subtype;
|
||||
bool op_recheck;
|
||||
int matching_cols;
|
||||
Oid expr_op;
|
||||
List *opclasses;
|
||||
List *subtypes;
|
||||
List *new_ops;
|
||||
ListCell *largs_cell;
|
||||
ListCell *rargs_cell;
|
||||
ListCell *opnos_cell;
|
||||
bool var_on_left;
|
||||
int op_strategy;
|
||||
Oid op_subtype;
|
||||
bool op_recheck;
|
||||
int matching_cols;
|
||||
Oid expr_op;
|
||||
List *opclasses;
|
||||
List *subtypes;
|
||||
List *new_ops;
|
||||
ListCell *largs_cell;
|
||||
ListCell *rargs_cell;
|
||||
ListCell *opnos_cell;
|
||||
|
||||
/* We have to figure out (again) how the first col matches */
|
||||
var_on_left = match_index_to_operand((Node *) linitial(clause->largs),
|
||||
@ -2459,12 +2460,12 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
|
||||
subtypes = list_make1_oid(op_subtype);
|
||||
|
||||
/*
|
||||
* See how many of the remaining columns match some index column
|
||||
* in the same way. A note about rel membership tests: we assume
|
||||
* that the clause as a whole is already known to use only Vars from
|
||||
* the indexed relation and possibly some acceptable outer relations.
|
||||
* So the "other" side of any potential index condition is OK as long
|
||||
* as it doesn't use Vars from the indexed relation.
|
||||
* See how many of the remaining columns match some index column in the
|
||||
* same way. A note about rel membership tests: we assume that the clause
|
||||
* as a whole is already known to use only Vars from the indexed relation
|
||||
* and possibly some acceptable outer relations. So the "other" side of
|
||||
* any potential index condition is OK as long as it doesn't use Vars from
|
||||
* the indexed relation.
|
||||
*/
|
||||
matching_cols = 1;
|
||||
largs_cell = lnext(list_head(clause->largs));
|
||||
@ -2498,10 +2499,10 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
|
||||
break; /* no good, volatile comparison value */
|
||||
|
||||
/*
|
||||
* The Var side can match any column of the index. If the user
|
||||
* does something weird like having multiple identical index
|
||||
* columns, we insist the match be on the first such column,
|
||||
* to avoid confusing the executor.
|
||||
* The Var side can match any column of the index. If the user does
|
||||
* something weird like having multiple identical index columns, we
|
||||
* insist the match be on the first such column, to avoid confusing
|
||||
* the executor.
|
||||
*/
|
||||
for (i = 0; i < index->ncolumns; i++)
|
||||
{
|
||||
@ -2534,9 +2535,9 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
|
||||
return rinfo;
|
||||
|
||||
/*
|
||||
* We have to generate a subset rowcompare (possibly just one OpExpr).
|
||||
* The painful part of this is changing < to <= or > to >=, so deal with
|
||||
* that first.
|
||||
* We have to generate a subset rowcompare (possibly just one OpExpr). The
|
||||
* painful part of this is changing < to <= or > to >=, so deal with that
|
||||
* first.
|
||||
*/
|
||||
if (op_strategy == BTLessEqualStrategyNumber ||
|
||||
op_strategy == BTGreaterEqualStrategyNumber)
|
||||
@ -2546,8 +2547,8 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
|
||||
}
|
||||
else
|
||||
{
|
||||
ListCell *opclasses_cell;
|
||||
ListCell *subtypes_cell;
|
||||
ListCell *opclasses_cell;
|
||||
ListCell *subtypes_cell;
|
||||
|
||||
if (op_strategy == BTLessStrategyNumber)
|
||||
op_strategy = BTLessEqualStrategyNumber;
|
||||
@ -2561,13 +2562,13 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
|
||||
expr_op = get_opclass_member(lfirst_oid(opclasses_cell),
|
||||
lfirst_oid(subtypes_cell),
|
||||
op_strategy);
|
||||
if (!OidIsValid(expr_op)) /* should not happen */
|
||||
if (!OidIsValid(expr_op)) /* should not happen */
|
||||
elog(ERROR, "could not find member %d of opclass %u",
|
||||
op_strategy, lfirst_oid(opclasses_cell));
|
||||
if (!var_on_left)
|
||||
{
|
||||
expr_op = get_commutator(expr_op);
|
||||
if (!OidIsValid(expr_op)) /* should not happen */
|
||||
if (!OidIsValid(expr_op)) /* should not happen */
|
||||
elog(ERROR, "could not find commutator of member %d of opclass %u",
|
||||
op_strategy, lfirst_oid(opclasses_cell));
|
||||
}
|
||||
@ -2596,7 +2597,7 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
|
||||
}
|
||||
else
|
||||
{
|
||||
Expr *opexpr;
|
||||
Expr *opexpr;
|
||||
|
||||
opexpr = make_opclause(linitial_oid(new_ops), BOOLOID, false,
|
||||
copyObject(linitial(clause->largs)),
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.106 2006/08/17 17:06:37 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.107 2006/10/04 00:29:54 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -33,7 +33,7 @@ static void hash_inner_and_outer(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
RelOptInfo *outerrel, RelOptInfo *innerrel,
|
||||
List *restrictlist, JoinType jointype);
|
||||
static Path *best_appendrel_indexscan(PlannerInfo *root, RelOptInfo *rel,
|
||||
RelOptInfo *outer_rel, JoinType jointype);
|
||||
RelOptInfo *outer_rel, JoinType jointype);
|
||||
static List *select_mergejoin_clauses(RelOptInfo *joinrel,
|
||||
RelOptInfo *outerrel,
|
||||
RelOptInfo *innerrel,
|
||||
@ -544,9 +544,9 @@ match_unsorted_outer(PlannerInfo *root,
|
||||
* mergejoin using a subset of the merge clauses. Here, we consider
|
||||
* both cheap startup cost and cheap total cost. We can ignore
|
||||
* inner_cheapest_total on the first iteration, since we already made
|
||||
* a path with it --- but not on later iterations with shorter
|
||||
* sort keys, because then we are considering a different situation,
|
||||
* viz using a simpler mergejoin to avoid a sort of the inner rel.
|
||||
* a path with it --- but not on later iterations with shorter sort
|
||||
* keys, because then we are considering a different situation, viz
|
||||
* using a simpler mergejoin to avoid a sort of the inner rel.
|
||||
*/
|
||||
num_sortkeys = list_length(innersortkeys);
|
||||
if (num_sortkeys > 1 && !useallclauses)
|
||||
@ -792,7 +792,7 @@ hash_inner_and_outer(PlannerInfo *root,
|
||||
* best_appendrel_indexscan
|
||||
* Finds the best available set of inner indexscans for a nestloop join
|
||||
* with the given append relation on the inside and the given outer_rel
|
||||
* outside. Returns an AppendPath comprising the best inner scans, or
|
||||
* outside. Returns an AppendPath comprising the best inner scans, or
|
||||
* NULL if there are no possible inner indexscans.
|
||||
*/
|
||||
static Path *
|
||||
@ -820,9 +820,9 @@ best_appendrel_indexscan(PlannerInfo *root, RelOptInfo *rel,
|
||||
Assert(childrel->reloptkind == RELOPT_OTHER_MEMBER_REL);
|
||||
|
||||
/*
|
||||
* Check to see if child was rejected by constraint exclusion.
|
||||
* If so, it will have a cheapest_total_path that's an Append path
|
||||
* with no members (see set_plain_rel_pathlist).
|
||||
* Check to see if child was rejected by constraint exclusion. If so,
|
||||
* it will have a cheapest_total_path that's an Append path with no
|
||||
* members (see set_plain_rel_pathlist).
|
||||
*/
|
||||
if (IsA(childrel->cheapest_total_path, AppendPath) &&
|
||||
((AppendPath *) childrel->cheapest_total_path)->subpaths == NIL)
|
||||
@ -835,10 +835,10 @@ best_appendrel_indexscan(PlannerInfo *root, RelOptInfo *rel,
|
||||
outer_rel, jointype);
|
||||
|
||||
/*
|
||||
* If no luck on an indexpath for this rel, we'll still consider
|
||||
* an Append substituting the cheapest-total inner path. However
|
||||
* we must find at least one indexpath, else there's not going to
|
||||
* be any improvement over the base path for the appendrel.
|
||||
* If no luck on an indexpath for this rel, we'll still consider an
|
||||
* Append substituting the cheapest-total inner path. However we must
|
||||
* find at least one indexpath, else there's not going to be any
|
||||
* improvement over the base path for the appendrel.
|
||||
*/
|
||||
if (bestinnerjoin)
|
||||
found_indexscan = true;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.79 2006/03/05 15:58:28 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.80 2006/10/04 00:29:54 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -87,11 +87,11 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels)
|
||||
|
||||
/*
|
||||
* An exception occurs when there is a clauseless join inside a
|
||||
* construct that restricts join order, i.e., an outer join RHS
|
||||
* or an IN (sub-SELECT) construct. Here, the rel may well have
|
||||
* join clauses against stuff outside the OJ RHS or IN sub-SELECT,
|
||||
* but the clauseless join *must* be done before we can make use
|
||||
* of those join clauses. So do the clauseless join bit.
|
||||
* construct that restricts join order, i.e., an outer join RHS or
|
||||
* an IN (sub-SELECT) construct. Here, the rel may well have join
|
||||
* clauses against stuff outside the OJ RHS or IN sub-SELECT, but
|
||||
* the clauseless join *must* be done before we can make use of
|
||||
* those join clauses. So do the clauseless join bit.
|
||||
*
|
||||
* See also the last-ditch case below.
|
||||
*/
|
||||
@ -386,9 +386,9 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
|
||||
joinrelids = bms_union(rel1->relids, rel2->relids);
|
||||
|
||||
/*
|
||||
* If we have any outer joins, the proposed join might be illegal; and
|
||||
* in any case we have to determine its join type. Scan the OJ list
|
||||
* for conflicts.
|
||||
* If we have any outer joins, the proposed join might be illegal; and in
|
||||
* any case we have to determine its join type. Scan the OJ list for
|
||||
* conflicts.
|
||||
*/
|
||||
jointype = JOIN_INNER; /* default if no match to an OJ */
|
||||
is_valid_inner = true;
|
||||
@ -485,16 +485,16 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
|
||||
InClauseInfo *ininfo = (InClauseInfo *) lfirst(l);
|
||||
|
||||
/*
|
||||
* This IN clause is not relevant unless its RHS overlaps the
|
||||
* proposed join. (Check this first as a fast path for dismissing
|
||||
* most irrelevant INs quickly.)
|
||||
* This IN clause is not relevant unless its RHS overlaps the proposed
|
||||
* join. (Check this first as a fast path for dismissing most
|
||||
* irrelevant INs quickly.)
|
||||
*/
|
||||
if (!bms_overlap(ininfo->righthand, joinrelids))
|
||||
continue;
|
||||
|
||||
/*
|
||||
* If we are still building the IN clause's RHS, then this IN
|
||||
* clause isn't relevant yet.
|
||||
* If we are still building the IN clause's RHS, then this IN clause
|
||||
* isn't relevant yet.
|
||||
*/
|
||||
if (bms_is_subset(joinrelids, ininfo->righthand))
|
||||
continue;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.80 2006/07/14 14:52:20 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.81 2006/10/04 00:29:54 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -106,8 +106,8 @@ create_or_index_quals(PlannerInfo *root, RelOptInfo *rel)
|
||||
* Use the generate_bitmap_or_paths() machinery to estimate the
|
||||
* value of each OR clause. We can use regular restriction
|
||||
* clauses along with the OR clause contents to generate
|
||||
* indexquals. We pass outer_rel = NULL so that sub-clauses
|
||||
* that are actually joins will be ignored.
|
||||
* indexquals. We pass outer_rel = NULL so that sub-clauses that
|
||||
* are actually joins will be ignored.
|
||||
*/
|
||||
List *orpaths;
|
||||
ListCell *k;
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.78 2006/08/17 17:02:49 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.79 2006/10/04 00:29:54 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -909,7 +909,7 @@ get_cheapest_fractional_path_for_pathkeys(List *paths,
|
||||
* representing a backwards scan of the index. Return NIL if can't do it.
|
||||
*
|
||||
* If 'canonical' is TRUE, we remove duplicate pathkeys (which can occur
|
||||
* if two index columns are equijoined, eg WHERE x = 1 AND y = 1). This
|
||||
* if two index columns are equijoined, eg WHERE x = 1 AND y = 1). This
|
||||
* is required if the result is to be compared directly to a canonical query
|
||||
* pathkeys list. However, some callers want a list with exactly one entry
|
||||
* per index column, and they must pass FALSE.
|
||||
@ -1106,8 +1106,8 @@ convert_subquery_pathkeys(PlannerInfo *root, RelOptInfo *rel,
|
||||
outer_expr = (Node *)
|
||||
makeRelabelType((Expr *) outer_expr,
|
||||
((RelabelType *) sub_key)->resulttype,
|
||||
((RelabelType *) sub_key)->resulttypmod,
|
||||
((RelabelType *) sub_key)->relabelformat);
|
||||
((RelabelType *) sub_key)->resulttypmod,
|
||||
((RelabelType *) sub_key)->relabelformat);
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
@ -24,7 +24,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.27 2006/03/05 15:58:28 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.28 2006/10/04 00:29:54 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -125,7 +125,7 @@ IsTidEqualAnyClause(ScalarArrayOpExpr *node, int varno)
|
||||
/* CTID must be first argument */
|
||||
if (arg1 && IsA(arg1, Var))
|
||||
{
|
||||
Var *var = (Var *) arg1;
|
||||
Var *var = (Var *) arg1;
|
||||
|
||||
if (var->varattno == SelfItemPointerAttributeNumber &&
|
||||
var->vartype == TIDOID &&
|
||||
@ -187,7 +187,7 @@ TidQualFromExpr(Node *expr, int varno)
|
||||
{
|
||||
foreach(l, ((BoolExpr *) expr)->args)
|
||||
{
|
||||
List *frtn = TidQualFromExpr((Node *) lfirst(l), varno);
|
||||
List *frtn = TidQualFromExpr((Node *) lfirst(l), varno);
|
||||
|
||||
if (frtn)
|
||||
rlst = list_concat(rlst, frtn);
|
||||
|
Reference in New Issue
Block a user