diff --git a/ydb/core/protos/flat_scheme_op.proto b/ydb/core/protos/flat_scheme_op.proto index 2e1c5c58a1e1..6136d090b873 100644 --- a/ydb/core/protos/flat_scheme_op.proto +++ b/ydb/core/protos/flat_scheme_op.proto @@ -1482,6 +1482,7 @@ message TApplyIf { optional uint64 PathId = 1; optional uint64 PathVersion = 2; optional uint64 LockedTxId = 3; + optional bool CheckEntityVersion = 4 [default = false]; } message TUpgradeSubDomain { diff --git a/ydb/core/tx/schemeshard/schemeshard_impl.cpp b/ydb/core/tx/schemeshard/schemeshard_impl.cpp index fe63f68618ff..c106529ef196 100644 --- a/ydb/core/tx/schemeshard/schemeshard_impl.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_impl.cpp @@ -1227,7 +1227,72 @@ bool TSchemeShard::CheckApplyIf(const NKikimrSchemeOp::TModifyScheme &scheme, TS if (item.HasPathVersion()) { const auto requiredVersion = item.GetPathVersion(); - const auto actualVersion = GetPathVersion(TPath::Init(pathId, this)).GetGeneralVersion(); + arc_ui64 actualVersion; + auto path = TPath::Init(pathId, this); + auto pathVersion = GetPathVersion(path); + + if (item.HasCheckEntityVersion() && item.GetCheckEntityVersion()) { + switch(path.Base()->PathType) { + case NKikimrSchemeOp::EPathTypePersQueueGroup: + actualVersion = pathVersion.GetPQVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeSubDomain: + case NKikimrSchemeOp::EPathType::EPathTypeExtSubDomain: + actualVersion = pathVersion.GetSubDomainVersion(); + break; + case NKikimrSchemeOp::EPathTypeTable: + actualVersion = pathVersion.GetTableSchemaVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeBlockStoreVolume: + actualVersion = pathVersion.GetBSVVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeFileStore: + actualVersion = pathVersion.GetFileStoreVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeKesus: + actualVersion = pathVersion.GetKesusVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeRtmrVolume: + actualVersion = pathVersion.GetRTMRVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeSolomonVolume: + actualVersion = pathVersion.GetSolomonVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeTableIndex: + actualVersion = pathVersion.GetTableIndexVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeColumnStore: + actualVersion = pathVersion.GetColumnStoreVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeColumnTable: + actualVersion = pathVersion.GetColumnTableVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeCdcStream: + actualVersion = pathVersion.GetCdcStreamVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeSequence: + actualVersion = pathVersion.GetSequenceVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeReplication: + actualVersion = pathVersion.GetReplicationVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeExternalTable: + actualVersion = pathVersion.GetExternalTableVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeExternalDataSource: + actualVersion = pathVersion.GetExternalDataSourceVersion(); + break; + case NKikimrSchemeOp::EPathType::EPathTypeView: + actualVersion = pathVersion.GetViewVersion(); + break; + default: + actualVersion = pathVersion.GetGeneralVersion(); + break; + } + } else { + actualVersion = pathVersion.GetGeneralVersion(); + } + if (requiredVersion != actualVersion) { errStr = TStringBuilder() << "fail user constraint in ApplyIf section:"