[CP] fix core when no memory
This commit is contained in:
@ -129,7 +129,7 @@ int count_child(ParseNode* root, void* malloc_pool, int* count)
|
|||||||
do {
|
do {
|
||||||
ParseNode *tree = NULL;
|
ParseNode *tree = NULL;
|
||||||
if (NULL == stack_top || NULL == (tree = (ParseNode *)stack_top->val_)) {
|
if (NULL == stack_top || NULL == (tree = (ParseNode *)stack_top->val_)) {
|
||||||
ret = OB_PARSER_ERR_NO_MEMORY;
|
ret = OB_PARSER_ERR_UNEXPECTED;
|
||||||
(void)fprintf(stderr, "ERROR invalid null argument\n");
|
(void)fprintf(stderr, "ERROR invalid null argument\n");
|
||||||
} else {
|
} else {
|
||||||
stack_top = stack_top->next_;
|
stack_top = stack_top->next_;
|
||||||
@ -142,7 +142,7 @@ int count_child(ParseNode* root, void* malloc_pool, int* count)
|
|||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
if (NULL == tree->children_) {
|
if (NULL == tree->children_) {
|
||||||
ret = OB_PARSER_ERR_NO_MEMORY;
|
ret = OB_PARSER_ERR_UNEXPECTED;
|
||||||
(void)fprintf(stderr, "ERROR invalid null children\n");
|
(void)fprintf(stderr, "ERROR invalid null children\n");
|
||||||
}
|
}
|
||||||
ParserLinkNode* tmp_node = NULL;
|
ParserLinkNode* tmp_node = NULL;
|
||||||
@ -171,7 +171,7 @@ int merge_child(ParseNode* node, void* malloc_pool, ParseNode* source_tree, int*
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
ParserLinkNode* stack_top = NULL;
|
ParserLinkNode* stack_top = NULL;
|
||||||
if (OB_UNLIKELY(NULL == node || NULL == index)) {
|
if (OB_UNLIKELY(NULL == node || NULL == index)) {
|
||||||
ret = OB_PARSER_ERR_NO_MEMORY;
|
ret = OB_PARSER_ERR_UNEXPECTED;
|
||||||
(void)fprintf(stderr, "ERROR node%p or index:%p is NULL\n", node, index);
|
(void)fprintf(stderr, "ERROR node%p or index:%p is NULL\n", node, index);
|
||||||
} else if (NULL == source_tree) {
|
} else if (NULL == source_tree) {
|
||||||
// do nothing
|
// do nothing
|
||||||
@ -184,7 +184,7 @@ int merge_child(ParseNode* node, void* malloc_pool, ParseNode* source_tree, int*
|
|||||||
do {
|
do {
|
||||||
ParseNode *tree = NULL;
|
ParseNode *tree = NULL;
|
||||||
if (NULL == stack_top || NULL == (tree = (ParseNode *)stack_top->val_)) {
|
if (NULL == stack_top || NULL == (tree = (ParseNode *)stack_top->val_)) {
|
||||||
ret = OB_PARSER_ERR_NO_MEMORY;
|
ret = OB_PARSER_ERR_UNEXPECTED;
|
||||||
(void)fprintf(stderr, "ERROR invalid null argument\n");
|
(void)fprintf(stderr, "ERROR invalid null argument\n");
|
||||||
} else {
|
} else {
|
||||||
// pop stack
|
// pop stack
|
||||||
@ -194,11 +194,11 @@ int merge_child(ParseNode* node, void* malloc_pool, ParseNode* source_tree, int*
|
|||||||
// do nothing
|
// do nothing
|
||||||
} else if (T_LINK_NODE != tree->type_) {
|
} else if (T_LINK_NODE != tree->type_) {
|
||||||
if (OB_UNLIKELY(*index < 0 || *index >= node->num_child_)) {
|
if (OB_UNLIKELY(*index < 0 || *index >= node->num_child_)) {
|
||||||
ret = OB_PARSER_ERR_NO_MEMORY;
|
ret = OB_PARSER_ERR_UNEXPECTED;
|
||||||
(void)fprintf(
|
(void)fprintf(
|
||||||
stderr, "ERROR invalid index: %d, num_child:%d\n tree: %d", *index, node->num_child_, tree->type_);
|
stderr, "ERROR invalid index: %d, num_child:%d\n tree: %d", *index, node->num_child_, tree->type_);
|
||||||
} else if (NULL == node->children_) {
|
} else if (NULL == node->children_) {
|
||||||
ret = OB_PARSER_ERR_NO_MEMORY;
|
ret = OB_PARSER_ERR_UNEXPECTED;
|
||||||
(void)fprintf(stderr, "ERROR invalid null children pointer\n");
|
(void)fprintf(stderr, "ERROR invalid null children pointer\n");
|
||||||
} else {
|
} else {
|
||||||
node->children_[*index] = tree;
|
node->children_[*index] = tree;
|
||||||
@ -207,7 +207,7 @@ int merge_child(ParseNode* node, void* malloc_pool, ParseNode* source_tree, int*
|
|||||||
} else if (tree->num_child_ <= 0) {
|
} else if (tree->num_child_ <= 0) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if (NULL == tree->children_) {
|
} else if (NULL == tree->children_) {
|
||||||
ret = OB_PARSER_ERR_NO_MEMORY;
|
ret = OB_PARSER_ERR_UNEXPECTED;
|
||||||
(void)fprintf(stderr, "ERROR invalid children pointer\n");
|
(void)fprintf(stderr, "ERROR invalid children pointer\n");
|
||||||
} else {
|
} else {
|
||||||
ParserLinkNode* tmp_node = NULL;
|
ParserLinkNode* tmp_node = NULL;
|
||||||
|
|||||||
@ -256,23 +256,28 @@ int ObTransformUtils::add_new_joined_table(ObTransformerCtx* ctx, ObDMLStmt& stm
|
|||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("transform context is invalid", K(ret), K(ctx), K(stmt), K(left_table), K(right_table));
|
LOG_WARN("transform context is invalid", K(ret), K(ctx), K(stmt), K(left_table), K(right_table));
|
||||||
} else {
|
} else {
|
||||||
JoinedTable* joined_table = static_cast<JoinedTable*>(ctx->allocator_->alloc(sizeof(JoinedTable)));
|
JoinedTable *joined_table = static_cast<JoinedTable *>(ctx->allocator_->alloc(sizeof(JoinedTable)));
|
||||||
joined_table = new (joined_table) JoinedTable();
|
if (OB_ISNULL(joined_table)) {
|
||||||
joined_table->type_ = TableItem::JOINED_TABLE;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
joined_table->table_id_ = stmt.get_query_ctx()->available_tb_id_--;
|
LOG_WARN("fail to allocate memory", K(ret));
|
||||||
joined_table->joined_type_ = join_type;
|
|
||||||
joined_table->left_table_ = left_table;
|
|
||||||
joined_table->right_table_ = right_table;
|
|
||||||
if (OB_FAIL(joined_table->join_conditions_.assign(joined_conds))) {
|
|
||||||
LOG_WARN("failed to push back join conditions", K(ret));
|
|
||||||
} else if (OB_FAIL(ObTransformUtils::add_joined_table_single_table_ids(*joined_table, *left_table))) {
|
|
||||||
LOG_WARN("failed to add left table ids", K(ret));
|
|
||||||
} else if (OB_FAIL(ObTransformUtils::add_joined_table_single_table_ids(*joined_table, *right_table))) {
|
|
||||||
LOG_WARN("failed to add right table ids", K(ret));
|
|
||||||
} else if (add_table && OB_FAIL(stmt.add_joined_table(joined_table))) {
|
|
||||||
LOG_WARN("failed to add joined table into stmt", K(ret));
|
|
||||||
} else {
|
} else {
|
||||||
new_join_table = joined_table;
|
joined_table = new (joined_table) JoinedTable();
|
||||||
|
joined_table->type_ = TableItem::JOINED_TABLE;
|
||||||
|
joined_table->table_id_ = stmt.get_query_ctx()->available_tb_id_--;
|
||||||
|
joined_table->joined_type_ = join_type;
|
||||||
|
joined_table->left_table_ = left_table;
|
||||||
|
joined_table->right_table_ = right_table;
|
||||||
|
if (OB_FAIL(joined_table->join_conditions_.assign(joined_conds))) {
|
||||||
|
LOG_WARN("failed to push back join conditions", K(ret));
|
||||||
|
} else if (OB_FAIL(ObTransformUtils::add_joined_table_single_table_ids(*joined_table, *left_table))) {
|
||||||
|
LOG_WARN("failed to add left table ids", K(ret));
|
||||||
|
} else if (OB_FAIL(ObTransformUtils::add_joined_table_single_table_ids(*joined_table, *right_table))) {
|
||||||
|
LOG_WARN("failed to add right table ids", K(ret));
|
||||||
|
} else if (add_table && OB_FAIL(stmt.add_joined_table(joined_table))) {
|
||||||
|
LOG_WARN("failed to add joined table into stmt", K(ret));
|
||||||
|
} else {
|
||||||
|
new_join_table = joined_table;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user