adjust error message and add test

This commit is contained in:
Minionyh 2024-06-24 05:52:13 +00:00 committed by ob-robot
parent 790d2060f8
commit 175b976263
9 changed files with 37 additions and 29 deletions

View File

@ -74,7 +74,7 @@ int ObTableLoadRedefTable::start(const ObTableLoadRedefTableStartArg &arg,
create_table_arg.nls_formats_[ObNLSFormatEnum::NLS_TIMESTAMP] = session_info.get_local_nls_timestamp_format();
create_table_arg.nls_formats_[ObNLSFormatEnum::NLS_TIMESTAMP_TZ] = session_info.get_local_nls_timestamp_tz_format();
create_table_arg.consumer_group_id_ = THIS_WORKER.get_group_id();
create_table_arg.is_insert_overwrite_ = arg.is_insert_overwrite_;
DEBUG_SYNC(BEFORE_CREATE_HIDDEN_TABLE_IN_LOAD);
if (OB_FAIL(create_table_arg.tz_info_wrap_.deep_copy(session_info.get_tz_info_wrap()))) {
LOG_WARN("failed to deep copy tz_info_wrap", KR(ret));
} else if (OB_FAIL(ObDDLServerClient::create_hidden_table(create_table_arg, create_table_res,

View File

@ -478,6 +478,8 @@ int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_gu
return ret;
}
static const char *InsertOverwritePrefix = "insert overwrite with ";
static const char *EmptyPrefix = "";
int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_guard,
const ObTableSchema *table_schema,
const ObDirectLoadMethod::Type method,
@ -487,7 +489,8 @@ int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_gu
int ret = OB_SUCCESS;
if (OB_UNLIKELY(nullptr == table_schema ||
!ObDirectLoadMethod::is_type_valid(method) ||
!ObDirectLoadInsertMode::is_type_valid(insert_mode))) {
!ObDirectLoadInsertMode::is_type_valid(insert_mode)) ||
!ObDirectLoadMode::is_type_valid(load_mode)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid args", KR(ret), KP(table_schema), K(method), K(insert_mode));
} else {
@ -499,20 +502,22 @@ int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_gu
bool has_invisible_column = false;
bool has_unused_column = false;
// check if it is a user table
const char *tmp_prefix = ObDirectLoadMode::is_insert_overwrite(load_mode) ? InsertOverwritePrefix : EmptyPrefix;
if (!table_schema->is_user_table()) {
ret = OB_NOT_SUPPORTED;
if (lib::is_oracle_mode() && table_schema->is_tmp_table()) {
LOG_WARN("direct-load does not support oracle temporary table", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support oracle temporary table");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support oracle temporary table", tmp_prefix);
} else if (table_schema->is_view_table()) {
LOG_WARN("direct-load does not support view table", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support view table");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support view table", tmp_prefix);
} else if (table_schema->is_mlog_table()) {
LOG_WARN("direct-load does not support materialized view log table", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support materialized view log table");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support materialized view log table", tmp_prefix);
} else {
LOG_WARN("direct-load does not support non-user table", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support non-user table");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support non-user table", tmp_prefix);
}
}
// check if exists full-text search index
@ -521,7 +526,7 @@ int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_gu
} else if (has_fts_index) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("direct-load does not support table has full-text search index", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support table has full-text search index");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support table has full-text search index", tmp_prefix);
}
// check if exists multi-value index
else if (OB_FAIL(table_schema->check_has_multivalue_index(schema_guard, has_multivalue_index))) {
@ -529,13 +534,13 @@ int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_gu
} else if (has_multivalue_index) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("direct-load does not support table has multi-value index", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support table has multi-value index");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support table has multi-value index", tmp_prefix);
}
// check if exists generated column
else if (OB_UNLIKELY(table_schema->has_generated_column())) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("direct-load does not support table has generated column", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support table has generated column");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support table has generated column", tmp_prefix);
}
// check if the trigger is enabled
else if (OB_FAIL(table_schema->check_has_trigger_on_table(schema_guard, trigger_enabled))) {
@ -543,7 +548,7 @@ int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_gu
} else if (trigger_enabled) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("direct-load does not support table with trigger enabled", KR(ret), K(trigger_enabled));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support table with trigger enabled");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support table with trigger enabled", tmp_prefix);
}
// check has udt column
else if (OB_FAIL(ObTableLoadSchema::check_has_udt_column(table_schema, has_udt_column))) {
@ -551,7 +556,7 @@ int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_gu
} else if (has_udt_column) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("direct-load does not support table has udt column", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support table has udt column");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support table has udt column", tmp_prefix);
}
// check has invisible column
else if (OB_FAIL(ObTableLoadSchema::check_has_invisible_column(table_schema, has_invisible_column))) {
@ -559,7 +564,7 @@ int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_gu
} else if (has_invisible_column) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("direct-load does not support table has invisible column", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support table has invisible column");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support table has invisible column", tmp_prefix);
}
// check has unused column
else if (OB_FAIL(ObTableLoadSchema::check_has_unused_column(table_schema, has_unused_column))) {
@ -567,13 +572,13 @@ int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_gu
} else if (has_unused_column) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("direct-load does not support table has unused column", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support table has unused column");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support table has unused column", tmp_prefix);
}
// check if table has mlog
else if (table_schema->has_mlog_table()) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("direct-load does not support table with materialized view log", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "direct-load does not support table with materialized view log");
FORWARD_USER_ERROR_MSG(ret, "%sdirect-load does not support table with materialized view log", tmp_prefix);
} else if (ObDirectLoadMethod::is_incremental(method)) { // incremental direct-load
uint64_t compat_version = 0;
if (!ObDirectLoadInsertMode::is_valid_for_incremental_method(insert_mode)) {
@ -607,6 +612,10 @@ int ObTableLoadService::check_support_direct_load(ObSchemaGetterGuard &schema_gu
ret = OB_NOT_SUPPORTED;
LOG_WARN("version lower than 4.3.2.0 does not support insert overwrite", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "version lower than 4.3.2.0 does not support insert overwrite");
} else if (table_schema->get_foreign_key_infos().count() > 0) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("insert overwrite with incremental direct-load does not support table with foreign keys", KR(ret));
FORWARD_USER_ERROR_MSG(ret, "insert overwrite with direct-load does not support table with foreign keys");
}
}
}

