[Bug] Fix bug that BE will crash when querying information_schema.columns (#4511)
This bug is introduced from #4364
This commit is contained in:
@ -154,11 +154,11 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
|
||||
// set all bit to not null
|
||||
memset((void *)tuple, 0, _tuple_desc->num_null_bytes());
|
||||
|
||||
// catalog
|
||||
// TABLE_CATALOG
|
||||
{
|
||||
tuple->set_null(_tuple_desc->slots()[0]->null_indicator_offset());
|
||||
}
|
||||
// schema
|
||||
// TABLE_SCHEMA
|
||||
{
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[1]->tuple_offset());
|
||||
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
|
||||
@ -167,7 +167,7 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
|
||||
str_slot->len = db_name.size();
|
||||
memcpy(str_slot->ptr, db_name.c_str(), str_slot->len);
|
||||
}
|
||||
// table
|
||||
// TABLE_NAME
|
||||
{
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[2]->tuple_offset());
|
||||
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
|
||||
@ -175,7 +175,7 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
|
||||
str_slot->len = _table_result.tables[_table_index - 1].length();
|
||||
memcpy(str_slot->ptr, _table_result.tables[_table_index - 1].c_str(), str_slot->len);
|
||||
}
|
||||
// column
|
||||
// COLUMN_NAME
|
||||
{
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[3]->tuple_offset());
|
||||
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
|
||||
@ -252,17 +252,21 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
|
||||
tuple->set_null(_tuple_desc->slots()[11]->null_indicator_offset());
|
||||
}
|
||||
}
|
||||
// CHARACTER_SET_NAME
|
||||
// DATETIME_PRECISION
|
||||
{
|
||||
tuple->set_null(_tuple_desc->slots()[12]->null_indicator_offset());
|
||||
}
|
||||
// COLLATION_NAME
|
||||
// CHARACTER_SET_NAME
|
||||
{
|
||||
tuple->set_null(_tuple_desc->slots()[13]->null_indicator_offset());
|
||||
}
|
||||
// COLLATION_NAME
|
||||
{
|
||||
tuple->set_null(_tuple_desc->slots()[14]->null_indicator_offset());
|
||||
}
|
||||
// COLUMN_TYPE
|
||||
{
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[14]->tuple_offset());
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[15]->tuple_offset());
|
||||
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
|
||||
std::string buffer = type_to_string(_desc_result.columns[_column_index].columnDesc);
|
||||
str_slot->len = buffer.length();
|
||||
@ -271,7 +275,7 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
|
||||
}
|
||||
// COLUMN_KEY
|
||||
{
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[15]->tuple_offset());
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[16]->tuple_offset());
|
||||
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
|
||||
str_slot->len = strlen("") + 1;
|
||||
str_slot->ptr = (char *)pool->allocate(str_slot->len);
|
||||
@ -279,7 +283,7 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
|
||||
}
|
||||
// EXTRA
|
||||
{
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[16]->tuple_offset());
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[17]->tuple_offset());
|
||||
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
|
||||
str_slot->len = strlen("") + 1;
|
||||
str_slot->ptr = (char *)pool->allocate(str_slot->len);
|
||||
@ -287,7 +291,7 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
|
||||
}
|
||||
// PRIVILEGES
|
||||
{
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[17]->tuple_offset());
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[18]->tuple_offset());
|
||||
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
|
||||
str_slot->len = strlen("") + 1;
|
||||
str_slot->ptr = (char *)pool->allocate(str_slot->len);
|
||||
@ -295,7 +299,7 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
|
||||
}
|
||||
// COLUMN_COMMENT
|
||||
{
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[18]->tuple_offset());
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[19]->tuple_offset());
|
||||
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
|
||||
str_slot->ptr =
|
||||
(char *)pool->allocate(_desc_result.columns[_column_index].comment.length());
|
||||
@ -304,24 +308,32 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
|
||||
}
|
||||
// COLUMN_SIZE
|
||||
{
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[19]->tuple_offset());
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[20]->tuple_offset());
|
||||
int64_t* str_slot = reinterpret_cast<int64_t*>(slot);
|
||||
if (_desc_result.columns[_column_index].columnDesc.__isset.columnLength) {
|
||||
*str_slot = _desc_result.columns[_column_index].columnDesc.columnLength;
|
||||
} else {
|
||||
tuple->set_null(_tuple_desc->slots()[19]->null_indicator_offset());
|
||||
tuple->set_null(_tuple_desc->slots()[20]->null_indicator_offset());
|
||||
}
|
||||
}
|
||||
// DECIMAL_DIGITS
|
||||
{
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[20]->tuple_offset());
|
||||
void *slot = tuple->get_slot(_tuple_desc->slots()[21]->tuple_offset());
|
||||
int64_t* str_slot = reinterpret_cast<int64_t*>(slot);
|
||||
if (_desc_result.columns[_column_index].columnDesc.__isset.columnScale) {
|
||||
*str_slot = _desc_result.columns[_column_index].columnDesc.columnScale;
|
||||
} else {
|
||||
tuple->set_null(_tuple_desc->slots()[20]->null_indicator_offset());
|
||||
tuple->set_null(_tuple_desc->slots()[21]->null_indicator_offset());
|
||||
}
|
||||
}
|
||||
// GENERATION_EXPRESSION
|
||||
{
|
||||
tuple->set_null(_tuple_desc->slots()[23]->null_indicator_offset());
|
||||
}
|
||||
// SRS_ID
|
||||
{
|
||||
tuple->set_null(_tuple_desc->slots()[23]->null_indicator_offset());
|
||||
}
|
||||
_column_index++;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user