HangyuanLiu commented on a change in pull request #4858:
URL: https://github.com/apache/incubator-doris/pull/4858#discussion_r521182314
##########
File path: be/src/exec/schema_scanner/schema_columns_scanner.cpp
##########
@@ -250,20 +265,33 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple,
MemPool *pool) {
memcpy(str_slot->ptr, buffer.c_str(), str_slot->len);
}
// CHARACTER_MAXIMUM_LENGTH
+ // For string columns, the maximum length in characters.
{
- tuple->set_null(_tuple_desc->slots()[8]->null_indicator_offset());
+ int data_type =
_desc_result.columns[_column_index].columnDesc.columnType;
+ if (data_type == TPrimitiveType::VARCHAR || data_type ==
TPrimitiveType::CHAR) {
+ void *slot =
tuple->get_slot(_tuple_desc->slots()[8]->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()[8]->null_indicator_offset());
+ }
+ } else {
+ tuple->set_null(_tuple_desc->slots()[8]->null_indicator_offset());
+ }
}
// CHARACTER_OCTET_LENGTH
+ // For string columns, the maximum length in bytes.
{
int data_type =
_desc_result.columns[_column_index].columnDesc.columnType;
if (data_type == TPrimitiveType::VARCHAR || data_type ==
TPrimitiveType::CHAR) {
void *slot =
tuple->get_slot(_tuple_desc->slots()[9]->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;
+ *str_slot =
_desc_result.columns[_column_index].columnDesc.columnLength * 4;
Review comment:
For mysql-compatible purposes, we need to multiply this by 4.
According to
https://dev.mysql.com/doc/refman/8.0/en/information-schema-columns-table.html.
CHARACTER_OCTET_LENGTH stands for maximum length in **bytes**, while
CHARACTER_MAXIMUM_LENGTH stands for maximum length in **characters**
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]