BugFix:Add Column 'Expression' to 'show index from'
This commit is contained in:
parent
294157b1ca
commit
253e483237
@ -426,6 +426,11 @@ int ObTableIndex::add_rowkey_indexes(const ObTableSchema &table_schema,
|
||||
cells[cell_idx].set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
break;
|
||||
}
|
||||
//expression
|
||||
case OB_APP_MIN_COLUMN_ID + 17: {
|
||||
cells[cell_idx].set_null();
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -757,6 +762,21 @@ int ObTableIndex::add_normal_index_column(const ObString &database_name,
|
||||
cells[cell_idx].set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
break;
|
||||
}
|
||||
//expression
|
||||
case OB_APP_MIN_COLUMN_ID + 17: {
|
||||
if (column_schema->is_func_idx_column()) {
|
||||
ObString col_def;
|
||||
if (OB_FAIL(column_schema->get_cur_default_value().get_string(col_def))) {
|
||||
LOG_WARN("get generated column definition failed", K(ret), K(*column_schema));
|
||||
} else {
|
||||
cells[cell_idx].set_varchar(col_def);
|
||||
cells[cell_idx].set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
}
|
||||
} else {
|
||||
cells[cell_idx].set_null();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
SERVER_LOG(WARN, "invalid column id", K(ret), K(cell_idx),
|
||||
@ -941,6 +961,11 @@ int ObTableIndex::add_fulltext_index_column(const ObString &database_name,
|
||||
cells[cell_idx].set_varchar(is_visible);
|
||||
cells[cell_idx].set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
break;
|
||||
}
|
||||
//expression
|
||||
case OB_APP_MIN_COLUMN_ID + 17: {
|
||||
cells[cell_idx].set_null();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
|
@ -898,6 +898,21 @@ int ObInnerTableSchema::tenant_virtual_table_index_schema(ObTableSchema &table_s
|
||||
is_visible_default,
|
||||
is_visible_default); //default_value
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("expression", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
OB_MAX_DEFAULT_VALUE_LENGTH, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
table_schema.set_index_using_type(USING_HASH);
|
||||
table_schema.set_row_store_type(ENCODING_ROW_STORE);
|
||||
table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL);
|
||||
|
@ -5395,6 +5395,21 @@ int ObInnerTableSchema::tenant_virtual_table_index_agent_schema(ObTableSchema &t
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("EXPRESSION", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_UTF8MB4_BIN, //column_collation_type
|
||||
OB_MAX_DEFAULT_VALUE_LENGTH, //column_length
|
||||
2, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
table_schema.set_index_using_type(USING_HASH);
|
||||
table_schema.set_row_store_type(ENCODING_ROW_STORE);
|
||||
table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL);
|
||||
|
@ -5630,6 +5630,7 @@ def_table_schema(
|
||||
('comment', 'varchar:MAX_TABLE_COMMENT_LENGTH', 'true'),
|
||||
('index_comment', 'varchar:MAX_TABLE_COMMENT_LENGTH', 'false', ''),
|
||||
('is_visible', 'varchar:MAX_COLUMN_YES_NO_LENGTH', 'false', ''),
|
||||
('expression', 'varchar:OB_MAX_DEFAULT_VALUE_LENGTH', 'true')
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -2732,9 +2732,9 @@ DEFINE_SHOW_CLAUSE_SET(SHOW_CREATE_TABLEGROUP,
|
||||
NULL);
|
||||
DEFINE_SHOW_CLAUSE_SET(SHOW_INDEXES,
|
||||
NULL,
|
||||
"SELECT `TABLE` AS `Table`, NON_UNIQUE AS Non_unique, KEY_NAME AS Key_name, SEQ_IN_INDEX AS Seq_in_index, COLUMN_NAME AS Column_name, COLLATION AS Collation, CARDINALITY AS Cardinality, SUB_PART AS Sub_part, PACKED AS Packed, `NULL` AS `Null`, INDEX_TYPE AS Index_type, `COMMENT` AS `Comment`, INDEX_COMMENT AS Index_comment, IS_VISIBLE AS Visible FROM %s.%s where table_id = %ld",
|
||||
"SELECT `TABLE` AS `Table`, NON_UNIQUE AS Non_unique, KEY_NAME AS Key_name, SEQ_IN_INDEX AS Seq_in_index, COLUMN_NAME AS Column_name, COLLATION AS Collation, CARDINALITY AS Cardinality, SUB_PART AS Sub_part, PACKED AS Packed, `NULL` AS `Null`, INDEX_TYPE AS Index_type, `COMMENT` AS `Comment`, INDEX_COMMENT AS Index_comment, IS_VISIBLE AS Visible, EXPRESSION AS Expression FROM %s.%s where table_id = %ld",
|
||||
R"(SELECT "TABLE" AS "TABLE", "NON_UNIQUE" AS "NON_UNIQUE", "KEY_NAME" AS "KEY_NAME", "SEQ_IN_INDEX" AS "SEQ_IN_INDEX", "COLUMN_NAME" AS "COLUMN_NAME", "COLLATION" AS "COLLATION", "CARDINALITY" AS "CARDINALITY", "SUB_PART" AS "SUB_PART", "PACKED" AS "PACKED", "NULL" AS "NULL", "INDEX_TYPE" AS "INDEX_TYPE", "COMMENT" AS "COMMENT", )"
|
||||
R"(INDEX_COMMENT" AS "INDEX_COMMENT", "IS_VISIBLE" AS "VISIBLE" FROM %s.%s WHERE TABLE_ID = %ld")",
|
||||
R"(INDEX_COMMENT" AS "INDEX_COMMENT", "IS_VISIBLE" AS "VISIBLE", "EXPRESSION" AS "EXPRESSION" FROM %s.%s WHERE TABLE_ID = %ld")",
|
||||
NULL);
|
||||
|
||||
DEFINE_SHOW_CLAUSE_SET(SHOW_TRACE,
|
||||
|
@ -65,9 +65,9 @@ create table t_global_index (pk int primary key) partition by hash(pk) partition
|
||||
insert into t_global_index values (1), (2), (3);
|
||||
create index index1 on t_global_index (pk) global;
|
||||
show index from t_global_index;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible
|
||||
t_global_index 0 PRIMARY 1 pk A NULL NULL NULL BTREE available YES
|
||||
t_global_index 1 index1 1 pk A NULL NULL NULL BTREE available YES
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
|
||||
t_global_index 0 PRIMARY 1 pk A NULL NULL NULL BTREE available YES NULL
|
||||
t_global_index 1 index1 1 pk A NULL NULL NULL BTREE available YES NULL
|
||||
begin;
|
||||
insert into xm_test_t1 values (7, 1);
|
||||
select * from xm_test_t1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user