fix values table print bug

This commit is contained in:
JinmaoLi
2024-11-06 06:47:22 +00:00
committed by ob-robot
parent 8308c30def
commit b51b21995c

View File

@ -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)); LOG_WARN("values table def should not be NULL", K(ret), KP(table_def));
} else { } else {
const int64_t column_cnt = table_def->column_cnt_; const int64_t column_cnt = table_def->column_cnt_;
const int64_t row_cnt = table_def->row_cnt_; if (ObValuesTableDef::ACCESS_EXPR == table_def->access_type_ ||
const ObIArray<ObRawExpr *> &values = table_def->access_exprs_; ObValuesTableDef::FOLD_ACCESS_EXPR == table_def->access_type_) {
if (OB_UNLIKELY(column_cnt <= 0 || values.empty() || values.count() % column_cnt != 0)) { const ObIArray<ObRawExpr *> &values = table_def->access_exprs_;
ret = OB_ERR_UNEXPECTED; if (OB_UNLIKELY(column_cnt <= 0 || values.empty() || values.count() % column_cnt != 0)) {
LOG_WARN("get unexpected error", K(ret), K(column_cnt), K(values)); ret = OB_ERR_UNEXPECTED;
} else { LOG_WARN("get unexpected error", K(ret), K(column_cnt), K(values));
DATA_PRINTF("(VALUES "); } else {
for (int64_t i = 0; OB_SUCC(ret) && i < values.count(); ++i) { DATA_PRINTF("(VALUES ");
if (i % column_cnt == 0) { for (int64_t i = 0; OB_SUCC(ret) && i < values.count(); ++i) {
if (i == 0) { if (i % column_cnt == 0) {
DATA_PRINTF("ROW("); // first row if (i == 0) {
} else { DATA_PRINTF("ROW("); // first row
DATA_PRINTF("), ROW("); // next 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)) {
if (OB_SUCC(ret) && (i + 1) % column_cnt != 0) { OZ (expr_printer_.do_print(values.at(i), T_FROM_SCOPE));
DATA_PRINTF(", "); 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("))"); } else {
DATA_PRINTF(" %.*s", LEN_AND_PTR(table_item.alias_name_)); DATA_PRINTF("%.*s", LEN_AND_PTR(table_item.get_table_name()));
} }
} }
return ret; return ret;