mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +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:
@ -1359,7 +1359,8 @@ CheckPredicate(Expr *predicate)
|
||||
|
||||
/*
|
||||
* Compute per-index-column information, including indexed column numbers
|
||||
* or index expressions, opclasses, and indoptions.
|
||||
* or index expressions, opclasses, and indoptions. Note, all output vectors
|
||||
* should be allocated for all columns, including "including" ones.
|
||||
*/
|
||||
static void
|
||||
ComputeIndexAttrs(IndexInfo *indexInfo,
|
||||
@ -1490,6 +1491,36 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
|
||||
|
||||
typeOidP[attn] = atttype;
|
||||
|
||||
/*
|
||||
* Included columns have no collation, no opclass and no ordering options.
|
||||
*/
|
||||
if (attn >= nkeycols)
|
||||
{
|
||||
if (attribute->collation)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("including column does not support a collation")));
|
||||
if (attribute->opclass)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("including column does not support an operator class")));
|
||||
if (attribute->ordering != SORTBY_DEFAULT)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("including column does not support ASC/DESC options")));
|
||||
if (attribute->nulls_ordering != SORTBY_NULLS_DEFAULT)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("including column does not support NULLS FIRST/LAST options")));
|
||||
|
||||
classOidP[attn] = InvalidOid;
|
||||
colOptionP[attn] = 0;
|
||||
collationOidP[attn] = InvalidOid;
|
||||
attn++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Apply collation override if any
|
||||
*/
|
||||
@ -1521,17 +1552,6 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
|
||||
|
||||
collationOidP[attn] = attcollation;
|
||||
|
||||
/*
|
||||
* Included columns have no opclass and no ordering options.
|
||||
*/
|
||||
if (attn >= nkeycols)
|
||||
{
|
||||
classOidP[attn] = InvalidOid;
|
||||
colOptionP[attn] = 0;
|
||||
attn++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Identify the opclass to use.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user