Skip to content

Commit 99dd9ed

Browse files
authored
Stable-24-3-11: Remove old restriction: keys with Uint8 column values >127 are currently prohibited (#11886) (#12866)
1 parent 45446b8 commit 99dd9ed

File tree

7 files changed

+59
-37
lines changed

7 files changed

+59
-37
lines changed

ydb/core/engine/mkql_engine_flat.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -577,15 +577,6 @@ class TEngineFlat : public IEngineFlat {
577577
AddError("Validate", __LINE__, "Bad shard program: key size is greater that specified in schema");
578578
return false;
579579
}
580-
for (size_t i = 0; i < desc.Range.From.size(); ++i) {
581-
if (desc.KeyColumnTypes[i].GetTypeId() != NScheme::NTypeIds::Uint8)
582-
continue;
583-
const TCell& c = desc.Range.From[i];
584-
if (!c.IsNull() && c.AsValue<ui8>() > 127) {
585-
AddError("Validate", __LINE__, "Bad shard program: keys with Uint8 column values >127 are currently prohibited");
586-
return false;
587-
}
588-
}
589580
}
590581
return true;
591582
}

ydb/core/kqp/ut/indexes/kqp_indexes_ut.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5293,6 +5293,64 @@ R"([[#;#;["Primary1"];[41u]];[["Secondary2"];[2u];["Primary2"];[42u]];[["Seconda
52935293
UNIT_ASSERT_VALUES_EQUAL(reads[0]["columns"].GetArraySafe().size(), 1);
52945294
}
52955295
}
5296+
5297+
Y_UNIT_TEST(Uint8Index) {
5298+
TKikimrRunner kikimr;
5299+
auto db = kikimr.GetTableClient();
5300+
auto session = db.CreateSession().GetValueSync().GetSession();
5301+
5302+
{
5303+
const TString createTableSql = R"(CREATE TABLE `/Root/table` (
5304+
key Uint8,
5305+
value Uint8,
5306+
PRIMARY KEY (key)
5307+
);)";
5308+
5309+
auto result = session.ExecuteSchemeQuery(createTableSql).GetValueSync();
5310+
UNIT_ASSERT_C(result.GetIssues().Empty(), result.GetIssues().ToString());
5311+
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::SUCCESS);
5312+
}
5313+
5314+
{
5315+
const TString upsertSql(Q_(R"(
5316+
UPSERT INTO `/Root/table` (key, value) VALUES
5317+
(0, 1),
5318+
(10, 11),
5319+
(100, 101),
5320+
(200, 201);
5321+
)"));
5322+
5323+
auto result = session.ExecuteDataQuery(upsertSql, TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()).ExtractValueSync();
5324+
UNIT_ASSERT(result.IsSuccess());
5325+
}
5326+
5327+
{
5328+
const TString createTableSql = R"(ALTER TABLE `/Root/table`
5329+
ADD INDEX value_index GLOBAL ON (value)
5330+
)";
5331+
5332+
auto result = session.ExecuteSchemeQuery(createTableSql).GetValueSync();
5333+
UNIT_ASSERT_C(result.GetIssues().Empty(), result.GetIssues().ToString());
5334+
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::SUCCESS);
5335+
}
5336+
5337+
{
5338+
const auto& yson = ReadTablePartToYson(session, "/Root/table");
5339+
const TString expected = R"([[[0u];[1u]];[[10u];[11u]];[[100u];[101u]];[[200u];[201u]]])";
5340+
UNIT_ASSERT_VALUES_EQUAL(yson, expected);
5341+
}
5342+
5343+
{
5344+
const TString selectSql(Q1_(R"(
5345+
SELECT * FROM `/Root/table` VIEW value_index WHERE value > 100;
5346+
)"));
5347+
5348+
auto result = session.ExecuteDataQuery(selectSql, TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()).ExtractValueSync();
5349+
UNIT_ASSERT_C(result.GetIssues().Empty(), result.GetIssues().ToString());
5350+
UNIT_ASSERT(result.IsSuccess());
5351+
UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), R"([[[100u];[101u]];[[200u];[201u]]])");
5352+
}
5353+
}
52965354
}
52975355

52985356
}

