patch 4.0
This commit is contained in:
@ -18,86 +18,108 @@
|
||||
#include "sql/optimizer/ob_update_log_plan.h"
|
||||
#include "sql/optimizer/ob_insert_log_plan.h"
|
||||
#include "sql/optimizer/ob_explain_log_plan.h"
|
||||
#include "sql/optimizer/ob_help_log_plan.h"
|
||||
#include "sql/optimizer/ob_merge_log_plan.h"
|
||||
#include "sql/optimizer/ob_insert_all_log_plan.h"
|
||||
#include "sql/optimizer/ob_optimizer_context.h"
|
||||
using namespace oceanbase;
|
||||
using namespace oceanbase::sql;
|
||||
using namespace oceanbase::common;
|
||||
|
||||
ObLogPlanFactory::ObLogPlanFactory(ObIAllocator& allocator) : allocator_(allocator), plan_store_(allocator)
|
||||
{}
|
||||
ObLogPlanFactory::ObLogPlanFactory(ObIAllocator &allocator)
|
||||
: allocator_(allocator),
|
||||
plan_store_(allocator)
|
||||
{
|
||||
}
|
||||
|
||||
ObLogPlanFactory::~ObLogPlanFactory()
|
||||
{
|
||||
// destroy();
|
||||
//destroy();
|
||||
}
|
||||
// TODO: will rewrite it with template later to remove redundancy
|
||||
ObLogPlan* ObLogPlanFactory::create(ObOptimizerContext& ctx, const ObDMLStmt& stmt)
|
||||
// TODO(jiuman): will rewrite it with template later to remove redundancy
|
||||
ObLogPlan *ObLogPlanFactory::create(ObOptimizerContext &ctx, const ObDMLStmt &stmt)
|
||||
{
|
||||
ObLogPlan* ret = NULL;
|
||||
ObLogPlan *ret = NULL;
|
||||
switch (stmt.get_stmt_type()) {
|
||||
case stmt::T_SHOW_INDEXES:
|
||||
case stmt::T_SELECT: {
|
||||
void* ptr = allocator_.alloc(sizeof(ObSelectLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObSelectLogPlan(ctx, static_cast<const ObSelectStmt*>(&stmt));
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObSelectLogPlan error");
|
||||
}
|
||||
break;
|
||||
case stmt::T_SHOW_INDEXES:
|
||||
case stmt::T_SELECT: {
|
||||
void *ptr = allocator_.alloc(sizeof(ObSelectLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObSelectLogPlan(ctx, static_cast<const ObSelectStmt*>(&stmt));
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObSelectLogPlan error");
|
||||
}
|
||||
case stmt::T_DELETE: {
|
||||
void* ptr = allocator_.alloc(sizeof(ObDeleteLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObDeleteLogPlan(ctx, static_cast<const ObDeleteStmt*>(&stmt));
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObDeleteLogPlan error");
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case stmt::T_DELETE: {
|
||||
void *ptr = allocator_.alloc(sizeof(ObDeleteLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObDeleteLogPlan(ctx, static_cast<const ObDeleteStmt*>(&stmt));
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObDeleteLogPlan error");
|
||||
}
|
||||
case stmt::T_UPDATE: {
|
||||
void* ptr = allocator_.alloc(sizeof(ObUpdateLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObUpdateLogPlan(ctx, static_cast<const ObUpdateStmt*>(&stmt));
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObUpdateLogPlan error");
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case stmt::T_UPDATE: {
|
||||
void *ptr = allocator_.alloc(sizeof(ObUpdateLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObUpdateLogPlan(ctx, static_cast<const ObUpdateStmt*>(&stmt));
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObUpdateLogPlan error");
|
||||
}
|
||||
case stmt::T_INSERT:
|
||||
case stmt::T_REPLACE: {
|
||||
void* ptr = allocator_.alloc(sizeof(ObInsertLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObInsertLogPlan(ctx, &stmt);
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObInsertLogPlan error");
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case stmt::T_INSERT:
|
||||
case stmt::T_REPLACE: {
|
||||
void *ptr = allocator_.alloc(sizeof(ObInsertLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObInsertLogPlan(ctx, static_cast<const ObInsertStmt*>(&stmt));
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObInsertLogPlan error");
|
||||
}
|
||||
case stmt::T_EXPLAIN: {
|
||||
void* ptr = allocator_.alloc(sizeof(ObExplainLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObExplainLogPlan(ctx, &stmt);
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObExplainLogPlan error");
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case stmt::T_EXPLAIN: {
|
||||
void *ptr = allocator_.alloc(sizeof(ObExplainLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObExplainLogPlan(ctx, &stmt);
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObExplainLogPlan error");
|
||||
}
|
||||
case stmt::T_MERGE: {
|
||||
void* ptr = allocator_.alloc(sizeof(ObMergeLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObMergeLogPlan(ctx, static_cast<const ObMergeStmt*>(&stmt));
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObMergeLogPlan error");
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case stmt::T_HELP: {
|
||||
void *ptr = allocator_.alloc(sizeof(ObHelpLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObHelpLogPlan(ctx, &stmt);
|
||||
} else {
|
||||
}
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case stmt::T_MERGE: {
|
||||
void *ptr = allocator_.alloc(sizeof(ObMergeLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObMergeLogPlan(ctx, static_cast<const ObMergeStmt*>(&stmt));
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObMergeLogPlan error");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case stmt::T_INSERT_ALL: {
|
||||
void *ptr = allocator_.alloc(sizeof(ObInsertAllLogPlan));
|
||||
if (NULL != ptr) {
|
||||
ret = new (ptr) ObInsertAllLogPlan(ctx, static_cast<const ObInsertAllStmt*>(&stmt));
|
||||
} else {
|
||||
SQL_OPT_LOG(WARN, "Allocate ObInsertAllLogPlan error");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (ret != NULL) {
|
||||
int err = OB_SUCCESS;
|
||||
if (OB_SUCCESS != (err = ret->get_all_exprs().init()) || OB_SUCCESS != (err = plan_store_.store_obj(ret))) {
|
||||
if (OB_SUCCESS != (err = plan_store_.store_obj(ret))) {
|
||||
LOG_WARN("store log plan failed", K(err));
|
||||
ret->~ObLogPlan();
|
||||
ret = NULL;
|
||||
@ -108,12 +130,11 @@ ObLogPlan* ObLogPlanFactory::create(ObOptimizerContext& ctx, const ObDMLStmt& st
|
||||
|
||||
void ObLogPlanFactory::destroy()
|
||||
{
|
||||
DLIST_FOREACH_NORET(node, plan_store_.get_obj_list())
|
||||
{
|
||||
DLIST_FOREACH_NORET(node, plan_store_.get_obj_list()) {
|
||||
if (node != NULL && node->get_obj() != NULL) {
|
||||
node->get_obj()->~ObLogPlan();
|
||||
node->get_obj() = NULL;
|
||||
}
|
||||
}
|
||||
plan_store_.destory();
|
||||
plan_store_.destroy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user