[CP] Dynamically alloc memory for setting variable
This commit is contained in:
@ -1032,8 +1032,24 @@ int ObSPIService::set_variable(ObPLExecCtx *ctx,
|
|||||||
tmp_pos,
|
tmp_pos,
|
||||||
print_params))) {
|
print_params))) {
|
||||||
if (OB_SIZE_OVERFLOW == ret) {
|
if (OB_SIZE_OVERFLOW == ret) {
|
||||||
|
int64_t alloc_len = OB_MAX_SQL_LENGTH;
|
||||||
|
while (OB_SIZE_OVERFLOW == ret) {
|
||||||
ret = OB_SUCCESS;
|
ret = OB_SUCCESS;
|
||||||
new_buf = static_cast<char*>(allocator.alloc(OB_MAX_SQL_LENGTH));
|
if (OB_ISNULL(new_buf)) {
|
||||||
|
new_buf = static_cast<char*>(allocator.alloc(alloc_len));
|
||||||
|
} else {
|
||||||
|
if (alloc_len < (1L << 20)) {
|
||||||
|
alloc_len *= 2;
|
||||||
|
allocator.free(new_buf);
|
||||||
|
new_buf = NULL;
|
||||||
|
new_buf = static_cast<char*>(allocator.alloc(alloc_len));
|
||||||
|
} else {
|
||||||
|
ret = OB_SIZE_OVERFLOW;
|
||||||
|
LOG_WARN("failed to print_plain_str_literal",
|
||||||
|
K(buf), K(new_buf), K(pos), K(tmp_pos), K(ret));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (OB_ISNULL(new_buf)) {
|
if (OB_ISNULL(new_buf)) {
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
LOG_WARN("failed to alloc memory for set sql", K(ret), K(OB_MAX_SQL_LENGTH));
|
LOG_WARN("failed to alloc memory for set sql", K(ret), K(OB_MAX_SQL_LENGTH));
|
||||||
@ -1041,15 +1057,18 @@ int ObSPIService::set_variable(ObPLExecCtx *ctx,
|
|||||||
tmp_pos = 0;
|
tmp_pos = 0;
|
||||||
MEMCPY(new_buf, buf, pos);
|
MEMCPY(new_buf, buf, pos);
|
||||||
if (OB_FAIL(value.print_sql_literal(new_buf + pos,
|
if (OB_FAIL(value.print_sql_literal(new_buf + pos,
|
||||||
OB_MAX_SQL_LENGTH - pos,
|
alloc_len - pos,
|
||||||
tmp_pos,
|
tmp_pos,
|
||||||
print_params))) {
|
print_params))) {
|
||||||
|
if (OB_SIZE_OVERFLOW != ret) {
|
||||||
LOG_WARN("failed to print_plain_str_literal",
|
LOG_WARN("failed to print_plain_str_literal",
|
||||||
K(buf), K(new_buf), K(pos), K(tmp_pos), K(ret));
|
K(buf), K(new_buf), K(pos), K(tmp_pos), K(ret));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sql = new_buf;
|
sql = new_buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_WARN("failed to print_plain_str_literal",
|
LOG_WARN("failed to print_plain_str_literal",
|
||||||
K(buf), K(new_buf), K(pos), K(tmp_pos), K(ret));
|
K(buf), K(new_buf), K(pos), K(tmp_pos), K(ret));
|
||||||
|
|||||||
Reference in New Issue
Block a user