@@ -109,12 +109,12 @@ class TAlterTableRPC : public TRpcSchemeRequestActor<TAlterTableRPC, TEvAlterTab
109
109
break ;
110
110
111
111
case EOp::Attribute:
112
- PrepareAlterUserAttrubutes ();
112
+ case EOp::AddChangefeed:
113
+ case EOp::DropChangefeed:
114
+ GetProxyServices ();
113
115
break ;
114
116
115
- case EOp::AddChangefeed:
116
117
case EOp::DropIndex:
117
- case EOp::DropChangefeed:
118
118
case EOp::RenameIndex:
119
119
AlterTable (ctx);
120
120
break ;
@@ -197,7 +197,7 @@ class TAlterTableRPC : public TRpcSchemeRequestActor<TAlterTableRPC, TEvAlterTab
197
197
Navigate (msg->Services .SchemeCache , ctx);
198
198
}
199
199
200
- void PrepareAlterUserAttrubutes () {
200
+ void GetProxyServices () {
201
201
using namespace NTxProxy ;
202
202
Send (MakeTxProxyID (), new TEvTxUserProxy::TEvGetProxyServicesRequest);
203
203
}
@@ -222,13 +222,38 @@ class TAlterTableRPC : public TRpcSchemeRequestActor<TAlterTableRPC, TEvAlterTab
222
222
auto ev = CreateNavigateForPath (DatabaseName);
223
223
{
224
224
auto & entry = static_cast <TEvTxProxySchemeCache::TEvNavigateKeySet*>(ev)->Request ->ResultSet .emplace_back ();
225
- entry.Operation = NSchemeCache::TSchemeCacheNavigate::OpTable;
226
225
entry.Path = paths;
227
226
}
228
227
229
228
Send (schemeCache, ev);
230
229
}
231
230
231
+ void Navigate (const TTableId& pathId, const TActorContext& ctx) {
232
+ DatabaseName = Request_->GetDatabaseName ()
233
+ .GetOrElse (DatabaseFromDomain (AppData ()));
234
+
235
+ auto ev = CreateNavigateForPath (DatabaseName);
236
+ {
237
+ auto & entry = static_cast <TEvTxProxySchemeCache::TEvNavigateKeySet*>(ev)->Request ->ResultSet .emplace_back ();
238
+ entry.RequestType = NSchemeCache::TSchemeCacheNavigate::TEntry::ERequestType::ByTableId;
239
+ entry.TableId = pathId;
240
+ entry.ShowPrivatePath = true ;
241
+ entry.Operation = NSchemeCache::TSchemeCacheNavigate::OpList;
242
+ }
243
+
244
+ Send (MakeSchemeCacheID (), ev);
245
+ }
246
+
247
+ static bool IsChangefeedOperation (EOp type) {
248
+ switch (type) {
249
+ case EOp::AddChangefeed:
250
+ case EOp::DropChangefeed:
251
+ return true ;
252
+ default :
253
+ return false ;
254
+ }
255
+ }
256
+
232
257
void Handle (TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr& ev, const TActorContext& ctx) {
233
258
TXLOG_D (" Handle TEvTxProxySchemeCache::TEvNavigateKeySetResult"
234
259
<< " , errors# " << ev->Get ()->Request .Get ()->ErrorCount );
@@ -251,13 +276,48 @@ class TAlterTableRPC : public TRpcSchemeRequestActor<TAlterTableRPC, TEvAlterTab
251
276
return Reply (Ydb::StatusIds::SCHEME_ERROR, ctx);
252
277
}
253
278
279
+ Y_ABORT_UNLESS (!resp->ResultSet .empty ());
280
+ const auto & entry = resp->ResultSet .back ();
281
+
282
+ switch (entry.Kind ) {
283
+ case NSchemeCache::TSchemeCacheNavigate::KindTable:
284
+ case NSchemeCache::TSchemeCacheNavigate::KindColumnTable:
285
+ case NSchemeCache::TSchemeCacheNavigate::KindExternalTable:
286
+ case NSchemeCache::TSchemeCacheNavigate::KindExternalDataSource:
287
+ case NSchemeCache::TSchemeCacheNavigate::KindView:
288
+ break ; // table
289
+ case NSchemeCache::TSchemeCacheNavigate::KindIndex:
290
+ if (IsChangefeedOperation (OpType)) {
291
+ break ;
292
+ }
293
+ [[fallthrough]];
294
+ default :
295
+ Request_->RaiseIssue (MakeIssue (NKikimrIssues::TIssuesIds::GENERIC_RESOLVE_ERROR, TStringBuilder ()
296
+ << " Unable to nagivate: " << JoinPath (entry.Path ) << " status: PathNotTable" ));
297
+ return Reply (Ydb::StatusIds::SCHEME_ERROR, ctx);
298
+ }
299
+
254
300
switch (OpType) {
255
301
case EOp::AddIndex:
256
302
return AlterTableAddIndexOp (resp, ctx);
257
303
case EOp::Attribute:
258
- Y_ABORT_UNLESS (!resp->ResultSet .empty ());
259
304
ResolvedPathId = resp->ResultSet .back ().TableId .PathId ;
260
305
return AlterTable (ctx);
306
+ case EOp::AddChangefeed:
307
+ case EOp::DropChangefeed:
308
+ if (entry.Kind != NSchemeCache::TSchemeCacheNavigate::KindIndex) {
309
+ AlterTable (ctx);
310
+ } else if (auto list = entry.ListNodeEntry ) {
311
+ if (list->Children .size () != 1 ) {
312
+ return Reply (Ydb::StatusIds::SCHEME_ERROR, ctx);
313
+ }
314
+
315
+ const auto & child = list->Children .at (0 );
316
+ AlterTable (ctx, CanonizePath (ChildPath (NKikimr::SplitPath (GetProtoRequest ()->path ()), child.Name )));
317
+ } else {
318
+ Navigate (entry.TableId , ctx);
319
+ }
320
+ break ;
261
321
default :
262
322
TXLOG_E (" Got unexpected cache response" );
263
323
return Reply (Ydb::StatusIds::INTERNAL_ERROR, ctx);
@@ -351,13 +411,14 @@ class TAlterTableRPC : public TRpcSchemeRequestActor<TAlterTableRPC, TEvAlterTab
351
411
Die (ctx);
352
412
}
353
413
354
- void AlterTable (const TActorContext &ctx) {
414
+ void AlterTable (const TActorContext &ctx, const TMaybe<TString>& overridePath = {} ) {
355
415
const auto req = GetProtoRequest ();
356
416
std::unique_ptr<TEvTxUserProxy::TEvProposeTransaction> proposeRequest = CreateProposeTransaction ();
357
417
auto modifyScheme = proposeRequest->Record .MutableTransaction ()->MutableModifyScheme ();
418
+ modifyScheme->SetAllowAccessToPrivatePaths (overridePath.Defined ());
358
419
Ydb::StatusIds::StatusCode code;
359
420
TString error;
360
- if (!BuildAlterTableModifyScheme (req, modifyScheme, Profiles, ResolvedPathId, code, error)) {
421
+ if (!BuildAlterTableModifyScheme (overridePath. GetOrElse (req-> path ()), req, modifyScheme, Profiles, ResolvedPathId, code, error)) {
361
422
NYql::TIssues issues;
362
423
issues.AddIssue (NYql::TIssue (error));
363
424
return Reply (code, issues, ctx);
0 commit comments