fix values table print bug
This commit is contained in:
@ -525,30 +525,34 @@ int ObDMLStmtPrinter::print_values_table(const TableItem &table_item, bool no_pr
|
||||
LOG_WARN("values table def should not be NULL", K(ret), KP(table_def));
|
||||
} else {
|
||||
const int64_t column_cnt = table_def->column_cnt_;
|
||||
const int64_t row_cnt = table_def->row_cnt_;
|
||||
const ObIArray<ObRawExpr *> &values = table_def->access_exprs_;
|
||||
if (OB_UNLIKELY(column_cnt <= 0 || values.empty() || values.count() % column_cnt != 0)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(column_cnt), K(values));
|
||||
} else {
|
||||
DATA_PRINTF("(VALUES ");
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < values.count(); ++i) {
|
||||
if (i % column_cnt == 0) {
|
||||
if (i == 0) {
|
||||
DATA_PRINTF("ROW("); // first row
|
||||
} else {
|
||||
DATA_PRINTF("), ROW("); // next row
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
OZ (expr_printer_.do_print(values.at(i), T_FROM_SCOPE));
|
||||
if (OB_SUCC(ret) && (i + 1) % column_cnt != 0) {
|
||||
DATA_PRINTF(", ");
|
||||
if (ObValuesTableDef::ACCESS_EXPR == table_def->access_type_ ||
|
||||
ObValuesTableDef::FOLD_ACCESS_EXPR == table_def->access_type_) {
|
||||
const ObIArray<ObRawExpr *> &values = table_def->access_exprs_;
|
||||
if (OB_UNLIKELY(column_cnt <= 0 || values.empty() || values.count() % column_cnt != 0)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(column_cnt), K(values));
|
||||
} else {
|
||||
DATA_PRINTF("(VALUES ");
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < values.count(); ++i) {
|
||||
if (i % column_cnt == 0) {
|
||||
if (i == 0) {
|
||||
DATA_PRINTF("ROW("); // first row
|
||||
} else {
|
||||
DATA_PRINTF("), ROW("); // next row
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
OZ (expr_printer_.do_print(values.at(i), T_FROM_SCOPE));
|
||||
if (OB_SUCC(ret) && (i + 1) % column_cnt != 0) {
|
||||
DATA_PRINTF(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
DATA_PRINTF("))");
|
||||
DATA_PRINTF(" %.*s", LEN_AND_PTR(table_item.alias_name_));
|
||||
}
|
||||
DATA_PRINTF("))");
|
||||
DATA_PRINTF(" %.*s", LEN_AND_PTR(table_item.alias_name_));
|
||||
} else {
|
||||
DATA_PRINTF("%.*s", LEN_AND_PTR(table_item.get_table_name()));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user