aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniil Cherednik <dcherednik@ydb.tech>2024-01-11 18:13:40 +0100
committerGitHub <noreply@github.com>2024-01-11 18:13:40 +0100
commit27016d52a89ebcdabeb1c395da53ad300282ee0b (patch)
treeeeca7e4af40ccdd77c41d4126095eb84b8745d03
parente67863791f9b920db900dbf300c5abaee981b131 (diff)
downloadydb-27016d52a89ebcdabeb1c395da53ad300282ee0b.tar.gz
fix missed check for usedIndexes. (#947)
-rw-r--r--ydb/core/kqp/opt/physical/effects/kqp_opt_phy_upsert_index.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/ydb/core/kqp/opt/physical/effects/kqp_opt_phy_upsert_index.cpp b/ydb/core/kqp/opt/physical/effects/kqp_opt_phy_upsert_index.cpp
index 405c9e0e3f..c9e11842f4 100644
--- a/ydb/core/kqp/opt/physical/effects/kqp_opt_phy_upsert_index.cpp
+++ b/ydb/core/kqp/opt/physical/effects/kqp_opt_phy_upsert_index.cpp
@@ -365,10 +365,12 @@ TMaybe<TCondenseInputResult> CheckUniqueConstraint(const TExprBase& inputRows, c
for (const auto& [_, indexDesc] : indexes) {
hasUniqIndex |= (indexDesc->Type == TIndexDescription::EType::GlobalSyncUnique);
for (const auto& indexKeyCol : indexDesc->KeyColumns) {
- if (inputColumns.contains(indexKeyCol)
- && std::find(mainPk.begin(), mainPk.end(), indexKeyCol) == mainPk.end())
- {
- usedIndexes.insert(indexDesc->Name);
+ if (inputColumns.contains(indexKeyCol)) {
+ if (!usedIndexes.contains(indexDesc->Name) &&
+ std::find(mainPk.begin(), mainPk.end(), indexKeyCol) == mainPk.end())
+ {
+ usedIndexes.insert(indexDesc->Name);
+ }
} else {
// input always contains key columns
YQL_ENSURE(std::find(mainPk.begin(), mainPk.end(), indexKeyCol) == mainPk.end());