View File

@ -14198,10 +14198,6 @@ int ObDDLService::create_hidden_table(
owner_id,
trans))) {
LOG_WARN("failed to lock ddl lock", K(ret));
} else if (create_hidden_table_arg.is_insert_overwrite_ && !orig_table_schema->get_foreign_key_infos().empty()) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("insert overwrite not support foreign key", K(ret));
LOG_USER_ERROR(OB_NOT_SUPPORTED, "insert overwrite table with foreign key");
} else if (OB_FAIL(create_user_hidden_table(
*orig_table_schema,
new_table_schema,

View File

@ -614,6 +614,7 @@ class ObString;
ACT(AFTER_CHECK_LOG_NEED_REBUILD,)\
ACT(BEFORE_SEND_ALTER_TABLE,)\
ACT(BEFOR_EXEC_REBUILD_TASK,)\
ACT(BEFORE_CREATE_HIDDEN_TABLE_IN_LOAD,)\
ACT(MAX_DEBUG_SYNC_POINT,)
DECLARE_ENUM(ObDebugSyncPoint, debug_sync_point, OB_DEBUG_SYNC_POINT_DEF);

View File

@ -707,7 +707,6 @@ int ObCreateHiddenTableArg::assign(const ObCreateHiddenTableArg &arg)
parallelism_ = arg.parallelism_;
ddl_type_ = arg.ddl_type_;
sql_mode_ = arg.sql_mode_;
is_insert_overwrite_ = arg.is_insert_overwrite_;
for (int64_t i = 0; OB_SUCC(ret) && i < common::ObNLSFormatEnum::NLS_MAX; i++) {
nls_formats_[i].assign_ptr(arg.nls_formats_[i].ptr(), static_cast<int32_t>(arg.nls_formats_[i].length()));
}

View File

@ -1860,8 +1860,7 @@ public:
K_(ddl_stmt_str),
K_(sql_mode),
K_(tz_info_wrap),
"nls_formats", common::ObArrayWrap<common::ObString>(nls_formats_, common::ObNLSFormatEnum::NLS_MAX),
K_(is_insert_overwrite));
"nls_formats", common::ObArrayWrap<common::ObString>(nls_formats_, common::ObNLSFormatEnum::NLS_MAX));
ObCreateHiddenTableArg() :
ObDDLArg(),
tenant_id_(common::OB_INVALID_ID),
@ -1873,7 +1872,6 @@ public:
ddl_stmt_str_(),
sql_mode_(0),
tz_info_wrap_(),
is_insert_overwrite_(false),
nls_formats_{}
{}
~ObCreateHiddenTableArg()
@ -1889,7 +1887,6 @@ public:
dest_tenant_id_ = common::OB_INVALID_ID;
session_id_ = common::OB_INVALID_ID;
ddl_type_ = share::DDL_INVALID;
is_insert_overwrite_ = false;
ddl_stmt_str_.reset();
sql_mode_ = 0;
}
@ -1907,7 +1904,6 @@ public:
common::ObArenaAllocator allocator_;
common::ObTimeZoneInfo tz_info_;
common::ObTimeZoneInfoWrap tz_info_wrap_;
bool is_insert_overwrite_;
common::ObString nls_formats_[common::ObNLSFormatEnum::NLS_MAX];
};

