From ef163ff0fc200c8c647b48e1390d187ebffed2ba Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Nov 2003 12:28:36 +0200 Subject: after review fix mysql-test/r/func_str.result: new results sql/item.cc: charset changed printing string moved to String sql/item_cmpfunc.cc: new comparation class builder to avoid long switch new print_agrs used sql/item_cmpfunc.h: new comparation class builder to avoid long switch sql/item_func.cc: new print_agrs sql/item_func.h: new print_agrs sql/item_strfunc.cc: new print_agrs sql/item_subselect.cc: new comparation class builder to avoid long switch sql/item_subselect.h: new comparation class builder to avoid long switch sql/item_timefunc.cc: charset changed sql/mysql_priv.h: new comparation class builder to avoid long switch sql/mysqld.cc: new comparation class builder to avoid long switch sql/sql_parse.cc: new comparation class builder to avoid long switch sql/sql_string.cc: string printing moved to String class sql/sql_string.h: string printing moved to String class sql/sql_yacc.yy: birect class creation where it is possible --- sql/item_cmpfunc.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 7 deletions(-) (limited to 'sql/item_cmpfunc.h') diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 3f73c7736da..081374345d8 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -109,6 +109,69 @@ public: Item_cache **get_cache() { return &cache; } }; +class Comp_creator +{ +public: + virtual Item_bool_func2* create(Item *a, Item *b) const = 0; + virtual const char* symbol(bool invert) const = 0; + virtual bool eqne_op() const = 0; + virtual bool l_op() const = 0; +}; + +class Eq_creator :public Comp_creator +{ +public: + virtual Item_bool_func2* create(Item *a, Item *b) const; + virtual const char* symbol(bool invert) const { return invert? "<>" : "="; } + virtual bool eqne_op() const { return 1; } + virtual bool l_op() const { return 0; } +}; + +class Ne_creator :public Comp_creator +{ +public: + virtual Item_bool_func2* create(Item *a, Item *b) const; + virtual const char* symbol(bool invert) const { return invert? "=" : "<>"; } + virtual bool eqne_op() const { return 1; } + virtual bool l_op() const { return 0; } +}; + +class Gt_creator :public Comp_creator +{ +public: + virtual Item_bool_func2* create(Item *a, Item *b) const; + virtual const char* symbol(bool invert) const { return invert? "<=" : ">"; } + virtual bool eqne_op() const { return 0; } + virtual bool l_op() const { return 0; } +}; + +class Lt_creator :public Comp_creator +{ +public: + virtual Item_bool_func2* create(Item *a, Item *b) const; + virtual const char* symbol(bool invert) const { return invert? ">=" : "<"; } + virtual bool eqne_op() const { return 0; } + virtual bool l_op() const { return 1; } +}; + +class Ge_creator :public Comp_creator +{ +public: + virtual Item_bool_func2* create(Item *a, Item *b) const; + virtual const char* symbol(bool invert) const { return invert? "<" : ">="; } + virtual bool eqne_op() const { return 0; } + virtual bool l_op() const { return 0; } +}; + +class Le_creator :public Comp_creator +{ +public: + virtual Item_bool_func2* create(Item *a, Item *b) const; + virtual const char* symbol(bool invert) const { return invert? ">" : "<="; } + virtual bool eqne_op() const { return 0; } + virtual bool l_op() const { return 1; } +}; + class Item_bool_func2 :public Item_int_func { /* Bool with 2 string args */ protected: @@ -129,13 +192,6 @@ public: void print(String *str) { Item_func::print_op(str); } bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); } - static Item_bool_func2* eq_creator(Item *a, Item *b); - static Item_bool_func2* ne_creator(Item *a, Item *b); - static Item_bool_func2* gt_creator(Item *a, Item *b); - static Item_bool_func2* lt_creator(Item *a, Item *b); - static Item_bool_func2* ge_creator(Item *a, Item *b); - static Item_bool_func2* le_creator(Item *a, Item *b); - friend class Arg_comparator; }; -- cgit v1.2.1