patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -25,9 +25,10 @@ using namespace oceanbase::common;
using namespace oceanbase::json;
using namespace oceanbase::share::schema;
namespace test {
static TestSQL* test_sql = NULL;
static ObPlanCache* plan_cache = NULL;
namespace test
{
static TestSQL *test_sql = NULL;
static ObPlanCache *plan_cache = NULL;
static const int64_t BUKET_NUM = 102400;
void init_pcv_set()
@ -39,64 +40,60 @@ void init_pcv_set()
}
if (NULL == plan_cache) {
plan_cache = new ObPlanCache;
plan_cache->init(BUKET_NUM, test_sql->get_addr(), test_sql->get_part_cache(), OB_SYS_TENANT_ID);
plan_cache->init(BUKET_NUM, test_sql->get_addr(), test_sql->get_part_cache(), OB_SYS_TENANT_ID, NULL);
plan_cache->set_mem_limit_pct(20);
plan_cache->set_mem_high_pct(90);
plan_cache->set_mem_low_pct(50);
}
}
void generate_plan(TestSqlCtx& test_sql_ctx, const char* query, ParamStore& params, ObLogPlan*& logical_plan,
ObPhysicalPlan*& phy_plan, const ObSQLSessionInfo& session)
void generate_plan(TestSqlCtx &test_sql_ctx, const char *query,
ParamStore &params, ObLogPlan *&logical_plan,
ObPhysicalPlan *&phy_plan, const ObSQLSessionInfo &session)
{
LOG_INFO("generate_plan!");
ParseResult parse_result;
ObStmt* stmt = NULL;
ObStmt *stmt = NULL;
// parse
//parse
test_sql->do_parse(*test_sql_ctx.allocator_, query, parse_result);
LOG_INFO("tree", "tree", CSJ(ObParserResultPrintWrapper(*(parse_result.result_tree_))));
// replace const expt with ? in syntax tree; get params;
//replace const expt with ? in syntax tree; get params;
SqlInfo not_param_info;
ObMaxConcurrentParam::FixParamStore fixed_param_store(
OB_MALLOC_NORMAL_BLOCK_SIZE, ObWrapperAllocator(test_sql_ctx.allocator_));
ObMaxConcurrentParam::FixParamStore fixed_param_store(OB_MALLOC_NORMAL_BLOCK_SIZE,
ObWrapperAllocator(test_sql_ctx.allocator_));
bool is_transform_outline = false;
ObSqlParameterization::transform_syntax_tree(*test_sql_ctx.allocator_,
session,
NULL,
0,
parse_result.result_tree_,
not_param_info,
params,
NULL,
fixed_param_store,
is_transform_outline);
session,
NULL,
parse_result.result_tree_,
not_param_info,
params,
NULL,
fixed_param_store,
is_transform_outline);
LOG_INFO("tree", "tree trans", CSJ(ObParserResultPrintWrapper(*(parse_result.result_tree_))));
// resolve
//resolve
test_sql->do_resolve(test_sql_ctx, parse_result, stmt, &params);
// logical_plan
//logical_plan
test_sql->generate_logical_plan(test_sql_ctx, &params, stmt, logical_plan);
// physical plan
//physical plan
test_sql->generate_physical_plan(logical_plan, phy_plan);
}
class TestPCVSet : public ::testing::Test {
class TestPCVSet : public ::testing::Test
{
public:
TestPCVSet()
{}
virtual ~TestPCVSet()
{}
void SetUp()
{}
void TearDown()
{}
TestPCVSet() {}
virtual ~TestPCVSet() {}
void SetUp() {}
void TearDown() {}
private:
// disallow copy
TestPCVSet(const TestPCVSet& other);
TestPCVSet& operator=(const TestPCVSet& other);
//disallow copy
TestPCVSet(const TestPCVSet &other);
TestPCVSet& operator=(const TestPCVSet &other);
};
TEST_F(TestPCVSet, basic)
@ -116,14 +113,18 @@ TEST_F(TestPCVSet, basic)
// just empty array to avoid failure while adding plan
ObSEArray<ObPCConstParamInfo, 4> const_params_constraints;
ObSEArray<ObPCParamEqualInfo, 4> equal_param_constraints;
ObSEArray<ObPCParamPreciseInfo, 4> precise_param_constraints;
ObDList<ObPreCalcExprConstraint> all_pre_calc_constraints_;
ObSEArray<uint64_t, 4> trans_happened_route;
int64_t merged_version = test_sql->get_merged_version();
sql_ctx.schema_guard_ = &(test_sql->get_schema_guard());
sql_ctx.merged_version_ = test_sql->get_merged_version();
sql_ctx.session_info_ = &session;
sql_ctx.all_plan_const_param_constraints_ = &const_params_constraints;
sql_ctx.all_possible_const_param_constraints_ = &const_params_constraints;
sql_ctx.all_equal_param_constraints_ = &equal_param_constraints;
sql_ctx.all_precise_param_constraints_ = &precise_param_constraints;
sql_ctx.all_pre_calc_constraints_ = &all_pre_calc_constraints_;
sql_ctx.trans_happened_route_ = &trans_happened_route;
ASSERT_EQ(OB_SUCCESS, session.init_tenant(ObString(OB_SYS_TENANT_NAME), OB_SYS_TENANT_ID));
exec_ctx.create_physical_plan_ctx();
@ -131,8 +132,8 @@ TEST_F(TestPCVSet, basic)
exec_ctx.set_sql_ctx(&sql_ctx);
exec_ctx.get_sql_ctx()->session_info_ = &session;
exec_ctx.get_task_executor_ctx()->set_min_cluster_version(CLUSTER_VERSION_1500);
ObLogPlan* logical_plan = nullptr;
ObPhysicalPlan* phy_plan = nullptr;
ObLogPlan *logical_plan = nullptr;
ObPhysicalPlan *phy_plan = nullptr;
ASSERT_EQ(OB_SUCCESS, ObPreProcessSysVars::init_sys_var());
EXPECT_TRUE(OB_SUCCESS == session.load_default_sys_variable(false, true));
// when add generate_plan() , change TEST_PLAN_NUM
@ -141,23 +142,21 @@ TEST_F(TestPCVSet, basic)
ObPCVSet pcv_set(plan_cache);
int ret = OB_SUCCESS;
generate_plan(test_sql_ctx,
sql.ptr(),
exec_ctx.get_physical_plan_ctx()->get_param_store_for_update(),
logical_plan,
phy_plan,
session);
sql.ptr(),
exec_ctx.get_physical_plan_ctx()->get_param_store_for_update(),
logical_plan, phy_plan, session);
ret = pcv_set.init(pc_ctx, phy_plan);
ret = pcv_set.add_cache_obj(phy_plan, pc_ctx);
EXPECT_EQ(OB_SUCCESS, ret);
}
} // namespace test
}
int main(int argc, char** argv)
int main(int argc, char **argv)
{
system("rm -rf test_pcv_set.log");
::oceanbase::sql::init_sql_factories();
::testing::InitGoogleTest(&argc, argv);
::testing::InitGoogleTest(&argc,argv);
OB_LOGGER.set_log_level("INFO");
OB_LOGGER.set_file_name("test_pcv_set.log", true);