ydb/core/tx/datashard/datashard_change_receiving.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,6 @@ class TDataShard::TTxApplyChangeRecords: public TTransactionBase<TDataShard> {
227227
for (size_t i = 0; i < tableInfo.KeyColumnTypes.size(); ++i) {
228228
const auto type = tableInfo.KeyColumnTypes.at(i);
229229
const auto& cell = KeyCells.GetCells().at(i);
230-
231-
if (type.GetTypeId() == NScheme::NTypeIds::Uint8 && !cell.IsNull() && cell.AsValue<ui8>() > 127) {
232-
AddRecordStatus(ctx, record.GetOrder(), NKikimrChangeExchange::TEvStatus::STATUS_REJECT,
233-
NKikimrChangeExchange::TEvStatus::REASON_SCHEME_ERROR,
234-
"Keys with Uint8 column values >127 are currently prohibited");
235-
return false;
236-
}
237-
238230
keyBytes += cell.Size();
239231
Key.emplace_back(cell.AsRef(), type);
240232
}

ydb/core/tx/datashard/datashard_common_upload.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ bool TCommonUploadOps<TEvRequest, TEvResponse>::Execute(TDataShard* self, TTrans
129129
ui64 keyBytes = 0;
130130
for (const auto& kt : tableInfo.KeyColumnTypes) {
131131
const TCell& c = keyCells.GetCells()[ki];
132-
if (kt.GetTypeId() == NScheme::NTypeIds::Uint8 && !c.IsNull() && c.AsValue<ui8>() > 127) {
133-
SetError(NKikimrTxDataShard::TError::BAD_ARGUMENT, "Keys with Uint8 column values >127 are currently prohibited");
134-
return true;
135-
}
136-
137132
keyBytes += c.Size();
138133
key.emplace_back(TRawTypeValue(c.AsRef(), kt));
139134
++ki;

ydb/core/tx/datashard/datashard_direct_erase.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,6 @@ TDirectTxErase::EStatus TDirectTxErase::CheckedExecute(
103103
for (size_t ki : xrange(tableInfo.KeyColumnTypes.size())) {
104104
const auto& kt = tableInfo.KeyColumnTypes[ki];
105105
const TCell& cell = keyCells.GetCells()[ki];
106-
107-
if (kt.GetTypeId() == NScheme::NTypeIds::Uint8 && !cell.IsNull() && cell.AsValue<ui8>() > 127) {
108-
status = NKikimrTxDataShard::TEvEraseRowsResponse::BAD_REQUEST;
109-
error = "Keys with Uint8 column values >127 are currently prohibited";
110-
return EStatus::Error;
111-
}
112-
113106
keyBytes += cell.Size();
114107
key.emplace_back(TRawTypeValue(cell.AsRef(), kt));
115108
}

ydb/core/tx/datashard/datashard_write_operation.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ std::tuple<NKikimrTxDataShard::TError::EKind, TString> TValidatedWriteTxOperatio
144144
{
145145
ui64 keyBytes = 0;
146146
for (ui16 keyColIdx = 0; keyColIdx < tableInfo.KeyColumnIds.size(); ++keyColIdx) {
147-
const auto& cellType = tableInfo.KeyColumnTypes[keyColIdx];
148147
const TCell& cell = Matrix.GetCell(rowIdx, keyColIdx);
149-
if (cellType.GetTypeId() == NScheme::NTypeIds::Uint8 && !cell.IsNull() && cell.AsValue<ui8>() > 127)
150-
return {NKikimrTxDataShard::TError::BAD_ARGUMENT, TStringBuilder() << "Keys with Uint8 column values >127 are currently prohibited"};
151-
152148
keyBytes += cell.IsNull() ? 1 : cell.Size();
153149
}
154150

ydb/services/ydb/ydb_bulk_upsert_ut.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -961,10 +961,7 @@ Y_UNIT_TEST_SUITE(YdbTableBulkUpsert) {
961961
for (ui32 i = 0; i < 256; ++i) {
962962
{
963963
auto res = TestUpsertRow(client, "/Root/ui8", i, 42);
964-
if (i <= 127)
965-
UNIT_ASSERT_VALUES_EQUAL(res.GetStatus(), EStatus::SUCCESS);
966-
else
967-
UNIT_ASSERT_VALUES_EQUAL(res.GetStatus(), EStatus::BAD_REQUEST);
964+
UNIT_ASSERT_VALUES_EQUAL(res.GetStatus(), EStatus::SUCCESS);
968965
}
969966

970967
{

0 commit comments

Comments
 (0)