diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2018-04-12 16:37:22 +0300 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2018-04-12 16:37:22 +0300 |
commit | c266ed31a8a3beed3533e6a78faeca78234cbd43 (patch) | |
tree | 7e84de64e37a2a7f17739fb28fcbcded62f704ff /src/backend/commands/indexcmds.c | |
parent | 08ea7a2291db21a618d19d612c8060cda68f1892 (diff) | |
download | postgresql-c266ed31a8a3beed3533e6a78faeca78234cbd43.tar.gz postgresql-c266ed31a8a3beed3533e6a78faeca78234cbd43.zip |
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
Diffstat (limited to 'src/backend/commands/indexcmds.c')
-rw-r--r-- | src/backend/commands/indexcmds.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 3d90204d420..61a4b24437b 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -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, @@ -1491,6 +1492,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 */ if (attribute->collation) @@ -1522,17 +1553,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. */ classOidP[attn] = ResolveOpClass(attribute->opclass, |