Fix dblink bug

This commit is contained in:
xianyu-w
2023-08-17 17:23:59 +08:00
committed by ob-robot
parent 65b74f7848
commit b6660b6f89

View File

@ -220,9 +220,8 @@ int ObRawExprPrinter::print(ObConstRawExpr *expr)
}
}
/** To preserve the type information of questionmark when it is NULL, print a cast*/
if (OB_FAIL(ret)) {
} else if (is_bool_expr && OB_FAIL(databuff_printf(buf_, buf_len_, *pos_, "1 = "))) {
} else if (is_bool_expr && OB_FAIL(databuff_printf(buf_, buf_len_, *pos_, "(1 = "))) {
/**
* For SQL like "select * from T1 where C1 = 1 and C1 = 2",
* because the where clause is always false,
@ -239,6 +238,9 @@ int ObRawExprPrinter::print(ObConstRawExpr *expr)
expr->get_data_type()))) {
LOG_WARN("fail to write param to buf", K(expr->get_value().get_unknown()), K(expr->get_expr_obj_meta()), K(ret));
}
if (is_bool_expr){
DATA_PRINTF(")");
}
} else if (OB_NOT_NULL(param_store_) && T_QUESTIONMARK == expr->get_expr_type()) {
int64_t idx = expr->get_value().get_unknown();
CK (0 <= idx && idx < param_store_->count());
@ -286,7 +288,7 @@ int ObRawExprPrinter::print(ObConstRawExpr *expr)
* by rewriting startup_filter as "0 = 1" or "1 = 1".
*
*/
if (OB_FAIL(databuff_printf(buf_, buf_len_, *pos_, expr->get_value().get_bool() ? "1 = 1" : "0 = 1"))) {
if (OB_FAIL(databuff_printf(buf_, buf_len_, *pos_, expr->get_value().get_bool() ? "(1 = 1)" : "(0 = 1)"))) {
LOG_WARN("fail to print startup filter", K(ret));
}
} else if (OB_FAIL(expr->get_value().print_sql_literal(buf_, buf_len_, *pos_, print_params_))) {