fix default values of start date expr in creating mview/mlog
This commit is contained in:
@ -603,12 +603,10 @@ int ObCreateMLogResolver::resolve_purge_node(
|
|||||||
} else {
|
} else {
|
||||||
ParseNode *purge_start_node = purge_type_node->children_[0];
|
ParseNode *purge_start_node = purge_type_node->children_[0];
|
||||||
ParseNode *purge_next_node = purge_type_node->children_[1];
|
ParseNode *purge_next_node = purge_type_node->children_[1];
|
||||||
if (OB_NOT_NULL(purge_start_node) || OB_NOT_NULL(purge_next_node)) {
|
|
||||||
if (OB_FAIL(resolve_purge_start_next_node(purge_start_node, purge_next_node, create_mlog_stmt))) {
|
if (OB_FAIL(resolve_purge_start_next_node(purge_start_node, purge_next_node, create_mlog_stmt))) {
|
||||||
LOG_WARN("failed to resolve purge start next node", KR(ret));
|
LOG_WARN("failed to resolve purge start next node", KR(ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
@ -625,8 +623,9 @@ int ObCreateMLogResolver::resolve_purge_start_next_node(
|
|||||||
ObCreateMLogStmt &create_mlog_stmt)
|
ObCreateMLogStmt &create_mlog_stmt)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_NOT_NULL(purge_start_node) || OB_NOT_NULL(purge_next_node)) {
|
||||||
int64_t current_time = ObTimeUtility::current_time() / 1000000L * 1000000L; // ignore micro seconds
|
int64_t current_time = ObTimeUtility::current_time() / 1000000L * 1000000L; // ignore micro seconds
|
||||||
int64_t start_time = current_time;
|
int64_t start_time = OB_INVALID_TIMESTAMP;
|
||||||
ObCreateMLogArg &create_mlog_arg = create_mlog_stmt.get_create_mlog_arg();
|
ObCreateMLogArg &create_mlog_arg = create_mlog_stmt.get_create_mlog_arg();
|
||||||
|
|
||||||
if (OB_NOT_NULL(purge_start_node)
|
if (OB_NOT_NULL(purge_start_node)
|
||||||
@ -645,22 +644,21 @@ int ObCreateMLogResolver::resolve_purge_start_next_node(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
create_mlog_arg.purge_options_.start_datetime_expr_.set_timestamp(start_time);
|
|
||||||
create_mlog_stmt.set_purge_mode(ObMLogPurgeMode::DEFERRED);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret) && OB_NOT_NULL(purge_next_node)) {
|
if (OB_SUCC(ret) && OB_NOT_NULL(purge_next_node)) {
|
||||||
int64_t next_time = 0;
|
int64_t next_time = OB_INVALID_TIMESTAMP;
|
||||||
if (OB_FAIL(ObMViewSchedJobUtils::resolve_date_expr_to_timestamp(params_,
|
if (OB_FAIL(ObMViewSchedJobUtils::resolve_date_expr_to_timestamp(params_,
|
||||||
*session_info_, *purge_next_node, *allocator_, next_time))) {
|
*session_info_, *purge_next_node, *allocator_, next_time))) {
|
||||||
LOG_WARN("failed to resolve date expr to timestamp", KR(ret));
|
LOG_WARN("failed to resolve date expr to timestamp", KR(ret));
|
||||||
} else if (next_time <= current_time) {
|
} else if (next_time < current_time) {
|
||||||
ret = OB_ERR_TIME_EARLIER_THAN_SYSDATE;
|
ret = OB_ERR_TIME_EARLIER_THAN_SYSDATE;
|
||||||
LOG_WARN("the parameter next date must evaluate to a time in the future",
|
LOG_WARN("the parameter next date must evaluate to a time in the future",
|
||||||
KR(ret), K(current_time), K(next_time));
|
KR(ret), K(current_time), K(next_time));
|
||||||
LOG_USER_ERROR(OB_ERR_TIME_EARLIER_THAN_SYSDATE, "next date");
|
LOG_USER_ERROR(OB_ERR_TIME_EARLIER_THAN_SYSDATE, "next date");
|
||||||
} else {
|
} else if (OB_INVALID_TIMESTAMP == start_time) {
|
||||||
|
start_time = next_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
ObString next_date_str(purge_next_node->str_len_, purge_next_node->str_value_);
|
ObString next_date_str(purge_next_node->str_len_, purge_next_node->str_value_);
|
||||||
if (OB_FAIL(ob_write_string(*allocator_, next_date_str,
|
if (OB_FAIL(ob_write_string(*allocator_, next_date_str,
|
||||||
create_mlog_arg.purge_options_.next_datetime_expr_))) {
|
create_mlog_arg.purge_options_.next_datetime_expr_))) {
|
||||||
@ -668,6 +666,12 @@ int ObCreateMLogResolver::resolve_purge_start_next_node(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
create_mlog_arg.purge_options_.start_datetime_expr_.set_timestamp(start_time);
|
||||||
|
create_mlog_stmt.set_purge_mode(ObMLogPurgeMode::DEFERRED);
|
||||||
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} // sql
|
} // sql
|
||||||
|
|||||||
@ -1084,7 +1084,7 @@ int ObCreateViewResolver::resolve_mv_refresh_info(ParseNode *refresh_info_node,
|
|||||||
ParseNode *start_date = refresh_interval_node->children_[0];
|
ParseNode *start_date = refresh_interval_node->children_[0];
|
||||||
ParseNode *next_date = refresh_interval_node->children_[1];
|
ParseNode *next_date = refresh_interval_node->children_[1];
|
||||||
int64_t current_time = ObTimeUtility::current_time() / 1000000L * 1000000L; // ignore micro seconds
|
int64_t current_time = ObTimeUtility::current_time() / 1000000L * 1000000L; // ignore micro seconds
|
||||||
int64_t start_time = current_time;
|
int64_t start_time = OB_INVALID_TIMESTAMP;
|
||||||
|
|
||||||
if (OB_NOT_NULL(start_date)
|
if (OB_NOT_NULL(start_date)
|
||||||
&& (T_MV_REFRESH_START_EXPR == start_date->type_)
|
&& (T_MV_REFRESH_START_EXPR == start_date->type_)
|
||||||
@ -1102,27 +1102,31 @@ int ObCreateViewResolver::resolve_mv_refresh_info(ParseNode *refresh_info_node,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
refresh_info.start_time_.set_timestamp(start_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret) && OB_NOT_NULL(next_date)) {
|
if (OB_SUCC(ret) && OB_NOT_NULL(next_date)) {
|
||||||
int64_t next_time = 0;
|
int64_t next_time = OB_INVALID_TIMESTAMP;
|
||||||
if (OB_FAIL(ObMViewSchedJobUtils::resolve_date_expr_to_timestamp(params_,
|
if (OB_FAIL(ObMViewSchedJobUtils::resolve_date_expr_to_timestamp(params_,
|
||||||
*session_info_, *next_date, *allocator_, next_time))) {
|
*session_info_, *next_date, *allocator_, next_time))) {
|
||||||
LOG_WARN("fail to resolve date expr to timestamp", KR(ret));
|
LOG_WARN("fail to resolve date expr to timestamp", KR(ret));
|
||||||
} else if (next_time <= current_time) {
|
} else if (next_time < current_time) {
|
||||||
ret = OB_ERR_TIME_EARLIER_THAN_SYSDATE;
|
ret = OB_ERR_TIME_EARLIER_THAN_SYSDATE;
|
||||||
LOG_WARN("the parameter next date must evaluate to a time in the future",
|
LOG_WARN("the parameter next date must evaluate to a time in the future",
|
||||||
KR(ret), K(current_time), K(next_time));
|
KR(ret), K(current_time), K(next_time));
|
||||||
LOG_USER_ERROR(OB_ERR_TIME_EARLIER_THAN_SYSDATE, "next date");
|
LOG_USER_ERROR(OB_ERR_TIME_EARLIER_THAN_SYSDATE, "next date");
|
||||||
} else {
|
} else if (OB_INVALID_TIMESTAMP == start_time) {
|
||||||
|
start_time = next_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
ObString next_date_str(next_date->str_len_, next_date->str_value_);
|
ObString next_date_str(next_date->str_len_, next_date->str_value_);
|
||||||
if (OB_FAIL(ob_write_string(*allocator_, next_date_str, refresh_info.next_time_expr_))) {
|
if (OB_FAIL(ob_write_string(*allocator_, next_date_str, refresh_info.next_time_expr_))) {
|
||||||
LOG_WARN("fail to write string", KR(ret));
|
LOG_WARN("fail to write string", KR(ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
refresh_info.start_time_.set_timestamp(start_time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user