fix forget to add func index column into data table when rebuild index.

This commit is contained in:
obdev
2023-08-14 07:48:35 +00:00
committed by ob-robot
parent 66b9cb880c
commit 24fb9416f3
2 changed files with 25 additions and 8 deletions

View File

@ -14384,6 +14384,8 @@ int ObDDLService::add_new_index_schema(obrpc::ObAlterTableArg &alter_table_arg,
const share::schema::ObTableSchema &orig_table_schema, const share::schema::ObTableSchema &orig_table_schema,
const ObTableSchema &hidden_table_schema, const ObTableSchema &hidden_table_schema,
ObSchemaGetterGuard &schema_guard, ObSchemaGetterGuard &schema_guard,
ObDDLOperator &ddl_operator,
common::ObMySQLTransaction &trans,
ObSArray<ObTableSchema> &new_table_schemas, ObSArray<ObTableSchema> &new_table_schemas,
ObSArray<uint64_t> &index_ids) ObSArray<uint64_t> &index_ids)
{ {
@ -14534,6 +14536,18 @@ int ObDDLService::add_new_index_schema(obrpc::ObAlterTableArg &alter_table_arg,
LOG_WARN("failed to add table schema!", K(ret)); LOG_WARN("failed to add table schema!", K(ret));
} else if (OB_FAIL(index_ids.push_back(index_schema.get_table_id()))) { } else if (OB_FAIL(index_ids.push_back(index_schema.get_table_id()))) {
LOG_WARN("failed to add new index id!", K(ret)); LOG_WARN("failed to add new index id!", K(ret));
} else {
// add new function index should add additional SYS_NC column into data table.
new_table_schema.set_in_offline_ddl_white_list(true);
for (int64_t i = 0; OB_SUCC(ret) && i < gen_columns.count(); ++i) {
ObColumnSchemaV2 *new_column_schema = gen_columns.at(i);
if (OB_ISNULL(new_column_schema)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("new column schema is null");
} else if (OB_FAIL(ddl_operator.insert_single_column(trans, new_table_schema, *new_column_schema))) {
LOG_WARN("failed to create table schema, ", K(ret));
}
}
} }
} }
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
@ -14770,15 +14784,13 @@ int ObDDLService::reconstruct_index_schema(const ObTableSchema &orig_table_schem
} }
int ObDDLService::rebuild_hidden_table_index_in_trans( int ObDDLService::rebuild_hidden_table_index_in_trans(
ObAlterTableArg &alter_table_arg, const uint64_t tenant_id,
const ObTableSchema &hidden_table_schema,
ObSchemaGetterGuard &schema_guard, ObSchemaGetterGuard &schema_guard,
ObDDLOperator &ddl_operator,
ObMySQLTransaction &trans, ObMySQLTransaction &trans,
ObSArray<ObTableSchema> &new_table_schemas) ObSArray<ObTableSchema> &new_table_schemas)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const uint64_t tenant_id = hidden_table_schema.get_tenant_id();
ObDDLOperator ddl_operator(*schema_service_, *sql_proxy_);
if (OB_FAIL(check_inner_stat())) { if (OB_FAIL(check_inner_stat())) {
LOG_WARN("variable is not init", K(ret)); LOG_WARN("variable is not init", K(ret));
} else { } else {
@ -14871,6 +14883,7 @@ int ObDDLService::rebuild_hidden_table_index(obrpc::ObAlterTableArg &alter_table
} }
} }
} else { } else {
ObDDLOperator ddl_operator(*schema_service_, *sql_proxy_);
if (OB_FAIL(col_name_map.init(*orig_table_schema, alter_table_schema))) { if (OB_FAIL(col_name_map.init(*orig_table_schema, alter_table_schema))) {
LOG_WARN("failed to init column name map", K(ret), K(alter_table_schema), KPC(orig_table_schema)); LOG_WARN("failed to init column name map", K(ret), K(alter_table_schema), KPC(orig_table_schema));
} else if (OB_FAIL(get_all_dropped_column_ids(alter_table_arg, *orig_table_schema, drop_cols_id_arr))) { } else if (OB_FAIL(get_all_dropped_column_ids(alter_table_arg, *orig_table_schema, drop_cols_id_arr))) {
@ -14889,12 +14902,14 @@ int ObDDLService::rebuild_hidden_table_index(obrpc::ObAlterTableArg &alter_table
*orig_table_schema, *orig_table_schema,
*hidden_table_schema, *hidden_table_schema,
schema_guard, schema_guard,
ddl_operator,
trans,
new_table_schemas, new_table_schemas,
index_ids))) { index_ids))) {
LOG_WARN("failed to add new index schema", K(ret)); LOG_WARN("failed to add new index schema", K(ret));
} else if (OB_FAIL(rebuild_hidden_table_index_in_trans(alter_table_arg, } else if (OB_FAIL(rebuild_hidden_table_index_in_trans(tenant_id,
*hidden_table_schema,
schema_guard, schema_guard,
ddl_operator,
trans, trans,
new_table_schemas))) { new_table_schemas))) {
LOG_WARN("failed to rebuild hidden table index in trans", K(ret)); LOG_WARN("failed to rebuild hidden table index in trans", K(ret));

View File

@ -1508,9 +1508,9 @@ private:
common::ObMySQLTransaction &trans, common::ObMySQLTransaction &trans,
common::ObSArray<uint64_t> &cst_ids); common::ObSArray<uint64_t> &cst_ids);
int rebuild_hidden_table_index_in_trans( int rebuild_hidden_table_index_in_trans(
obrpc::ObAlterTableArg &alter_table_arg, const uint64_t tenant_id,
const share::schema::ObTableSchema &hidden_table_schema,
share::schema::ObSchemaGetterGuard &schema_guard, share::schema::ObSchemaGetterGuard &schema_guard,
ObDDLOperator &ddl_operator,
common::ObMySQLTransaction &trans, common::ObMySQLTransaction &trans,
common::ObSArray<share::schema::ObTableSchema> &new_table_schemas); common::ObSArray<share::schema::ObTableSchema> &new_table_schemas);
int add_new_index_schema( int add_new_index_schema(
@ -1518,6 +1518,8 @@ private:
const share::schema::ObTableSchema &orig_table_schema, const share::schema::ObTableSchema &orig_table_schema,
const ObTableSchema &hidden_table_schema, const ObTableSchema &hidden_table_schema,
ObSchemaGetterGuard &schema_guard, ObSchemaGetterGuard &schema_guard,
ObDDLOperator &ddl_operator,
common::ObMySQLTransaction &trans,
ObSArray<ObTableSchema> &new_table_schemas, ObSArray<ObTableSchema> &new_table_schemas,
ObSArray<uint64_t> &index_ids); ObSArray<uint64_t> &index_ids);
int check_index_table_need_rebuild( int check_index_table_need_rebuild(