diff options
author | unknown <bell@sanja.is.com.ua> | 2002-11-15 20:32:09 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2002-11-15 20:32:09 +0200 |
commit | 3f742831211a4d53d97c5ac6ee402b4782de8776 (patch) | |
tree | bf6f2bb43cd9c75eef36dd94166c76c6b9d402af /sql/item_cmpfunc.h | |
parent | 5a8c6a33c22ed68acdccbde0649420cd8a80ad9d (diff) | |
download | mariadb-git-3f742831211a4d53d97c5ac6ee402b4782de8776.tar.gz |
basic row Items (SCRUM)
include/mysql_com.h:
basic row Items
include/mysqld_error.h:
more wide error mening
libmysqld/Makefile.am:
basic row Items
mysql-test/r/subselect.result:
more wide error mening
sql/Makefile.am:
basic row Items
sql/filesort.cc:
basic row Items
sql/item.cc:
basic row Items
sql/item.h:
basic row Items
sql/item_cmpfunc.cc:
basic row Items
sql/item_cmpfunc.h:
basic row Items
sql/item_func.cc:
basic row Items
sql/item_func.h:
basic row Items
sql/item_strfunc.cc:
basic row Items
sql/item_strfunc.h:
basic row Items
sql/item_subselect.cc:
basic row Items
sql/item_sum.cc:
basic row Items
sql/share/czech/errmsg.txt:
more wide error mening
sql/share/danish/errmsg.txt:
more wide error mening
sql/share/dutch/errmsg.txt:
more wide error mening
sql/share/english/errmsg.txt:
more wide error mening
sql/share/estonian/errmsg.txt:
more wide error mening
sql/share/french/errmsg.txt:
more wide error mening
sql/share/german/errmsg.txt:
more wide error mening
sql/share/greek/errmsg.txt:
more wide error mening
sql/share/hungarian/errmsg.txt:
more wide error mening
sql/share/italian/errmsg.txt:
more wide error mening
sql/share/japanese/errmsg.txt:
more wide error mening
sql/share/korean/errmsg.txt:
more wide error mening
sql/share/norwegian-ny/errmsg.txt:
more wide error mening
sql/share/norwegian/errmsg.txt:
more wide error mening
sql/share/polish/errmsg.txt:
more wide error mening
sql/share/portuguese/errmsg.txt:
more wide error mening
sql/share/romanian/errmsg.txt:
more wide error mening
sql/share/russian/errmsg.txt:
more wide error mening
sql/share/serbian/errmsg.txt:
more wide error mening
sql/share/slovak/errmsg.txt:
more wide error mening
sql/share/spanish/errmsg.txt:
more wide error mening
sql/share/swedish/errmsg.txt:
more wide error mening
sql/share/ukrainian/errmsg.txt:
more wide error mening
sql/sql_base.cc:
fix_fields error handling
sql/sql_lex.cc:
basic row Items
sql/sql_select.cc:
basic row Items
sql/sql_yacc.yy:
basic row Items
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r-- | sql/item_cmpfunc.h | 105 |
1 files changed, 86 insertions, 19 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 489d54ae786..dd1cf8d6da6 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -30,6 +30,61 @@ public: void fix_length_and_dec() { decimals=0; max_length=1; } }; +class Item_bool_func2; + +class Compare_func +{ +protected: + Item_bool_func2 *owner; +public: + static void *operator new(size_t size) + { + return (void*) sql_alloc((uint) size); + } + static void operator delete(void *ptr,size_t size) {} + + Compare_func(Item_bool_func2 *o) { owner= o; } + virtual ~Compare_func() {}; + virtual int compare(Item *, Item*)= 0; + + static Compare_func* get_compare_func(Item_bool_func2 *owner, + Item* a, Item* b); +}; + +class Compare_func_string: public Compare_func +{ +public: + Compare_func_string(Item_bool_func2 *owner): Compare_func(owner) {}; + int compare(Item *, Item*); +}; + +class Compare_func_real: public Compare_func +{ +public: + Compare_func_real(Item_bool_func2 *owner): Compare_func(owner) {}; + int compare(Item *, Item*); +}; + +class Compare_func_int: public Compare_func +{ +public: + Compare_func_int(Item_bool_func2 *owner): Compare_func(owner) {}; + int compare(Item *, Item*); +}; + +class Compare_func_row: public Compare_func +{ + Compare_func **cmp_func; +public: + Compare_func_row(Item_bool_func2 *owner, Item* a, Item* b); + ~Compare_func_row() + { + if(cmp_func) + sql_element_free(cmp_func); + } + int compare(Item *, Item*); +}; + class Item_bool_func2 :public Item_int_func { /* Bool with 2 string args */ protected: @@ -37,18 +92,28 @@ protected: public: Item_bool_func2(Item *a,Item *b) :Item_int_func(a,b) {} void fix_length_and_dec(); - void set_cmp_func(Item_result type); - int (Item_bool_func2::*cmp_func)(); - int compare_string(); /* compare arg[0] & arg[1] */ - int compare_real(); /* compare arg[0] & arg[1] */ - int compare_int(); /* compare arg[0] & arg[1] */ + Compare_func *cmp_func; + void set_cmp_func(Item *a, Item *b) + { + cmp_func= Compare_func::get_compare_func(this, args[0], args[1]); + } optimize_type select_optimize() const { return OPTIMIZE_OP; } virtual enum Functype rev_functype() const { return UNKNOWN_FUNC; } bool have_rev_func() const { return rev_functype() != UNKNOWN_FUNC; } void print(String *str) { Item_func::print_op(str); } bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); } + + friend class Compare_func_string; }; +class Item_bool_rowready_func2 :public Item_bool_func2 +{ +public: + Item_bool_rowready_func2(Item *a,Item *b) :Item_bool_func2(a,b) + { + allowed_arg_cols= a->cols(); + } +}; class Item_func_not :public Item_bool_func { @@ -58,10 +123,10 @@ public: const char *func_name() const { return "not"; } }; -class Item_func_eq :public Item_bool_func2 +class Item_func_eq :public Item_bool_rowready_func2 { public: - Item_func_eq(Item *a,Item *b) :Item_bool_func2(a,b) { }; + Item_func_eq(Item *a,Item *b) :Item_bool_rowready_func2(a,b) { }; longlong val_int(); enum Functype functype() const { return EQ_FUNC; } enum Functype rev_functype() const { return EQ_FUNC; } @@ -83,10 +148,10 @@ public: }; -class Item_func_ge :public Item_bool_func2 +class Item_func_ge :public Item_bool_rowready_func2 { public: - Item_func_ge(Item *a,Item *b) :Item_bool_func2(a,b) { }; + Item_func_ge(Item *a,Item *b) :Item_bool_rowready_func2(a,b) { }; longlong val_int(); enum Functype functype() const { return GE_FUNC; } enum Functype rev_functype() const { return LE_FUNC; } @@ -95,10 +160,10 @@ public: }; -class Item_func_gt :public Item_bool_func2 +class Item_func_gt :public Item_bool_rowready_func2 { public: - Item_func_gt(Item *a,Item *b) :Item_bool_func2(a,b) { }; + Item_func_gt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) { }; longlong val_int(); enum Functype functype() const { return GT_FUNC; } enum Functype rev_functype() const { return LT_FUNC; } @@ -107,10 +172,10 @@ public: }; -class Item_func_le :public Item_bool_func2 +class Item_func_le :public Item_bool_rowready_func2 { public: - Item_func_le(Item *a,Item *b) :Item_bool_func2(a,b) { }; + Item_func_le(Item *a,Item *b) :Item_bool_rowready_func2(a,b) { }; longlong val_int(); enum Functype functype() const { return LE_FUNC; } enum Functype rev_functype() const { return GE_FUNC; } @@ -119,10 +184,10 @@ public: }; -class Item_func_lt :public Item_bool_func2 +class Item_func_lt :public Item_bool_rowready_func2 { public: - Item_func_lt(Item *a,Item *b) :Item_bool_func2(a,b) { } + Item_func_lt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) { } longlong val_int(); enum Functype functype() const { return LT_FUNC; } enum Functype rev_functype() const { return GT_FUNC; } @@ -131,10 +196,10 @@ public: }; -class Item_func_ne :public Item_bool_func2 +class Item_func_ne :public Item_bool_rowready_func2 { public: - Item_func_ne(Item *a,Item *b) :Item_bool_func2(a,b) { } + Item_func_ne(Item *a,Item *b) :Item_bool_rowready_func2(a,b) { } longlong val_int(); enum Functype functype() const { return NE_FUNC; } cond_result eq_cmp_result() const { return COND_FALSE; } @@ -179,7 +244,8 @@ public: longlong val_int(); bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref) { - return (item->fix_fields(thd, tlist, &item) || + return (item->check_cols(1) || + item->fix_fields(thd, tlist, &item) || Item_func::fix_fields(thd, tlist, ref)); } void fix_length_and_dec(); @@ -414,7 +480,8 @@ class Item_func_in :public Item_int_func longlong val_int(); bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref) { - return (item->fix_fields(thd, tlist, &item) || + return (item->check_cols(1) || + item->fix_fields(thd, tlist, &item) || Item_func::fix_fields(thd, tlist, ref)); } void fix_length_and_dec(); |