[FEAT MERGE] log4100 branch
Co-authored-by: tino247 <tino247@126.com> Co-authored-by: BinChenn <binchenn.bc@gmail.com> Co-authored-by: HaHaJeff <jeffzhouhhh@gmail.com>
This commit is contained in:
@ -29,6 +29,7 @@
|
||||
#include "sql/resolver/cmd/ob_alter_system_stmt.h"
|
||||
#include "sql/resolver/cmd/ob_system_cmd_stmt.h"
|
||||
#include "sql/resolver/cmd/ob_clear_balance_task_stmt.h"
|
||||
#include "sql/resolver/cmd/ob_switch_tenant_resolver.h"
|
||||
#include "sql/resolver/ddl/ob_create_table_resolver.h"
|
||||
#include "sql/resolver/ddl/ob_drop_table_stmt.h"
|
||||
#include "sql/resolver/ddl/ob_alter_table_stmt.h"
|
||||
@ -315,9 +316,9 @@ int ObAlterSystemResolverUtil::resolve_string(const ParseNode *node, ObString &s
|
||||
if (OB_UNLIKELY(NULL == node)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("node should not be null");
|
||||
} else if (OB_UNLIKELY(T_VARCHAR != node->type_)) {
|
||||
} else if (OB_UNLIKELY(T_VARCHAR != node->type_ && T_CHAR != node->type_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("node type is not T_VARCHAR", "type", get_type_name(node->type_));
|
||||
LOG_WARN("node type is not T_VARCHAR/T_CHAR", "type", get_type_name(node->type_));
|
||||
} else if (OB_UNLIKELY(node->str_len_ <= 0)) {
|
||||
ret = OB_ERR_PARSER_SYNTAX;
|
||||
LOG_WARN("empty string");
|
||||
@ -2354,6 +2355,36 @@ int ObMigrateUnitResolver::resolve(const ParseNode &parse_tree)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObAddArbitrationServiceResolver::resolve(const ParseNode &parse_tree)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSEDx(parse_tree);
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("not supported in CE version", KR(ret));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "add arbitration service in CE version");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObRemoveArbitrationServiceResolver::resolve(const ParseNode &parse_tree)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSEDx(parse_tree);
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("not supported in CE version", KR(ret));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "remove arbitration service in CE version");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObReplaceArbitrationServiceResolver::resolve(const ParseNode &parse_tree)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSEDx(parse_tree);
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("not supported in CE version", KR(ret));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "replace arbitration service in CE version");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObUpgradeVirtualSchemaResolver::resolve(const ParseNode &parse_tree)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2489,57 +2520,10 @@ int ObPhysicalRestoreTenantResolver::resolve(const ParseNode &parse_tree)
|
||||
// resolve datetime
|
||||
if (OB_ISNULL(parse_tree.children_[2])) {
|
||||
stmt->get_rpc_arg().with_restore_scn_ = false;
|
||||
} else {
|
||||
ParseNode *time_node = parse_tree.children_[2];
|
||||
if (OB_UNLIKELY(T_PHYSICAL_RESTORE_TENANT != time_node->type_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("type is not T_PHYSICAL_RESTORE_TENANT", "type", get_type_name(time_node->type_));
|
||||
} else if (OB_UNLIKELY(NULL == time_node->children_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("children should not be null");
|
||||
} else if (OB_UNLIKELY(2 != time_node->num_child_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("num of children not match", K(ret), "child_num", time_node->num_child_);
|
||||
} else if (0/*timestamp*/ == time_node->children_[0]->value_) {
|
||||
uint64_t time_val = 0;
|
||||
ObString time_str;
|
||||
ObString sys_time_zone;
|
||||
ObTimeZoneInfoWrap tz_info_wrap;
|
||||
const ObTimeZoneInfo *time_zone_info = nullptr;
|
||||
const ObTimeZoneInfo *sys_tz_info = nullptr;
|
||||
if (OB_ISNULL(time_zone_info = session_info_->get_timezone_info())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("time zone info is null", K(ret), KP(session_info_), KP(time_zone_info));
|
||||
} else if (OB_FAIL(session_info_->get_sys_variable(share::SYS_VAR_SYSTEM_TIME_ZONE, sys_time_zone))) {
|
||||
LOG_WARN("Get sys variable error", K(ret));
|
||||
} else if (OB_FAIL(tz_info_wrap.init_time_zone(sys_time_zone, OB_INVALID_VERSION,
|
||||
*(const_cast<ObTZInfoMap *>(time_zone_info->get_tz_info_map()))))) {
|
||||
LOG_WARN("tz_info_wrap init_time_zone fail", KR(ret), K(sys_time_zone));
|
||||
} else if (OB_ISNULL(sys_tz_info = tz_info_wrap.get_time_zone_info())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("sys time zone info is null", K(ret));
|
||||
} else if (OB_FAIL(Util::resolve_string(time_node->children_[1], time_str))) {
|
||||
LOG_WARN("resolve string failed", K(ret));
|
||||
} else if (OB_FAIL(ObTimeConverter::str_to_scn_value(time_str,
|
||||
sys_tz_info,
|
||||
time_zone_info,
|
||||
ObTimeConverter::COMPAT_OLD_NLS_TIMESTAMP_FORMAT,
|
||||
true/*oracle mode*/,
|
||||
time_val))) {
|
||||
ret = OB_ERR_WRONG_VALUE;
|
||||
LOG_USER_ERROR(OB_ERR_WRONG_VALUE, "TIMESTAMP", to_cstring(time_str));
|
||||
} else if (OB_FAIL(stmt->get_rpc_arg().restore_scn_.convert_for_sql(time_val))) {
|
||||
LOG_WARN("fail to set scn", K(ret));
|
||||
} else {
|
||||
stmt->get_rpc_arg().with_restore_scn_ = true;
|
||||
}
|
||||
} else if (1/*scn*/ == time_node->children_[0]->value_) {
|
||||
if (OB_FAIL(stmt->get_rpc_arg().restore_scn_.convert_for_sql(time_node->children_[1]->value_))) {
|
||||
LOG_WARN("fail to set scn", K(ret));
|
||||
} else {
|
||||
stmt->get_rpc_arg().with_restore_scn_ = true;
|
||||
}
|
||||
}
|
||||
} else if (OB_FAIL(resolve_restore_until(*parse_tree.children_[2], session_info_,
|
||||
stmt->get_rpc_arg().restore_scn_,
|
||||
stmt->get_rpc_arg().with_restore_scn_))) {
|
||||
LOG_WARN("failed to resolve restore until", KR(ret), KP(parse_tree.children_[2]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4325,5 +4309,143 @@ int ObCheckpointSlogResolver::resolve(const ParseNode &parse_tree)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObRecoverTenantResolver::resolve(const ParseNode &parse_tree)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
share::SCN recovery_until_scn = SCN::min_scn();
|
||||
obrpc::ObRecoverTenantArg::RecoverType type = obrpc::ObRecoverTenantArg::RecoverType::INVALID;
|
||||
ObString tenant_name;
|
||||
bool with_restore_scn = false;
|
||||
if (OB_UNLIKELY(T_RECOVER != parse_tree.type_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("type is not T_RECOVER", "type", get_type_name(parse_tree.type_));
|
||||
} else if (OB_ISNULL(parse_tree.children_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("children should not be null");
|
||||
} else if (OB_UNLIKELY(2 != parse_tree.num_child_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("num of children not match", KR(ret), "child_num", parse_tree.num_child_);
|
||||
} else {
|
||||
ObRecoverTenantStmt *stmt = create_stmt<ObRecoverTenantStmt>();
|
||||
if (OB_ISNULL(stmt)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_ERROR("create ObRecoverTenantStmt failed");
|
||||
} else {
|
||||
if (OB_FAIL(resolve_tenant_name(parse_tree.children_[0],
|
||||
session_info_->get_effective_tenant_id(), tenant_name))) {
|
||||
LOG_WARN("resolve_tenant_name", KR(ret), KP(parse_tree.children_[0]),
|
||||
K(session_info_->get_effective_tenant_id()), K(tenant_name));
|
||||
} else if (OB_ISNULL(parse_tree.children_[1])) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_USER_ERROR(OB_INVALID_ARGUMENT, "restore until, should specify restore until point");
|
||||
LOG_WARN("should specify restore until point", KR(ret));
|
||||
} else if (T_PHYSICAL_RESTORE_UNTIL == parse_tree.children_[1]->type_) {
|
||||
if (OB_FAIL(resolve_restore_until(*parse_tree.children_[1], session_info_, recovery_until_scn,
|
||||
with_restore_scn))) {
|
||||
LOG_WARN("failed to resolve restore until", KR(ret), KP(parse_tree.children_[1]),
|
||||
K(recovery_until_scn), K(with_restore_scn));
|
||||
} else {
|
||||
type = obrpc::ObRecoverTenantArg::RecoverType::UNTIL;
|
||||
}
|
||||
} else if (T_RECOVER_UNLIMITED == parse_tree.children_[1]->type_) {
|
||||
//TODO(yaoying):need check recovery_until_scn
|
||||
recovery_until_scn.set_max();
|
||||
type = obrpc::ObRecoverTenantArg::RecoverType::UNTIL;
|
||||
} else if (T_RECOVER_CANCEL == parse_tree.children_[1]->type_) {
|
||||
recovery_until_scn.set_min();
|
||||
type = obrpc::ObRecoverTenantArg::RecoverType::CANCEL;
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected node type", KR(ret), "type", get_type_name(parse_tree.children_[1]->type_));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(stmt->get_rpc_arg().init(session_info_->get_effective_tenant_id(),
|
||||
tenant_name, type, recovery_until_scn))) {
|
||||
LOG_WARN("fail to init arg", KR(ret), K(stmt->get_rpc_arg()),
|
||||
K(session_info_->get_effective_tenant_id()), K(tenant_name), K(type),
|
||||
K(recovery_until_scn));
|
||||
} else {
|
||||
stmt_ = stmt;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int resolve_restore_until(const ParseNode &time_node,
|
||||
const ObSQLSessionInfo *session_info,
|
||||
share::SCN &recovery_until_scn,
|
||||
bool &with_restore_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
recovery_until_scn.set_min();
|
||||
with_restore_scn = false;
|
||||
|
||||
if (OB_UNLIKELY(T_PHYSICAL_RESTORE_UNTIL != time_node.type_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("type is not T_PHYSICAL_RESTORE_UNTIL", "type", get_type_name(time_node.type_));
|
||||
} else if (OB_ISNULL(session_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("arg should not be null", KP(session_info));
|
||||
} else if (OB_ISNULL(time_node.children_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("children should not be null");
|
||||
} else if (OB_UNLIKELY(2 != time_node.num_child_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("num of children not match", K(ret), "child_num", time_node.num_child_);
|
||||
} else if (OB_ISNULL(time_node.children_[0]) || OB_ISNULL(time_node.children_[1])) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("children should not be null", KP(time_node.children_[0]), KP(time_node.children_[1]));
|
||||
} else if (0/*timestamp*/ == time_node.children_[0]->value_) {
|
||||
uint64_t time_val = 0;
|
||||
ObString time_str;
|
||||
ObString sys_time_zone;
|
||||
ObTimeZoneInfoWrap tz_info_wrap;
|
||||
const ObTimeZoneInfo *time_zone_info = nullptr;
|
||||
const ObTimeZoneInfo *sys_tz_info = nullptr;
|
||||
if (OB_ISNULL(time_zone_info = session_info->get_timezone_info())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("time zone info is null", K(ret), KP(session_info), KP(time_zone_info));
|
||||
} else if (OB_FAIL(session_info->get_sys_variable(share::SYS_VAR_SYSTEM_TIME_ZONE, sys_time_zone))) {
|
||||
LOG_WARN("Get sys variable error", K(ret));
|
||||
} else if (OB_ISNULL(time_zone_info->get_tz_info_map())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("should not be null", KP(time_zone_info->get_tz_info_map()));
|
||||
} else if (OB_FAIL(tz_info_wrap.init_time_zone(sys_time_zone, OB_INVALID_VERSION,
|
||||
*(const_cast<ObTZInfoMap *>(time_zone_info->get_tz_info_map()))))) {
|
||||
LOG_WARN("tz_info_wrap init_time_zone fail", KR(ret), K(sys_time_zone));
|
||||
} else if (OB_ISNULL(sys_tz_info = tz_info_wrap.get_time_zone_info())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("sys time zone info is null", K(ret));
|
||||
} else if (OB_FAIL(ObAlterSystemResolverUtil::resolve_string(time_node.children_[1], time_str))) {
|
||||
LOG_WARN("resolve string failed", K(ret));
|
||||
} else if (OB_FAIL(ObTimeConverter::str_to_scn_value(time_str,
|
||||
sys_tz_info,
|
||||
time_zone_info,
|
||||
ObTimeConverter::COMPAT_OLD_NLS_TIMESTAMP_FORMAT,
|
||||
true/*oracle mode*/,
|
||||
time_val))) {
|
||||
ret = OB_ERR_WRONG_VALUE;
|
||||
LOG_USER_ERROR(OB_ERR_WRONG_VALUE, "TIMESTAMP", to_cstring(time_str));
|
||||
} else if (recovery_until_scn.convert_for_sql(time_val)) {
|
||||
LOG_WARN("fail to set scn", K(ret));
|
||||
} else {
|
||||
with_restore_scn = true;
|
||||
}
|
||||
} else if (1/*scn*/ == time_node.children_[0]->value_) {
|
||||
if (share::OB_BASE_SCN_TS_NS >= time_node.children_[1]->value_) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_USER_ERROR(OB_INVALID_ARGUMENT, "until scn, it should be positive integer");
|
||||
LOG_WARN("until scn, it should be positive integer", KR(ret), K(time_node.children_[1]->value_));
|
||||
} else if (OB_FAIL(recovery_until_scn.convert_for_sql(time_node.children_[1]->value_))) {
|
||||
LOG_WARN("fail to set scn", K(ret));
|
||||
} else {
|
||||
with_restore_scn = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // end namespace sql
|
||||
} // end namespace oceanbase
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
#define OCEANBASE_RESOLVER_CMD_OB_ALTER_SYSTEM_RESOLVER_
|
||||
|
||||
#include "sql/resolver/cmd/ob_system_cmd_resolver.h"
|
||||
#include "sql/session/ob_sql_session_info.h" // ObSqlSessionInfo
|
||||
#include "share/ls/ob_ls_i_life_manager.h" //OB_LS_MAX_SCN_VALUE
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -118,6 +120,10 @@ DEF_SIMPLE_CMD_RESOLVER(ObReloadZoneResolver);
|
||||
|
||||
DEF_SIMPLE_CMD_RESOLVER(ObClearMergeErrorResolver);
|
||||
|
||||
DEF_SIMPLE_CMD_RESOLVER(ObAddArbitrationServiceResolver);
|
||||
DEF_SIMPLE_CMD_RESOLVER(ObRemoveArbitrationServiceResolver);
|
||||
DEF_SIMPLE_CMD_RESOLVER(ObReplaceArbitrationServiceResolver);
|
||||
|
||||
DEF_SIMPLE_CMD_RESOLVER(ObMigrateUnitResolver);
|
||||
|
||||
DEF_SIMPLE_CMD_RESOLVER(ObUpgradeVirtualSchemaResolver);
|
||||
@ -154,6 +160,11 @@ DEF_SIMPLE_CMD_RESOLVER(ObAddRestoreSourceResolver);
|
||||
DEF_SIMPLE_CMD_RESOLVER(ObClearRestoreSourceResolver);
|
||||
DEF_SIMPLE_CMD_RESOLVER(ObCheckpointSlogResolver);
|
||||
|
||||
int resolve_restore_until(const ParseNode &time_node,
|
||||
const ObSQLSessionInfo *session_info,
|
||||
share::SCN &recovery_until_scn,
|
||||
bool &with_restore_scn);
|
||||
|
||||
class ObPhysicalRestoreTenantResolver : public ObSystemCmdResolver
|
||||
{
|
||||
public:
|
||||
@ -165,6 +176,15 @@ class ObPhysicalRestoreTenantResolver : public ObSystemCmdResolver
|
||||
int resolve_restore_source_array(obrpc::ObPhysicalRestoreTenantArg &arg);
|
||||
};
|
||||
|
||||
class ObRecoverTenantResolver : public ObSystemCmdResolver
|
||||
{
|
||||
public:
|
||||
ObRecoverTenantResolver(ObResolverParams ¶ms) : ObSystemCmdResolver(params) {}
|
||||
virtual ~ObRecoverTenantResolver() {}
|
||||
virtual int resolve(const ParseNode &parse_tree);
|
||||
private:
|
||||
};
|
||||
|
||||
class ObAlterSystemSetResolver : public ObSystemCmdResolver
|
||||
{
|
||||
public:
|
||||
|
||||
@ -384,6 +384,29 @@ private:
|
||||
obrpc::ObAdminMigrateUnitArg rpc_arg_;
|
||||
};
|
||||
|
||||
class ObAddArbitrationServiceStmt : public ObSystemCmdStmt
|
||||
{
|
||||
public:
|
||||
ObAddArbitrationServiceStmt() : ObSystemCmdStmt(stmt::T_ADD_ARBITRATION_SERVICE) {}
|
||||
virtual ~ObAddArbitrationServiceStmt() {}
|
||||
TO_STRING_KV(N_STMT_TYPE, ((int)stmt_type_));
|
||||
};
|
||||
|
||||
class ObRemoveArbitrationServiceStmt : public ObSystemCmdStmt
|
||||
{
|
||||
public:
|
||||
ObRemoveArbitrationServiceStmt() : ObSystemCmdStmt(stmt::T_REMOVE_ARBITRATION_SERVICE) {}
|
||||
virtual ~ObRemoveArbitrationServiceStmt() {}
|
||||
TO_STRING_KV(N_STMT_TYPE, ((int)stmt_type_));
|
||||
};
|
||||
|
||||
class ObReplaceArbitrationServiceStmt : public ObSystemCmdStmt
|
||||
{
|
||||
public:
|
||||
ObReplaceArbitrationServiceStmt() : ObSystemCmdStmt(stmt::T_REPLACE_ARBITRATION_SERVICE) {}
|
||||
virtual ~ObReplaceArbitrationServiceStmt() {}
|
||||
TO_STRING_KV(N_STMT_TYPE, ((int)stmt_type_));
|
||||
};
|
||||
|
||||
class ObClearLocationCacheStmt : public ObSystemCmdStmt
|
||||
{
|
||||
@ -1162,6 +1185,18 @@ public:
|
||||
common::ObAddr server_;
|
||||
};
|
||||
|
||||
class ObRecoverTenantStmt : public ObSystemCmdStmt
|
||||
{
|
||||
public:
|
||||
ObRecoverTenantStmt()
|
||||
: ObSystemCmdStmt(stmt::T_RECOVER),
|
||||
rpc_arg_() {}
|
||||
virtual ~ObRecoverTenantStmt() {}
|
||||
|
||||
obrpc::ObRecoverTenantArg &get_rpc_arg() { return rpc_arg_; }
|
||||
private:
|
||||
obrpc::ObRecoverTenantArg rpc_arg_;
|
||||
};
|
||||
|
||||
} // end namespace sql
|
||||
} // end namespace oceanbase
|
||||
|
||||
@ -43,6 +43,8 @@ int ObSwitchTenantResolver::resolve_switch_tenant(const ParseNode &parse_tree)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSwitchTenantStmt *stmt = create_stmt<ObSwitchTenantStmt>();
|
||||
ObString tenant_name;
|
||||
obrpc::ObSwitchTenantArg::OpType op_type = obrpc::ObSwitchTenantArg::OpType::INVALID;
|
||||
if (OB_UNLIKELY(T_SWITCHOVER != parse_tree.type_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid parse node, type is not T_SWITCHOVER", KR(ret), "type",
|
||||
@ -60,28 +62,82 @@ int ObSwitchTenantResolver::resolve_switch_tenant(const ParseNode &parse_tree)
|
||||
ParseNode *switch_node = parse_tree.children_[0];
|
||||
obrpc::ObSwitchTenantArg &arg = stmt->get_arg();
|
||||
|
||||
if (T_FAILOVER_TO_PRIMARY == switch_node->type_) {
|
||||
arg.set_op_type(ObSwitchTenantArg::FAILOVER_TO_PRIMARY);
|
||||
|
||||
if (OB_FAIL(resolve_tenant_name(*stmt, switch_node->children_[0],
|
||||
session_info_->get_effective_tenant_id()))) {
|
||||
LOG_WARN("resolve_tenant_name", KR(ret), KP(stmt), KP(switch_node->children_[0]),
|
||||
K(session_info_->get_effective_tenant_id()));
|
||||
}
|
||||
if (OB_FAIL(resolve_tenant_name(switch_node->children_[0],
|
||||
session_info_->get_effective_tenant_id(), tenant_name))) {
|
||||
LOG_WARN("resolve_tenant_name fail", KR(ret), KP(stmt), KP(switch_node->children_[0]),
|
||||
K(session_info_->get_effective_tenant_id()));
|
||||
} else {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid switch node type", KR(ret), "type", get_type_name(switch_node->type_));
|
||||
switch(switch_node->type_) {
|
||||
case T_SWITCHOVER_TO_PRIMARY: {
|
||||
op_type = ObSwitchTenantArg::SWITCH_TO_PRIMARY;
|
||||
break;
|
||||
}
|
||||
case T_SWITCHOVER_TO_STANDBY: {
|
||||
op_type = ObSwitchTenantArg::SWITCH_TO_STANDBY;
|
||||
break;
|
||||
}
|
||||
case T_FAILOVER_TO_PRIMARY: {
|
||||
op_type = ObSwitchTenantArg::FAILOVER_TO_PRIMARY;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid switch node type", KR(ret), "type", get_type_name(switch_node->type_));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
obrpc::ObSwitchTenantArg &arg = stmt->get_arg();
|
||||
arg.set_exec_tenant_id(session_info_->get_effective_tenant_id());
|
||||
stmt_ = stmt;
|
||||
if (OB_FAIL(stmt->get_arg().init(session_info_->get_effective_tenant_id(), op_type, tenant_name))) {
|
||||
LOG_WARN("fail to init arg", KR(ret), K(stmt->get_arg()),
|
||||
K(session_info_->get_effective_tenant_id()), K(tenant_name), K(op_type));
|
||||
} else {
|
||||
stmt_ = stmt;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int resolve_tenant_name(
|
||||
const ParseNode *node,
|
||||
const uint64_t effective_tenant_id,
|
||||
ObString &tenant_name)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
tenant_name.reset();
|
||||
if (OB_ISNULL(node)) {
|
||||
if (OB_SYS_TENANT_ID == effective_tenant_id) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret));
|
||||
LOG_USER_ERROR(OB_INVALID_ARGUMENT, "tenant name, should specify tenant name");
|
||||
}
|
||||
} else if (OB_UNLIKELY(T_TENANT_NAME != node->type_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid type", K(node->type_));
|
||||
} else if (OB_UNLIKELY(node->num_child_ <= 0)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid num_child", "num_child", node->num_child_);
|
||||
} else if (OB_ISNULL(node->children_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("node should not be null");
|
||||
} else {
|
||||
const ParseNode *tenant_name_node = node->children_[0];
|
||||
if (OB_ISNULL(tenant_name_node)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("tenant_name_node should not be null");
|
||||
} else if (tenant_name_node->value_ <= 0) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("empty tenant string");
|
||||
} else {
|
||||
tenant_name.assign_ptr((char *)(tenant_name_node->str_value_),
|
||||
static_cast<int32_t>(tenant_name_node->str_len_));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} //end sql
|
||||
} //end oceanbase
|
||||
|
||||
@ -34,45 +34,10 @@ private:
|
||||
int resolve_switch_tenant(const ParseNode &parse_tree);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
int resolve_tenant_name(
|
||||
T &stmt,
|
||||
const ParseNode *node,
|
||||
const uint64_t effective_tenant_id)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(node)) {
|
||||
if (OB_SYS_TENANT_ID == effective_tenant_id) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret));
|
||||
LOG_USER_ERROR(OB_INVALID_ARGUMENT, "tenant name, should specify tenant name");
|
||||
}
|
||||
} else if (OB_UNLIKELY(T_TENANT_NAME != node->type_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid type", K(node->type_));
|
||||
} else if (OB_UNLIKELY(node->num_child_ <= 0)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid num_child", "num_child", node->num_child_);
|
||||
} else if (OB_ISNULL(node->children_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("node should not be null");
|
||||
} else {
|
||||
const ParseNode *tenant_name_node = node->children_[0];
|
||||
if (OB_ISNULL(tenant_name_node)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("tenant_name_node should not be null");
|
||||
} else if (tenant_name_node->value_ <= 0) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("empty tenant string");
|
||||
} else {
|
||||
ObString tenant_name;
|
||||
tenant_name.assign_ptr((char *)(tenant_name_node->str_value_),
|
||||
static_cast<int32_t>(tenant_name_node->str_len_));
|
||||
stmt.set_tenant_name(tenant_name);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const uint64_t effective_tenant_id,
|
||||
ObString &tenant_name);
|
||||
|
||||
} //end sql
|
||||
} //end oceanbase
|
||||
|
||||
@ -29,7 +29,6 @@ public:
|
||||
virtual ~ObSwitchTenantStmt()
|
||||
{
|
||||
}
|
||||
void set_tenant_name(const ObString &tenant_name) { arg_.set_tenant_name(tenant_name); }
|
||||
|
||||
obrpc::ObSwitchTenantArg &get_arg() { return arg_; }
|
||||
TO_STRING_KV(N_STMT_TYPE, ((int)stmt_type_), K_(arg));
|
||||
|
||||
@ -90,6 +90,14 @@ void ObCreateTenantStmt::set_primary_zone(const common::ObString &zone)
|
||||
create_tenant_arg_.tenant_schema_.set_primary_zone(zone);
|
||||
}
|
||||
|
||||
void ObCreateTenantStmt::set_enable_arbitration_service(const bool enable_arbitration_service)
|
||||
{
|
||||
create_tenant_arg_.tenant_schema_.set_arbitration_service_status(
|
||||
enable_arbitration_service
|
||||
? share::ObArbitrationServiceStatus(share::ObArbitrationServiceStatus::ENABLING)
|
||||
: share::ObArbitrationServiceStatus(share::ObArbitrationServiceStatus::DISABLED));
|
||||
}
|
||||
|
||||
void ObCreateTenantStmt::set_if_not_exist(const bool if_not_exist)
|
||||
{
|
||||
create_tenant_arg_.if_not_exist_ = if_not_exist;
|
||||
|
||||
@ -42,6 +42,7 @@ public:
|
||||
void set_if_not_exist(const bool is_exist);
|
||||
void set_charset_type(const common::ObCharsetType type);
|
||||
void set_collation_type(const common::ObCollationType type);
|
||||
void set_enable_arbitration_service(const bool enable_arbitration_service);
|
||||
void set_read_only(const bool read_only)
|
||||
{
|
||||
create_tenant_arg_.tenant_schema_.set_read_only(read_only);
|
||||
|
||||
@ -107,6 +107,14 @@ void ObModifyTenantStmt::set_charset_type(const common::ObCharsetType type)
|
||||
modify_tenant_arg_.tenant_schema_.set_charset_type(type);
|
||||
}
|
||||
|
||||
void ObModifyTenantStmt::set_enable_arbitration_service(const bool enable_arbitration_service)
|
||||
{
|
||||
modify_tenant_arg_.tenant_schema_.set_arbitration_service_status(
|
||||
enable_arbitration_service
|
||||
? share::ObArbitrationServiceStatus(share::ObArbitrationServiceStatus::ENABLING)
|
||||
: share::ObArbitrationServiceStatus(share::ObArbitrationServiceStatus::DISABLING));
|
||||
}
|
||||
|
||||
void ObModifyTenantStmt::set_collation_type(const common::ObCollationType type)
|
||||
{
|
||||
modify_tenant_arg_.tenant_schema_.set_collation_type(type);
|
||||
|
||||
@ -51,6 +51,7 @@ public:
|
||||
int set_locality(const common::ObString &locality);
|
||||
void set_primary_zone(const common::ObString &zone);
|
||||
void set_charset_type(const common::ObCharsetType type);
|
||||
void set_enable_arbitration_service(const bool enable_arbitration_service);
|
||||
void set_collation_type(const common::ObCollationType type);
|
||||
inline void set_read_only(const bool read_only)
|
||||
{
|
||||
|
||||
@ -158,6 +158,16 @@ int ObTenantResolver<T>::resolve_tenant_option(T *stmt, ParseNode *node,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case T_ENABLE_ARBITRATION_SERVICE: {
|
||||
const bool enable_arbitration_service = option_node->children_[0]->value_ ? true : false;
|
||||
stmt->set_enable_arbitration_service(enable_arbitration_service);
|
||||
if (stmt->get_stmt_type() == stmt::T_MODIFY_TENANT) {
|
||||
if (OB_FAIL(alter_option_bitset_.add_member(obrpc::ObModifyTenantArg::ENABLE_ARBITRATION_SERVICE))) {
|
||||
SQL_LOG(WARN, "failed to add member to bitset!", K(ret));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case T_PRIMARY_ZONE: {
|
||||
if (option_node->children_[0]->type_ == T_DEFAULT) {
|
||||
ret = OB_OP_NOT_ALLOW;
|
||||
|
||||
@ -396,6 +396,10 @@ int ObResolver::resolve(IsPrepared if_prepared, const ParseNode &parse_tree, ObS
|
||||
REGISTER_STMT_RESOLVER(SwitchTenant);
|
||||
break;
|
||||
}
|
||||
case T_RECOVER: {
|
||||
REGISTER_STMT_RESOLVER(RecoverTenant);
|
||||
break;
|
||||
}
|
||||
case T_REPORT_REPLICA: {
|
||||
REGISTER_STMT_RESOLVER(ReportReplica);
|
||||
break;
|
||||
@ -488,6 +492,18 @@ int ObResolver::resolve(IsPrepared if_prepared, const ParseNode &parse_tree, ObS
|
||||
REGISTER_STMT_RESOLVER(MigrateUnit);
|
||||
break;
|
||||
}
|
||||
case T_ADD_ARBITRATION_SERVICE: {
|
||||
REGISTER_STMT_RESOLVER(AddArbitrationService);
|
||||
break;
|
||||
}
|
||||
case T_REMOVE_ARBITRATION_SERVICE: {
|
||||
REGISTER_STMT_RESOLVER(RemoveArbitrationService);
|
||||
break;
|
||||
}
|
||||
case T_REPLACE_ARBITRATION_SERVICE: {
|
||||
REGISTER_STMT_RESOLVER(ReplaceArbitrationService);
|
||||
break;
|
||||
}
|
||||
case T_RUN_JOB: {
|
||||
REGISTER_STMT_RESOLVER(RunJob);
|
||||
break;
|
||||
|
||||
@ -276,9 +276,9 @@ OB_STMT_TYPE_DEF_UNKNOWN_AT(T_REFRESH_IO_CALIBRATION, get_sys_tenant_alter_syste
|
||||
OB_STMT_TYPE_DEF(T_INSERT_ALL, get_dml_stmt_need_privs, 277, ACTION_TYPE_INSERT)
|
||||
OB_STMT_TYPE_DEF_UNKNOWN_AT(T_PHYSICAL_RESTORE_STANDBY_TENANT, get_sys_tenant_alter_system_priv, 278)
|
||||
OB_STMT_TYPE_DEF_UNKNOWN_AT(T_RECOVER, get_sys_tenant_alter_system_priv, 279)
|
||||
//OB_STMT_TYPE_DEF_UNKNOWN_AT(T_ADD_ARBITRATION_SERVICE, get_sys_tenant_alter_system_priv, 280)
|
||||
//OB_STMT_TYPE_DEF_UNKNOWN_AT(T_REMOVE_ARBITRATION_SERVICE, get_sys_tenant_alter_system_priv, 281)
|
||||
//OB_STMT_TYPE_DEF_UNKNOWN_AT(T_REPLACE_ARBITRATION_SERVICE, get_sys_tenant_alter_system_priv, 282)
|
||||
OB_STMT_TYPE_DEF_UNKNOWN_AT(T_ADD_ARBITRATION_SERVICE, get_sys_tenant_alter_system_priv, 280)
|
||||
OB_STMT_TYPE_DEF_UNKNOWN_AT(T_REMOVE_ARBITRATION_SERVICE, get_sys_tenant_alter_system_priv, 281)
|
||||
OB_STMT_TYPE_DEF_UNKNOWN_AT(T_REPLACE_ARBITRATION_SERVICE, get_sys_tenant_alter_system_priv, 282)
|
||||
OB_STMT_TYPE_DEF_UNKNOWN_AT(T_SHOW_SEQUENCES, err_stmt_type_priv, 283)
|
||||
|
||||
OB_STMT_TYPE_DEF_UNKNOWN_AT(T_MAX, err_stmt_type_priv, 500)
|
||||
|
||||
Reference in New Issue
Block a user