Skip to content

Commit df6714d

Browse files
authored
Merge 03a37b9 into 0474cb4
2 parents 0474cb4 + 03a37b9 commit df6714d

File tree

18 files changed

+253
-64
lines changed

18 files changed

+253
-64
lines changed

ydb/core/testlib/common_helper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void THelper::WaitForSchemeOperation(TActorId sender, ui64 txId) {
5353

5454
void THelper::StartScanRequest(const TString& request, const bool expectSuccess, TVector<THashMap<TString, NYdb::TValue>>* result) const {
5555
NYdb::NTable::TTableClient tClient(Server.GetDriver(),
56-
NYdb::NTable::TClientSettings().UseQueryCache(false).AuthToken("root@builtin"));
56+
NYdb::NTable::TClientSettings().UseQueryCache(false).AuthToken(AuthToken));
5757
auto expectation = expectSuccess;
5858
bool resultReady = false;
5959
TVector<THashMap<TString, NYdb::TValue>> rows;
@@ -109,7 +109,7 @@ void THelper::StartScanRequest(const TString& request, const bool expectSuccess,
109109

110110
void THelper::StartDataRequest(const TString& request, const bool expectSuccess, TString* result) const {
111111
NYdb::NTable::TTableClient tClient(Server.GetDriver(),
112-
NYdb::NTable::TClientSettings().UseQueryCache(false).AuthToken("root@builtin"));
112+
NYdb::NTable::TClientSettings().UseQueryCache(false).AuthToken(AuthToken));
113113
auto expectation = expectSuccess;
114114
bool resultReady = false;
115115
bool* rrPtr = &resultReady;
@@ -144,7 +144,7 @@ void THelper::StartDataRequest(const TString& request, const bool expectSuccess,
144144

145145
void THelper::StartSchemaRequestTableServiceImpl(const TString& request, const bool expectation, const bool waiting) const {
146146
NYdb::NTable::TTableClient tClient(Server.GetDriver(),
147-
NYdb::NTable::TClientSettings().UseQueryCache(false).AuthToken("root@builtin"));
147+
NYdb::NTable::TClientSettings().UseQueryCache(false).AuthToken(AuthToken));
148148

149149
std::shared_ptr<bool> rrPtr = std::make_shared<bool>(false);
150150
tClient.CreateSession().Subscribe([rrPtr, request, expectation](NThreading::TFuture<NYdb::NTable::TCreateSessionResult> f) {
@@ -171,7 +171,7 @@ void THelper::StartSchemaRequestTableServiceImpl(const TString& request, const b
171171

172172
void THelper::StartSchemaRequestQueryServiceImpl(const TString& request, const bool expectation, const bool waiting) const {
173173
NYdb::NQuery::TQueryClient qClient(Server.GetDriver(),
174-
NYdb::NQuery::TClientSettings().AuthToken("root@builtin"));
174+
NYdb::NQuery::TClientSettings().AuthToken(AuthToken));
175175

176176
std::shared_ptr<bool> rrPtr = std::make_shared<bool>(false);
177177
auto future = qClient.ExecuteQuery(request, NYdb::NQuery::TTxControl::NoTx());

ydb/core/testlib/common_helper.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ class TLoggerInit {
5454
};
5555

5656
class THelper {
57+
private:
58+
inline static const TString DefaultAuthToken = "root@builtin";
59+
YDB_ACCESSOR(TString, AuthToken, DefaultAuthToken);
60+
5761
protected:
5862
void WaitForSchemeOperation(TActorId sender, ui64 txId);
5963
void PrintResultSet(const NYdb::TResultSet& resultSet, NYson::TYsonWriter& writer) const;
@@ -73,6 +77,10 @@ class THelper {
7377
UseQueryService = use;
7478
}
7579

80+
void ResetAuthToken() {
81+
AuthToken = DefaultAuthToken;
82+
}
83+
7684
void DropTable(const TString& tablePath);
7785

7886
void StartScanRequest(const TString& request, const bool expectSuccess, TVector<THashMap<TString, NYdb::TValue>>* result) const;

ydb/mvp/meta/meta_cloud.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <ydb/public/api/protos/ydb_discovery.pb.h>
1515
#include <ydb/public/api/protos/ydb_table.pb.h>
1616
#include <ydb/public/sdk/cpp/client/ydb_result/result.h>
17-
#include <ydb/core/kqp/provider/yql_kikimr_results.h>
1817
#include <ydb/core/ydb_convert/ydb_convert.h>
1918
#include <ydb/public/api/client/yc_private/resourcemanager/cloud_service.grpc.pb.h>
2019
#include <ydb/mvp/core/core_ydb.h>

ydb/mvp/meta/meta_cluster.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <ydb/public/api/grpc/ydb_scripting_v1.grpc.pb.h>
1414
#include <ydb/public/api/protos/ydb_discovery.pb.h>
1515
#include <ydb/public/sdk/cpp/client/ydb_result/result.h>
16-
#include <ydb/core/kqp/provider/yql_kikimr_results.h>
1716
#include <ydb/core/ydb_convert/ydb_convert.h>
1817
#include <ydb/mvp/core/core_ydb.h>
1918
#include <ydb/mvp/core/core_ydb_impl.h>

ydb/mvp/meta/meta_clusters.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <ydb/public/sdk/cpp/client/ydb_proto/accessor.h>
2222
#include <ydb/public/sdk/cpp/client/draft/ydb_scripting.h>
2323
#include <ydb/public/sdk/cpp/client/ydb_result/result.h>
24-
#include <ydb/core/kqp/provider/yql_kikimr_results.h>
2524
#include <ydb/core/ydb_convert/ydb_convert.h>
2625
#include <ydb/mvp/core/core_ydb.h>
2726
#include <ydb/mvp/core/core_ydb_impl.h>

ydb/mvp/meta/meta_cp_databases.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <ydb/public/api/grpc/ydb_scripting_v1.grpc.pb.h>
1515
#include <ydb/public/api/protos/ydb_discovery.pb.h>
1616
#include <ydb/public/sdk/cpp/client/ydb_result/result.h>
17-
#include <ydb/core/kqp/provider/yql_kikimr_results.h>
1817
#include <ydb/core/ydb_convert/ydb_convert.h>
1918
#include <ydb/mvp/core/core_ydb.h>
2019
#include <ydb/mvp/core/core_ydb_impl.h>

ydb/mvp/meta/meta_db_clusters.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <ydb/public/api/grpc/ydb_scripting_v1.grpc.pb.h>
1414
#include <ydb/public/api/protos/ydb_discovery.pb.h>
1515
#include <ydb/public/sdk/cpp/client/ydb_result/result.h>
16-
#include <ydb/core/kqp/provider/yql_kikimr_results.h>
1716
#include <ydb/core/ydb_convert/ydb_convert.h>
1817
#include <ydb/mvp/core/core_ydb.h>
1918
#include <ydb/mvp/core/core_ydb_impl.h>

ydb/services/metadata/manager/abstract.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44

55
#include <ydb/core/protos/kqp_physical.pb.h>
66
#include <ydb/core/tx/locks/sys_tables.h>
7+
78
#include <ydb/library/accessor/accessor.h>
89
#include <ydb/library/aclib/aclib.h>
9-
#include <ydb/library/conclusion/status.h>
10+
#include <ydb/library/actors/core/actorsystem.h>
1011
#include <ydb/library/conclusion/result.h>
11-
12+
#include <ydb/library/conclusion/status.h>
1213
#include <ydb/services/metadata/abstract/kqp_common.h>
1314
#include <ydb/services/metadata/abstract/parsing.h>
15+
#include <ydb/services/metadata/manager/modification.h>
1416

1517
#include <library/cpp/threading/future/core/future.h>
16-
#include <ydb/library/actors/core/actorsystem.h>
1718
#include <yql/essentials/sql/settings/translation_settings.h>
1819

1920
namespace NKikimr::NMetadata::NModifications {
@@ -168,6 +169,11 @@ class IObjectOperationsManager: public IOperationsManager {
168169
const TInternalModificationContext& context, const TAlterOperationContext& alterContext) const {
169170
return DoPrepareObjectsBeforeModification(std::move(patchedObjects), controller, context, alterContext);
170171
}
172+
173+
virtual std::vector<TModificationStage::TPtr> GetPreconditions(
174+
const std::vector<TObject>& /*objects*/, const IOperationsManager::TInternalModificationContext& /*context*/) const {
175+
return {};
176+
}
171177
};
172178

173179
class IObjectModificationCommand {

ydb/services/metadata/manager/alter.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class TUpdateObjectActor: public TModificationActor<TObject> {
1515
using TBase = TModificationActor<TObject>;
1616
protected:
1717
virtual bool ProcessPreparedObjects(NInternal::TTableRecords&& records) const override {
18-
TBase::Register(new TUpdateObjectsActor<TObject>(std::move(records), TBase::UserToken,
19-
TBase::InternalController, TBase::SessionId, TBase::TransactionId, TBase::Context.GetExternalData().GetUserToken()));
18+
TBase::Register(new TUpdateObjectsActor<TObject>(std::move(records), TBase::UserToken, TBase::InternalController, TBase::SessionId,
19+
TBase::TransactionId, TBase::Context.GetExternalData().GetUserToken(), TBase::Preconditions));
2020
return true;
2121
}
2222

@@ -33,9 +33,8 @@ class TUpsertObjectActor: public TModificationActor<TObject> {
3333
using TBase = TModificationActor<TObject>;
3434
protected:
3535
virtual bool ProcessPreparedObjects(NInternal::TTableRecords&& records) const override {
36-
TBase::Register(new TUpsertObjectsActor<TObject>(std::move(records), TBase::UserToken,
37-
TBase::InternalController, TBase::SessionId, TBase::TransactionId,
38-
TBase::Context.GetExternalData().GetUserToken()));
36+
TBase::Register(new TUpsertObjectsActor<TObject>(std::move(records), TBase::UserToken, TBase::InternalController, TBase::SessionId,
37+
TBase::TransactionId, TBase::Context.GetExternalData().GetUserToken(), TBase::Preconditions));
3938
return true;
4039
}
4140

@@ -53,9 +52,8 @@ class TCreateObjectActor: public TModificationActor<TObject> {
5352
bool ExistingOk = false;
5453
protected:
5554
virtual bool ProcessPreparedObjects(NInternal::TTableRecords&& records) const override {
56-
TBase::Register(new TInsertObjectsActor<TObject>(std::move(records), TBase::UserToken,
57-
TBase::InternalController, TBase::SessionId, TBase::TransactionId,
58-
TBase::Context.GetExternalData().GetUserToken(), ExistingOk));
55+
TBase::Register(new TInsertObjectsActor<TObject>(std::move(records), TBase::UserToken, TBase::InternalController, TBase::SessionId,
56+
TBase::TransactionId, TBase::Context.GetExternalData().GetUserToken(), TBase::Preconditions, ExistingOk));
5957
return true;
6058
}
6159

@@ -103,8 +101,8 @@ class TDeleteObjectActor: public TModificationActor<TObject> {
103101
using TBase::TBase;
104102

105103
virtual bool ProcessPreparedObjects(NInternal::TTableRecords&& records) const override {
106-
TBase::Register(new TDeleteObjectsActor<TObject>(std::move(records), TBase::UserToken,
107-
TBase::InternalController, TBase::SessionId, TBase::TransactionId, TBase::Context.GetExternalData().GetUserToken()));
104+
TBase::Register(new TDeleteObjectsActor<TObject>(std::move(records), TBase::UserToken, TBase::InternalController, TBase::SessionId,
105+
TBase::TransactionId, TBase::Context.GetExternalData().GetUserToken(), TBase::Preconditions));
108106
return true;
109107
}
110108

ydb/services/metadata/manager/alter_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class TModificationActorImpl: public NActors::TActorBootstrapped<TModificationAc
5858
typename IObjectOperationsManager<TObject>::TPtr Manager;
5959
const IOperationsManager::TInternalModificationContext Context;
6060
std::vector<NInternal::TTableRecord> Patches;
61+
std::vector<TModificationStage::TPtr> Preconditions;
6162
NInternal::TTableRecords RestoreObjectIds;
6263
const NACLib::TUserToken UserToken = NACLib::TSystemUsers::Metadata();
6364
virtual bool PrepareRestoredObjects(std::vector<TObject>& objects) const = 0;
@@ -179,6 +180,7 @@ class TModificationActorImpl: public NActors::TActorBootstrapped<TModificationAc
179180
}
180181

181182
void Handle(typename TEvAlterPreparationFinished<TObject>::TPtr& ev) {
183+
Preconditions = Manager->GetPreconditions(ev->Get()->GetObjects(), Context);
182184
NInternal::TTableRecords records;
183185
records.InitColumns(Manager->GetSchema().GetYDBColumns());
184186
records.ReserveRows(ev->Get()->GetObjects().size());

0 commit comments

Comments
 (0)