fix bug when load data into table partitioned by columns containing auto-inc value
This commit is contained in:
@ -1447,7 +1447,11 @@ int ObAutoincrementService::calc_prev_value(const uint64_t max_value,
|
||||
if (max_value <= offset) {
|
||||
prev_value = max_value;
|
||||
} else {
|
||||
prev_value = ((max_value - offset) / increment) * increment + offset;
|
||||
if (0 == increment) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
} else {
|
||||
prev_value = ((max_value - offset) / increment) * increment + offset;
|
||||
}
|
||||
}
|
||||
LOG_INFO("out of range for column. calc prev value",
|
||||
K(prev_value), K(max_value), K(offset), K(increment));
|
||||
|
@ -1063,7 +1063,8 @@ int ObLoadDataSPImpl::exec_shuffle(int64_t task_id, ObShuffleTaskHandle *handle)
|
||||
} else if (OB_FAIL(handle->generator.gen_insert_values(insert_values, str_buf))) {
|
||||
LOG_WARN("fail to generate insert values", K(ret));
|
||||
} else if (nullptr == handle->calc_tablet_id_expr) {
|
||||
tablet_id = handle->datafrag_mgr.get_tablet_ids().at(0);
|
||||
int64_t idx = task_id % handle->datafrag_mgr.get_tablet_ids().count();
|
||||
tablet_id = handle->datafrag_mgr.get_tablet_ids().at(idx);
|
||||
} else {
|
||||
for (int i = 0; i < handle->parser.get_fields_per_line().count(); ++i) {
|
||||
ObCSVGeneralParser::FieldValue &str_v = handle->parser.get_fields_per_line().at(i);
|
||||
@ -2568,6 +2569,14 @@ int ObLoadDataSPImpl::ToolBox::build_calc_partid_expr(ObExecContext &ctx,
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
bool part_key_has_autoinc = false;
|
||||
OZ (insert_stmt->part_key_has_auto_inc(part_key_has_autoinc));
|
||||
if (part_key_has_autoinc) {
|
||||
calc_tablet_id_expr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOG_DEBUG("LOAD DATA check insert info",
|
||||
K(column_convert_exprs), K(column_exprs), KPC(calc_partid_expr),
|
||||
|
Reference in New Issue
Block a user