View File

@ -3062,7 +3062,7 @@ int ObStaticEngineCG::generate_insert_with_das(ObLogInsert &op, ObTableInsertSpe
LOG_WARN("check is insert overwrite failed", K(ret));
} else if (is_insert_overwrite) {
ret = OB_NOT_SUPPORTED;
LOG_USER_ERROR(OB_NOT_SUPPORTED, "insert overwrite need open pdml");
LOG_USER_ERROR(OB_NOT_SUPPORTED, "please explain extended for why, insert overwrite need open pdml");
}
}

View File

@ -91,7 +91,6 @@ private:
K_(dup_action),
"method", storage::ObDirectLoadMethod::get_type_string(method_),
"insert_mode", storage::ObDirectLoadInsertMode::get_type_string(insert_mode_),
"load_mode", storage::ObDirectLoadMode::get_type_string(load_mode_),
K_(data_access_param),
K_(column_ids));
public:
@ -112,7 +111,6 @@ private:
sql::ObLoadDupActionType dup_action_;
storage::ObDirectLoadMethod::Type method_;
storage::ObDirectLoadInsertMode::Type insert_mode_;
storage::ObDirectLoadMode::Type load_mode_;
DataAccessParam data_access_param_;
ObArray<uint64_t> column_ids_;
};

View File

@ -86,10 +86,19 @@ int ObInsertResolver::resolve(const ParseNode &parse_tree)
if (OB_SUCC(ret) && 5 <= parse_tree.num_child_) {
bool overwrite = false;
if (OB_NOT_NULL(parse_tree.children_[OVERWRITE_NODE]) && 1 == parse_tree.children_[OVERWRITE_NODE]->value_) {
const uint64_t tenant_id = MTL_ID();
uint64_t data_version = 0;
if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, data_version))) {
LOG_WARN("fail to get sys tenant data version", KR(ret), K(data_version));
} else if (DATA_VERSION_4_3_2_0 > data_version) {
ret = OB_NOT_SUPPORTED;
LOG_USER_ERROR(OB_NOT_SUPPORTED, "Tenant data version is less than 4.3.2, and the insert overwrite statement is");
} else {
overwrite = true;
insert_stmt->set_overwrite(overwrite);
}
}
}
// resolve outline data hints first
if (OB_SUCC(ret)) {