Skip to content

Commit

Permalink
Fix temp object out of scope issue (#8767) (#8828)
Browse files Browse the repository at this point in the history
close #8674
  • Loading branch information
ti-chi-bot authored Mar 26, 2024
1 parent 026a0ad commit 7bfb681
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
10 changes: 8 additions & 2 deletions dbms/src/Flash/Coprocessor/ArrowColCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,14 @@ void flashEnumColToArrowCol(
}
auto enum_value = static_cast<UInt64>(flash_col->getElement(i));
if (enum_value > enum_value_size)
throw TiFlashException("number of enum overflow enum boundary", Errors::Coprocessor::Internal);
TiDBEnum ti_enum(enum_value, enum_type->getNameForValue(static_cast<const DataTypeEnum16::FieldType>(enum_value)));
throw TiFlashException(
Errors::Coprocessor::Internal,
"number of enum value {} overflow enum boundary {}",
enum_value,
enum_value_size);

const auto & enum_name = enum_type->getNameForValue(static_cast<const DataTypeEnum16::FieldType>(enum_value));
TiDBEnum ti_enum(enum_value, enum_name);
dag_column.append(ti_enum);
}
}
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Flash/Coprocessor/TiDBEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ class TiDBEnum
, name(name_)
{}
UInt64 value;
const StringRef & name;
const StringRef name;
};
} // namespace DB
28 changes: 28 additions & 0 deletions tests/fullstack-test/issues/issue_8767.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2024 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

mysql> drop table if exists test.t1
mysql> create table test.t1 (COL1 enum('^YSQT0]V@9TFN>^WB6G?NG@S8>VYOM;BSC@<BCQ6'), COL2 mediumint(41) DEFAULT NULL, COL3 year(4) DEFAULT NULL, KEY `U_M_COL4` (`COL1`,`COL2`), KEY U_M_COL5 (COL3, COL2));
mysql> insert into test.t1 values ('^YSQT0]V@9TFN>^WB6G?NG@S8>VYOM;BSC@<BCQ6', -1881752, 1986);
mysql> alter table test.t1 set tiflash replica 1
func> wait_table test t1

mysql> set session tidb_isolation_read_engines='tiflash'; set tidb_enforce_mpp=1; SELECT * FROM test.t1 where col2 = -1881752 and col2 * -1881752 != 8366212;
+------------------------------------------+----------+------+
| COL1 | COL2 | COL3 |
+------------------------------------------+----------+------+
| ^YSQT0]V@9TFN>^WB6G?NG@S8>VYOM;BSC@<BCQ6 | -1881752 | 1986 |
+------------------------------------------+----------+------+

mysql> drop table if exists test.t1

0 comments on commit 7bfb681

Please sign in to comment.