mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
Cleanup covering infrastructure
- Explicitly forbids opclass, collation and indoptions (like DESC/ASC etc) for including columns. Throw an error if user points that. - Truncated storage arrays for such attributes to store only key atrributes, added assertion checks. - Do not check opfamily and collation for including columns in CompareIndexInfo() Discussion: https://www.postgresql.org/message-id/5ee72852-3c4e-ee35-e2ed-c1d053d45c08@sigaev.ru
This commit is contained in:
@ -2329,8 +2329,8 @@ match_clause_to_indexcol(IndexOptInfo *index,
|
||||
{
|
||||
Expr *clause = rinfo->clause;
|
||||
Index index_relid = index->rel->relid;
|
||||
Oid opfamily = index->opfamily[indexcol];
|
||||
Oid idxcollation = index->indexcollations[indexcol];
|
||||
Oid opfamily;
|
||||
Oid idxcollation;
|
||||
Node *leftop,
|
||||
*rightop;
|
||||
Relids left_relids;
|
||||
@ -2339,6 +2339,11 @@ match_clause_to_indexcol(IndexOptInfo *index,
|
||||
Oid expr_coll;
|
||||
bool plain_op;
|
||||
|
||||
Assert(indexcol < index->nkeycolumns);
|
||||
|
||||
opfamily = index->opfamily[indexcol];
|
||||
idxcollation = index->indexcollations[indexcol];
|
||||
|
||||
/* First check for boolean-index cases. */
|
||||
if (IsBooleanOpfamily(opfamily))
|
||||
{
|
||||
@ -2678,8 +2683,8 @@ match_clause_to_ordering_op(IndexOptInfo *index,
|
||||
Expr *clause,
|
||||
Oid pk_opfamily)
|
||||
{
|
||||
Oid opfamily = index->opfamily[indexcol];
|
||||
Oid idxcollation = index->indexcollations[indexcol];
|
||||
Oid opfamily;
|
||||
Oid idxcollation;
|
||||
Node *leftop,
|
||||
*rightop;
|
||||
Oid expr_op;
|
||||
@ -2687,6 +2692,10 @@ match_clause_to_ordering_op(IndexOptInfo *index,
|
||||
Oid sortfamily;
|
||||
bool commuted;
|
||||
|
||||
Assert(indexcol < index->nkeycolumns);
|
||||
|
||||
opfamily = index->opfamily[indexcol];
|
||||
idxcollation = index->indexcollations[indexcol];
|
||||
/*
|
||||
* Clause must be a binary opclause.
|
||||
*/
|
||||
@ -2921,8 +2930,13 @@ ec_member_matches_indexcol(PlannerInfo *root, RelOptInfo *rel,
|
||||
{
|
||||
IndexOptInfo *index = ((ec_member_matches_arg *) arg)->index;
|
||||
int indexcol = ((ec_member_matches_arg *) arg)->indexcol;
|
||||
Oid curFamily = index->opfamily[indexcol];
|
||||
Oid curCollation = index->indexcollations[indexcol];
|
||||
Oid curFamily;
|
||||
Oid curCollation;
|
||||
|
||||
Assert(indexcol < index->nkeycolumns);
|
||||
|
||||
curFamily = index->opfamily[indexcol];
|
||||
curCollation = index->indexcollations[indexcol];
|
||||
|
||||
/*
|
||||
* If it's a btree index, we can reject it if its opfamily isn't
|
||||
@ -3548,8 +3562,13 @@ expand_indexqual_conditions(IndexOptInfo *index,
|
||||
RestrictInfo *rinfo = (RestrictInfo *) lfirst(lcc);
|
||||
int indexcol = lfirst_int(lci);
|
||||
Expr *clause = rinfo->clause;
|
||||
Oid curFamily = index->opfamily[indexcol];
|
||||
Oid curCollation = index->indexcollations[indexcol];
|
||||
Oid curFamily;
|
||||
Oid curCollation;
|
||||
|
||||
Assert(indexcol < index->nkeycolumns);
|
||||
|
||||
curFamily = index->opfamily[indexcol];
|
||||
curCollation = index->indexcollations[indexcol];
|
||||
|
||||
/* First check for boolean cases */
|
||||
if (IsBooleanOpfamily(curFamily))
|
||||
@ -3918,14 +3937,15 @@ adjust_rowcompare_for_index(RowCompareExpr *clause,
|
||||
/*
|
||||
* The Var side can match any column of the index.
|
||||
*/
|
||||
for (i = 0; i < index->ncolumns; i++)
|
||||
for (i = 0; i < index->nkeycolumns; i++)
|
||||
{
|
||||
if (match_index_to_operand(varop, i, index) &&
|
||||
get_op_opfamily_strategy(expr_op,
|
||||
index->opfamily[i]) == op_strategy &&
|
||||
IndexCollMatchesExprColl(index->indexcollations[i],
|
||||
lfirst_oid(collids_cell)))
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
if (i >= index->ncolumns)
|
||||
break; /* no match found */
|
||||
|
Reference in New Issue
Block a user