[FEAT MERGE] patch 423 sql compatible features to 432
Co-authored-by: akaError <lzg020616@163.com> Co-authored-by: JinmaoLi <ljm.csmaster@gmail.com> Co-authored-by: qingzhu521 <q15000557748@gmail.com>
This commit is contained in:
@ -1422,6 +1422,54 @@ int ObSQLUtils::check_ident_name(const ObCollationType cs_type, ObString &name,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObSQLUtils::get_proxy_can_activate_role(const ObIArray<uint64_t> &role_id_array,
|
||||
const ObIArray<uint64_t> &role_id_option_array,
|
||||
const ObProxyInfo &proxied_info,
|
||||
ObIArray<uint64_t> &new_role_id_array,
|
||||
ObIArray<uint64_t> &new_role_id_option_array)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(role_id_array.count() != role_id_option_array.count())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error", K(ret));
|
||||
} else if (proxied_info.proxy_flags_ == PROXY_USER_NO_ROLES_BE_ACTIVATED) {
|
||||
new_role_id_array.reuse();
|
||||
new_role_id_option_array.reuse();
|
||||
} else if (proxied_info.proxy_flags_ == PROXY_USER_ACTIVATE_ALL_ROLES) {
|
||||
OZ (new_role_id_array.assign(role_id_array));
|
||||
OZ (new_role_id_option_array.assign(role_id_option_array));
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < role_id_array.count(); i++) {
|
||||
bool found = false;
|
||||
for (int j = 0; OB_SUCC(ret) && !found && j < proxied_info.role_id_cnt_; j++) {
|
||||
uint64_t role_id = proxied_info.get_role_id_by_idx(j);
|
||||
if (role_id == OB_INVALID_ID) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error", K(ret));
|
||||
} else if (role_id_array.at(i) == role_id) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (proxied_info.proxy_flags_ == PROXY_USER_MAY_ACTIVATE_ROLE) {
|
||||
if (found) {
|
||||
OZ (new_role_id_array.push_back(role_id_array.at(i)));
|
||||
OZ (new_role_id_option_array.push_back(role_id_option_array.at(i)));
|
||||
}
|
||||
} else if (proxied_info.proxy_flags_ == PROXY_USER_ROLE_CAN_NOT_BE_ACTIVATED) {
|
||||
if (!found) {
|
||||
OZ (new_role_id_array.push_back(role_id_array.at(i)));
|
||||
OZ (new_role_id_option_array.push_back(role_id_option_array.at(i)));
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ObSQLUtils::check_mysql50_prefix(ObString &db_name)
|
||||
{
|
||||
bool ret = false;
|
||||
@ -1596,6 +1644,7 @@ bool ObSQLUtils::is_readonly_stmt(ParseResult &result)
|
||||
|| T_SET_NAMES == type //read only not restrict it
|
||||
|| T_SET_CHARSET == type //read only not restrict it
|
||||
|| T_SHOW_RECYCLEBIN == type
|
||||
|| T_SHOW_PROFILE == type
|
||||
|| T_SHOW_TENANT == type
|
||||
|| T_SHOW_RESTORE_PREVIEW == type
|
||||
|| T_SHOW_SEQUENCES == type
|
||||
@ -3364,6 +3413,26 @@ int ObSQLUtils::merge_solidified_var_into_max_allowed_packet(const share::schema
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObSQLUtils::merge_solidified_var_into_compat_version(const share::schema::ObLocalSessionVar *local_vars,
|
||||
uint64_t &compat_version)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSessionSysVar *local_var = NULL;
|
||||
if (NULL == local_vars) {
|
||||
//do nothing
|
||||
} else if (OB_FAIL(local_vars->get_local_var(SYS_VAR_OB_COMPATIBILITY_VERSION, local_var))) {
|
||||
LOG_WARN("get local session var failed", K(ret));
|
||||
} else if (NULL != local_var) {
|
||||
if (ObUInt64Type == local_var->val_.get_type()) {
|
||||
compat_version = local_var->val_.get_uint64();
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid compat version val type", K(ret), K(local_var->val_));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObSQLUtils::init_type_ctx(const ObSQLSessionInfo *session, ObExprTypeCtx &type_ctx)
|
||||
{
|
||||
if (NULL != session) {
|
||||
@ -5820,3 +5889,8 @@ bool ObSQLUtils::is_data_version_ge_423_or_431(uint64_t data_version)
|
||||
{
|
||||
return ((MOCK_DATA_VERSION_4_2_3_0 <= data_version && data_version < DATA_VERSION_4_3_0_0) || data_version >= DATA_VERSION_4_3_1_0);
|
||||
}
|
||||
|
||||
bool ObSQLUtils::is_data_version_ge_423_or_432(uint64_t data_version)
|
||||
{
|
||||
return ((MOCK_DATA_VERSION_4_2_3_0 <= data_version && data_version < DATA_VERSION_4_3_0_0) || data_version >= DATA_VERSION_4_3_2_0);
|
||||
}
|
||||
Reference in New Issue
Block a user