diff options
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/sql/item.h b/sql/item.h index d04d77da666..3740199698f 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1868,7 +1868,8 @@ public: return type_handler()->charset_for_protocol(this); }; - virtual bool walk(Item_processor processor, bool walk_subquery, void *arg) + virtual bool walk(Item_processor processor, bool walk_subquery, + void *arg, uint depth= 0) { return (this->*processor)(arg); } @@ -2595,15 +2596,17 @@ protected: Item **args, *tmp_arg[2]; uint arg_count; void set_arguments(THD *thd, List<Item> &list); - bool walk_args(Item_processor processor, bool walk_subquery, void *arg) + bool walk_args(Item_processor processor, bool walk_subquery, void *arg, + uint depth ) { for (uint i= 0; i < arg_count; i++) { - if (args[i]->walk(processor, walk_subquery, arg)) + if (args[i]->walk(processor, walk_subquery, arg, depth+1)) return true; } return false; } + bool transform_args(THD *thd, Item_transformer transformer, uchar *arg); void propagate_equal_fields(THD *, const Item::Context &, COND_EQUAL *); bool excl_dep_on_table(table_map tab_map) @@ -5294,12 +5297,20 @@ public: Item_func_or_sum(THD *thd, List<Item> &list): Item_result_field(thd), Item_args(thd, list) { } bool with_subquery() const { DBUG_ASSERT(fixed); return m_with_subquery; } - bool walk(Item_processor processor, bool walk_subquery, void *arg) + +#define MAX_WALK_DEPTH 70 + bool walk(Item_processor processor, bool walk_subquery, void *arg, uint depth) { - if (walk_args(processor, walk_subquery, arg)) + if (depth > MAX_WALK_DEPTH) + { + my_error( ER_DERIVED_RECURSION_LIMIT, MYF(0), MAX_WALK_DEPTH, "derived limit" ); + return true; + } + if (walk_args(processor, walk_subquery, arg, depth+1)) return true; return (this->*processor)(arg); } + /* This method is used for debug purposes to print the name of an item to the debug log. The second use of this method is as @@ -5488,10 +5499,11 @@ public: } bool is_json_type() { return (*ref)->is_json_type(); } - bool walk(Item_processor processor, bool walk_subquery, void *arg) + bool walk(Item_processor processor, bool walk_subquery, void *arg, + uint depth= 0) { if (ref && *ref) - return (*ref)->walk(processor, walk_subquery, arg) || + return (*ref)->walk(processor, walk_subquery, arg, depth+1) || (this->*processor)(arg); else return FALSE; @@ -5788,9 +5800,10 @@ public: } bool const_item() const { return orig_item->const_item(); } table_map not_null_tables() const { return orig_item->not_null_tables(); } - bool walk(Item_processor processor, bool walk_subquery, void *arg) + bool walk(Item_processor processor, bool walk_subquery, void *arg, + uint depth= 0) { - return orig_item->walk(processor, walk_subquery, arg) || + return orig_item->walk(processor, walk_subquery, arg, depth+1) || (this->*processor)(arg); } bool enumerate_field_refs_processor(void *arg) @@ -5899,9 +5912,10 @@ public: return (*ref)->const_item() && (null_ref_table == NO_NULL_TABLE); } TABLE *get_null_ref_table() const { return null_ref_table; } - bool walk(Item_processor processor, bool walk_subquery, void *arg) + bool walk(Item_processor processor, bool walk_subquery, void *arg, + uint depth= 0) { - return (*ref)->walk(processor, walk_subquery, arg) || + return (*ref)->walk(processor, walk_subquery, arg, depth+1) || (this->*processor)(arg); } bool view_used_tables_processor(void *arg) @@ -6277,9 +6291,10 @@ public: virtual double val_real() = 0; virtual longlong val_int() = 0; virtual int save_in_field(Field *field, bool no_conversions) = 0; - bool walk(Item_processor processor, bool walk_subquery, void *args) + bool walk(Item_processor processor, bool walk_subquery, void *args, + uint depth= 0) { - return (item->walk(processor, walk_subquery, args)) || + return (item->walk(processor, walk_subquery, args, depth+1)) || (this->*processor)(args); } }; @@ -6546,9 +6561,10 @@ public: bool check_func_default_processor(void *arg) { return true; } bool register_field_in_read_map(void *arg); - bool walk(Item_processor processor, bool walk_subquery, void *args) + bool walk(Item_processor processor, bool walk_subquery, void *args, + uint depth= 0) { - return (arg && arg->walk(processor, walk_subquery, args)) || + return (arg && arg->walk(processor, walk_subquery, args, depth+1)) || (this->*processor)(args); } @@ -6714,9 +6730,10 @@ public: Item_field *field_for_view_update() { return 0; } - bool walk(Item_processor processor, bool walk_subquery, void *args) + bool walk(Item_processor processor, bool walk_subquery, void *args, + uint depth= 0) { - return arg->walk(processor, walk_subquery, args) || + return arg->walk(processor, walk_subquery, args, depth+1) || (this->*processor)(args); } bool check_partition_func_processor(void *int_arg) {return TRUE;} @@ -6972,11 +6989,12 @@ public: return example->is_expensive_processor(arg); } virtual void set_null(); - bool walk(Item_processor processor, bool walk_subquery, void *arg) + bool walk(Item_processor processor, bool walk_subquery, void *arg, + uint depth= 0) { if (arg == STOP_PTR) return FALSE; - if (example && example->walk(processor, walk_subquery, arg)) + if (example && example->walk(processor, walk_subquery, arg, depth+1)) return TRUE; return (this->*processor)(arg); } @@ -7682,9 +7700,10 @@ public: { m_item->update_used_tables(); } bool const_item() const { return m_item->const_item(); } table_map not_null_tables() const { return m_item->not_null_tables(); } - bool walk(Item_processor processor, bool walk_subquery, void *arg) + bool walk(Item_processor processor, bool walk_subquery, void *arg, + uint depth= 0) { - return m_item->walk(processor, walk_subquery, arg) || + return m_item->walk(processor, walk_subquery, arg, depth+1) || (this->*processor)(arg); } bool enumerate_field_refs_processor(void *arg) |