diff options
author | unknown <igor@rurik.mysql.com> | 2003-12-01 18:47:19 -0800 |
---|---|---|
committer | unknown <igor@rurik.mysql.com> | 2003-12-01 18:47:19 -0800 |
commit | 7b853c645db94e179be5a4086feb5ccb4088280e (patch) | |
tree | 31494d26df6b929335d01f1c5d1433017038d9f5 /sql/item_cmpfunc.cc | |
parent | f6697593d252efc2d4a41897fb503e1598af97ad (diff) | |
parent | 7daa6cdc1358b0abcf24a28ed6eda57ba3533d23 (diff) | |
download | mariadb-git-7b853c645db94e179be5a4086feb5ccb4088280e.tar.gz |
Merge
mysql-test/t/range.test:
Auto merged
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_cmpfunc.h:
Auto merged
sql/item_func.cc:
Auto merged
sql/opt_range.cc:
Auto merged
sql/opt_sum.cc:
Auto merged
sql/sql_list.h:
Auto merged
sql/sql_select.h:
Auto merged
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 83 |
1 files changed, 55 insertions, 28 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 76cec7b6615..ff1d359ec3f 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -397,13 +397,12 @@ int Arg_comparator::compare_row() int Arg_comparator::compare_e_row() { - int res= 0; (*a)->bring_value(); (*b)->bring_value(); uint n= (*a)->cols(); for (uint i= 0; i<n; i++) { - if ((res= !comparators[i].compare())) + if (!comparators[i].compare()) return 0; } return 1; @@ -1096,8 +1095,10 @@ void Item_func_case::fix_length_and_dec() return; - // Aggregate first expression and all THEN expression types - // and collations when string comparison + /* + Aggregate first expression and all THEN expression types + and collations when string comparison + */ if (first_expr_num != -1) { agg[0]= args[first_expr_num]; @@ -1110,7 +1111,7 @@ void Item_func_case::fix_length_and_dec() return; } - if (!else_expr_num != -1 || args[else_expr_num]->maybe_null) + if (else_expr_num == -1 || args[else_expr_num]->maybe_null) maybe_null=1; max_length=0; @@ -1127,6 +1128,7 @@ void Item_func_case::fix_length_and_dec() } } + /* TODO: Fix this so that it prints the whole CASE expression */ void Item_func_case::print(String *str) @@ -1375,6 +1377,7 @@ cmp_item* cmp_item::get_comparator(Item *item) return 0; // to satisfy compiler :) } + cmp_item* cmp_item_sort_string::make_same() { return new cmp_item_sort_string_in_static(cmp_charset); @@ -1395,27 +1398,46 @@ cmp_item* cmp_item_row::make_same() return new cmp_item_row(); } + +cmp_item_row::~cmp_item_row() +{ + DBUG_ENTER("~cmp_item_row"); + DBUG_PRINT("enter",("this: %lx", this)); + if (comparators) + { + for (uint i= 0; i < n; i++) + { + if (comparators[i]) + delete comparators[i]; + } + } + DBUG_VOID_RETURN; +} + + void cmp_item_row::store_value(Item *item) { - THD *thd= current_thd; + DBUG_ENTER("cmp_item_row::store_value"); n= item->cols(); - if ((comparators= (cmp_item **) thd->calloc(sizeof(cmp_item *)*n))) + if (!comparators) + comparators= (cmp_item **) current_thd->calloc(sizeof(cmp_item *)*n); + if (comparators) { item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) - if ((comparators[i]= cmp_item::get_comparator(item->el(i)))) - { - comparators[i]->store_value(item->el(i)); - item->null_value|= item->el(i)->null_value; - } - else - return; + { + if (!comparators[i]) + if (!(comparators[i]= cmp_item::get_comparator(item->el(i)))) + break; // new failed + comparators[i]->store_value(item->el(i)); + item->null_value|= item->el(i)->null_value; + } } - else - return; + DBUG_VOID_RETURN; } + void cmp_item_row::store_value_by_template(cmp_item *t, Item *item) { cmp_item_row *tmpl= (cmp_item_row*) t; @@ -1430,19 +1452,17 @@ void cmp_item_row::store_value_by_template(cmp_item *t, Item *item) item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) - if ((comparators[i]= tmpl->comparators[i]->make_same())) - { - comparators[i]->store_value_by_template(tmpl->comparators[i], - item->el(i)); - item->null_value|= item->el(i)->null_value; - } - else - return; + { + if (!(comparators[i]= tmpl->comparators[i]->make_same())) + break; // new failed + comparators[i]->store_value_by_template(tmpl->comparators[i], + item->el(i)); + item->null_value|= item->el(i)->null_value; + } } - else - return; } + int cmp_item_row::cmp(Item *arg) { arg->null_value= 0; @@ -1454,25 +1474,31 @@ int cmp_item_row::cmp(Item *arg) bool was_null= 0; arg->bring_value(); for (uint i=0; i < n; i++) + { if (comparators[i]->cmp(arg->el(i))) { if (!arg->el(i)->null_value) return 1; was_null= 1; } + } return (arg->null_value= was_null); } + int cmp_item_row::compare(cmp_item *c) { - int res; cmp_item_row *cmp= (cmp_item_row *) c; for (uint i=0; i < n; i++) + { + int res; if ((res= comparators[i]->compare(cmp->comparators[i]))) return res; + } return 0; } + bool Item_func_in::nulls_in_row() { Item **arg,**arg_end; @@ -1484,6 +1510,7 @@ bool Item_func_in::nulls_in_row() return 0; } + static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) { return cs->coll->strnncollsp(cs, @@ -1491,6 +1518,7 @@ static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) (unsigned char *) y->ptr(),y->length()); } + void Item_func_in::fix_length_and_dec() { Item **arg, **arg_end; @@ -1512,7 +1540,6 @@ void Item_func_in::fix_length_and_dec() { switch (cmp_type) { case STRING_RESULT: - uint i; array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in, cmp_collation.collation); break; |