Skip to content

Commit 6f762e3

Browse files
committed
Fixes
1 parent 2f27c65 commit 6f762e3

File tree

6 files changed

+66
-3
lines changed

6 files changed

+66
-3
lines changed

ydb/core/kqp/provider/yql_kikimr_type_ann.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,17 @@ class TKiSourceTypeAnnotationTransformer : public TKiSourceVisitorTransformer {
164164

165165
auto listSelectType = ctx.MakeType<TListExprType>(selectType);
166166

167+
if (!SessionCtx->Config().FeatureFlags.GetEnableShowCreate()) {
168+
for (auto setting : readTable.Settings()) {
169+
auto name = setting.Name().Value();
170+
if (name == "showCreateTable") {
171+
ctx.AddError(TIssue(ctx.GetPosition(node.Pos()),
172+
TStringBuilder() << "SHOW CREATE statement is not supported"));
173+
return TStatus::Error;
174+
}
175+
}
176+
}
177+
167178
TTypeAnnotationNode::TListType children;
168179
children.push_back(node.World().Ref().GetTypeAnn());
169180
children.push_back(listSelectType);

ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2762,7 +2762,7 @@ Y_UNIT_TEST_SUITE(KqpQueryService) {
27622762
}
27632763

27642764
Y_UNIT_TEST(ShowCreateTable) {
2765-
auto serverSettings = TKikimrSettings();
2765+
auto serverSettings = TKikimrSettings().SetEnableShowCreate(true);
27662766

27672767
TKikimrRunner kikimr(serverSettings);
27682768
auto db = kikimr.GetQueryClient();
@@ -2793,6 +2793,50 @@ Y_UNIT_TEST_SUITE(KqpQueryService) {
27932793
}
27942794
}
27952795

2796+
Y_UNIT_TEST(ShowCreateTableDisable) {
2797+
auto serverSettings = TKikimrSettings().SetEnableShowCreate(false);
2798+
2799+
TKikimrRunner kikimr(serverSettings);
2800+
auto db = kikimr.GetQueryClient();
2801+
auto session = db.GetSession().GetValueSync().GetSession();
2802+
2803+
{
2804+
auto result = session.ExecuteQuery(R"(
2805+
CREATE TABLE test_show_create (
2806+
Key Uint32,
2807+
Value Uint32,
2808+
PRIMARY KEY (Key)
2809+
);
2810+
)", TTxControl::NoTx()).ExtractValueSync();
2811+
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
2812+
}
2813+
2814+
{
2815+
auto result = session.ExecuteQuery(R"(
2816+
SHOW CREATE TABLE `/Root/test_show_create`;
2817+
)", TTxControl::NoTx()).ExtractValueSync();
2818+
UNIT_ASSERT(!result.IsSuccess());
2819+
2820+
UNIT_ASSERT_VALUES_EQUAL("<main>: Error: Type annotation, code: 1030\n <main>:2:35: Error: At function: KiReadTable!\n <main>:2:35: Error: SHOW CREATE statement is not supported\n",
2821+
result.GetIssues().ToString());
2822+
}
2823+
}
2824+
2825+
Y_UNIT_TEST(ShowCreateTableNotSuccess) {
2826+
auto serverSettings = TKikimrSettings().SetEnableShowCreate(true);
2827+
2828+
TKikimrRunner kikimr(serverSettings);
2829+
auto db = kikimr.GetQueryClient();
2830+
auto session = db.GetSession().GetValueSync().GetSession();
2831+
2832+
{
2833+
auto result = session.ExecuteQuery(R"(
2834+
SHOW CREATE TABLE test_show_create;
2835+
)", TTxControl::NoTx()).ExtractValueSync();
2836+
UNIT_ASSERT(!result.IsSuccess());
2837+
}
2838+
}
2839+
27962840
Y_UNIT_TEST(DdlCache) {
27972841
NKikimrConfig::TAppConfig appConfig;
27982842
auto setting = NKikimrKqp::TKqpSetting();

ydb/core/protos/feature_flags.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,5 @@ message TFeatureFlags {
196196
optional bool EnableChangefeedsImport = 170 [default = false];
197197
optional bool EnablePermissionsExport = 171 [default = false];
198198
optional bool EnableDataErasure = 172 [default = false];
199+
optional bool EnableShowCreate = 173 [default = false];
199200
}

ydb/core/sys_view/show_create/show_create.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,21 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
4949

5050
private:
5151
void StartScan() {
52+
if (!AppData()->FeatureFlags.GetEnableShowCreate()) {
53+
ReplyErrorAndDie(Ydb::StatusIds::SCHEME_ERROR,
54+
TStringBuilder() << "Sys view is not supported: " << ShowCreateName);
55+
}
56+
5257
const auto& cellsFrom = TableRange.From.GetCells();
5358

5459
if (cellsFrom.size() != 2 || cellsFrom[0].IsNull() || cellsFrom[1].IsNull()) {
5560
ReplyErrorAndDie(Ydb::StatusIds::SCHEME_ERROR, "Invalid read key");
5661
}
5762

58-
if (!TableRange.Point && !TableRange.To.GetCells().empty()) {
63+
if (!TableRange.To.GetCells().empty()) {
5964
const auto& cellsTo = TableRange.To.GetCells();
6065
if (cellsTo.size() != 2 || cellsTo[0].IsNull() || cellsTo[1].IsNull()) {
61-
ReplyErrorAndDie(Ydb::StatusIds::SCHEME_ERROR, "Invalid table range");
66+
ReplyErrorAndDie(Ydb::StatusIds::SCHEME_ERROR, "Invalid read key");
6267
}
6368

6469
if (cellsFrom[0].AsBuf() != cellsTo[0].AsBuf() || cellsFrom[1].AsBuf() != cellsTo[1].AsBuf()) {

ydb/core/sys_view/ut_common.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ TTestEnv::TTestEnv(ui32 staticNodes, ui32 dynamicNodes, const TTestEnvSettings&
5252
Settings->SetEnableDbCounters(settings.EnableSVP);
5353
Settings->SetEnableForceFollowers(settings.EnableForceFollowers);
5454
Settings->SetEnableTablePgTypes(true);
55+
Settings->SetEnableShowCreate(true);
5556

5657
NKikimrConfig::TAppConfig appConfig;
5758
*appConfig.MutableFeatureFlags() = Settings->FeatureFlags;

ydb/core/testlib/basics/feature_flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class TTestFeatureFlagsHolder {
7676
FEATURE_FLAG_SETTER(EnableStrictUserManagement)
7777
FEATURE_FLAG_SETTER(EnableDatabaseAdmin)
7878
FEATURE_FLAG_SETTER(EnablePermissionsExport)
79+
FEATURE_FLAG_SETTER(EnableShowCreate)
7980

8081
#undef FEATURE_FLAG_SETTER
8182
};

0 commit comments

Comments
 (0)