Fix remove_const bug

This commit is contained in:
2149
2023-05-23 10:41:34 +00:00
committed by ob-robot
parent 795f695156
commit 03fdde5756
4 changed files with 42 additions and 34 deletions

View File

@ -21,7 +21,7 @@ namespace oceanbase
namespace sql
{
ObRawExprReplacer::ObRawExprReplacer()
: replace_happened_(false)
: replace_happened_(false), skip_bool_param_mysql_(false)
{}
ObRawExprReplacer::~ObRawExprReplacer()
@ -117,6 +117,15 @@ int ObRawExprReplacer::visit(ObOpRawExpr &expr)
for (int64_t i = 0; OB_SUCC(ret) && i < count; ++i) {
if (OB_FAIL(check_need_replace(expr.get_param_expr(i), new_expr, need_replace))) {
LOG_WARN("failed to check need replace", K(ret));
} else if (is_skip_bool_param_mysql()) {
if (T_OP_IS == expr.get_expr_type() && i == 1) {
//do nothing
} else if (T_OP_IS_NOT == expr.get_expr_type() && i == 1) {
//do nothing
} else if (need_replace) {
ret = expr.replace_param_expr(i, new_expr);
replace_happened_ = true;
}
} else if (need_replace) {
ret = expr.replace_param_expr(i, new_expr);
replace_happened_ = true;

View File

@ -54,6 +54,8 @@ public:
virtual bool skip_child(ObRawExpr &expr) override;
bool get_replace_happened() const { return replace_happened_; }
void set_skip_bool_param_mysql(bool skip) { skip_bool_param_mysql_ = skip; }
bool is_skip_bool_param_mysql() { return skip_bool_param_mysql_; }
int add_replace_expr(ObRawExpr *from_expr,
ObRawExpr *to_expr);
int add_replace_exprs(const ObIArray<ObRawExpr *> &from_exprs,
@ -78,6 +80,9 @@ private:
hash::ObHashMap<uint64_t, uint64_t> expr_replace_map_;
bool replace_happened_;
//If true, skip param epxrs which are resolved as flags instead of exprs in mysql.
//(e.g. the second param of IS expr)
bool skip_bool_param_mysql_;
};
} // end namespace sql