Fix udt bugs
This commit is contained in:
@ -1956,6 +1956,7 @@ char ObSQLUtils::find_first_empty_char(const ObString &sql)
|
||||
}
|
||||
|
||||
int ObSQLUtils::reconstruct_sql(ObIAllocator &allocator, const ObStmt *stmt, ObString &sql,
|
||||
ObSchemaGetterGuard *schema_guard,
|
||||
ObObjPrintParams print_params)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -1972,14 +1973,14 @@ int ObSQLUtils::reconstruct_sql(ObIAllocator &allocator, const ObStmt *stmt, ObS
|
||||
//First try 64K buf on the stack, if it fails, then try 128K.
|
||||
//If it still fails, allocate 256K from the heap. If it continues to fail, expand twice each time.
|
||||
SMART_VAR(char[OB_MAX_SQL_LENGTH], buf) {
|
||||
if (OB_FAIL(print_sql(allocator, buf, sizeof(buf), stmt, sql, print_params))) {
|
||||
if (OB_FAIL(print_sql(allocator, buf, sizeof(buf), stmt, sql, schema_guard, print_params))) {
|
||||
LOG_WARN("failed to print sql", K(sizeof(buf)), K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SIZE_OVERFLOW == ret) {
|
||||
ret = OB_SUCCESS;
|
||||
SMART_VAR(char[OB_MAX_SQL_LENGTH * 2], buf) {
|
||||
if (OB_FAIL(print_sql(allocator, buf, sizeof(buf), stmt, sql, print_params))) {
|
||||
if (OB_FAIL(print_sql(allocator, buf, sizeof(buf), stmt, sql, schema_guard, print_params))) {
|
||||
LOG_WARN("failed to print sql", K(sizeof(buf)), K(ret));
|
||||
}
|
||||
}
|
||||
@ -1994,7 +1995,7 @@ int ObSQLUtils::reconstruct_sql(ObIAllocator &allocator, const ObStmt *stmt, ObS
|
||||
if (OB_ISNULL(buf = static_cast<char*>(alloc.alloc(length)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc memory for set sql", K(ret), K(length));
|
||||
} else if (OB_FAIL(print_sql(allocator, buf, length, stmt, sql, print_params))) {
|
||||
} else if (OB_FAIL(print_sql(allocator, buf, length, stmt, sql, schema_guard, print_params))) {
|
||||
LOG_WARN("failed to print sql", K(length), K(i), K(ret));
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
@ -2013,6 +2014,7 @@ int ObSQLUtils::print_sql(ObIAllocator &allocator,
|
||||
int64_t buf_len,
|
||||
const ObStmt *stmt,
|
||||
ObString &sql,
|
||||
ObSchemaGetterGuard *schema_guard,
|
||||
ObObjPrintParams print_params)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2022,7 +2024,7 @@ int ObSQLUtils::print_sql(ObIAllocator &allocator,
|
||||
case stmt::T_SELECT: {
|
||||
bool is_set_subquery = false;
|
||||
ObSelectStmtPrinter printer(buf, buf_len, &pos, static_cast<const ObSelectStmt*>(stmt),
|
||||
print_params, NULL, is_set_subquery);
|
||||
schema_guard, print_params, NULL, is_set_subquery);
|
||||
if (OB_FAIL(printer.do_print())) {
|
||||
LOG_WARN("fail to print select stmt", K(ret));
|
||||
} else if (OB_FAIL(ob_write_string(allocator, ObString(pos, buf), sql))) {
|
||||
@ -2032,7 +2034,8 @@ int ObSQLUtils::print_sql(ObIAllocator &allocator,
|
||||
break;
|
||||
case stmt::T_INSERT_ALL: {
|
||||
ObInsertAllStmtPrinter printer(buf, buf_len, &pos,
|
||||
static_cast<const ObInsertAllStmt*>(stmt), print_params);
|
||||
static_cast<const ObInsertAllStmt*>(stmt),
|
||||
schema_guard, print_params);
|
||||
if (OB_FAIL(printer.do_print())) {
|
||||
LOG_WARN("fail to print insert stmt", K(ret));
|
||||
} else if (OB_FAIL(ob_write_string(allocator, ObString(pos, buf), sql))) {
|
||||
@ -2042,7 +2045,8 @@ int ObSQLUtils::print_sql(ObIAllocator &allocator,
|
||||
break;
|
||||
case stmt::T_INSERT: {
|
||||
ObInsertStmtPrinter printer(buf, buf_len, &pos,
|
||||
static_cast<const ObInsertStmt*>(stmt), print_params);
|
||||
static_cast<const ObInsertStmt*>(stmt),
|
||||
schema_guard, print_params);
|
||||
if (OB_FAIL(printer.do_print())) {
|
||||
LOG_WARN("fail to print insert stmt", K(ret));
|
||||
} else if (OB_FAIL(ob_write_string(allocator, ObString(pos, buf), sql))) {
|
||||
@ -2056,7 +2060,8 @@ int ObSQLUtils::print_sql(ObIAllocator &allocator,
|
||||
break;
|
||||
case stmt::T_DELETE: {
|
||||
ObDeleteStmtPrinter printer(buf, buf_len, &pos,
|
||||
static_cast<const ObDeleteStmt*>(stmt), print_params);
|
||||
static_cast<const ObDeleteStmt*>(stmt),
|
||||
schema_guard, print_params);
|
||||
if (OB_FAIL(printer.do_print())) {
|
||||
LOG_WARN("fail to print delete stmt", K(ret));
|
||||
} else if (OB_FAIL(ob_write_string(allocator, ObString(pos, buf), sql))) {
|
||||
@ -2066,7 +2071,8 @@ int ObSQLUtils::print_sql(ObIAllocator &allocator,
|
||||
break;
|
||||
case stmt::T_UPDATE: {
|
||||
ObUpdateStmtPrinter printer(buf, buf_len, &pos,
|
||||
static_cast<const ObUpdateStmt*>(stmt), print_params);
|
||||
static_cast<const ObUpdateStmt*>(stmt),
|
||||
schema_guard, print_params);
|
||||
if (OB_FAIL(printer.do_print())) {
|
||||
LOG_WARN("fail to print update stmt", K(ret));
|
||||
} else if (OB_FAIL(ob_write_string(allocator, ObString(pos, buf), sql))) {
|
||||
@ -2076,7 +2082,8 @@ int ObSQLUtils::print_sql(ObIAllocator &allocator,
|
||||
break;
|
||||
case stmt::T_MERGE: {
|
||||
ObMergeStmtPrinter printer(buf, buf_len, &pos,
|
||||
static_cast<const ObMergeStmt*>(stmt), print_params);
|
||||
static_cast<const ObMergeStmt*>(stmt),
|
||||
schema_guard, print_params);
|
||||
if (OB_FAIL(printer.do_print())) {
|
||||
LOG_WARN("failed to print merge stmt", K(ret));
|
||||
} else if (OB_FAIL(ob_write_string(allocator, ObString(pos, buf), sql))) {
|
||||
|
||||
Reference in New Issue
Block a user