[CP] fix: add defensive code for table api rowkey update

This commit is contained in:
obdev
2023-02-07 00:35:43 +08:00
committed by ob-robot
parent f981449258
commit 822aaaf7f2
2 changed files with 13 additions and 0 deletions

View File

@ -364,6 +364,16 @@ TEST_F(TestBatchExecute, all_single_operation)
ASSERT_EQ(OB_SUCCESS, r.get_entity(result_entity)); ASSERT_EQ(OB_SUCCESS, r.get_entity(result_entity));
ASSERT_TRUE(result_entity->is_empty()); ASSERT_TRUE(result_entity->is_empty());
} }
// update rowkey column
{
entity->reset();
ASSERT_EQ(OB_SUCCESS, entity->add_rowkey_value(key));
value.set_varchar(c3_value);
value.set_collation_type(CS_TYPE_UTF8MB4_GENERAL_CI);
ASSERT_EQ(OB_SUCCESS, entity->set_property(C1, value));
ObTableOperation table_operation = ObTableOperation::update(*entity);
ASSERT_EQ(OB_NOT_SUPPORTED, table_->execute(table_operation, r));
}
// replace C3 // replace C3
{ {
entity->reset(); entity->reset();

View File

@ -364,6 +364,9 @@ int ObTableCtx::adjust_properties()
LOG_WARN("fail to get column schema", K(ret), K(col_name)); LOG_WARN("fail to get column schema", K(ret), K(col_name));
} else if (is_get) { } else if (is_get) {
// do nothing // do nothing
} else if (col_schema->is_rowkey_column()) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("property should not be rowkey column", K(ret), K(prop_names), K(i));
} else if (OB_FAIL(adjust_column(*col_schema, prop_obj))) { } else if (OB_FAIL(adjust_column(*col_schema, prop_obj))) {
LOG_WARN("fail to adjust column", K(ret), K(prop_obj)); LOG_WARN("fail to adjust column", K(ret), K(prop_obj));
} }