#include <item_cmpfunc.h>
Inheritance diagram for Arg_comparator:


Definition at line 32 of file item_cmpfunc.h.
| Arg_comparator::Arg_comparator | ( | ) | [inline] |
| int Arg_comparator::compare | ( | ) | [inline] |
Definition at line 66 of file item_cmpfunc.h.
References func.
Referenced by compare_e_row(), compare_row(), Item_func_nullif::is_null(), Item_func_nullif::val_decimal(), Item_func_nullif::val_int(), Item_func_lt::val_int(), Item_func_le::val_int(), Item_func_gt::val_int(), Item_func_ge::val_int(), Item_func_ne::val_int(), Item_func_equal::val_int(), Item_func_eq::val_int(), Item_func_nullif::val_real(), and Item_func_nullif::val_str().
00066 { return (this->*func)(); }
Here is the caller graph for this function:

| int Arg_comparator::compare_binary_string | ( | ) |
Definition at line 576 of file item_cmpfunc.cc.
References cmp, int(), String::length(), memcmp(), min, Item::null_value, owner, String::ptr(), Item_bool_func2::tmp_value1, and Item_bool_func2::tmp_value2.
Referenced by set_compare_func().
00577 { 00578 String *res1,*res2; 00579 if ((res1= (*a)->val_str(&owner->tmp_value1))) 00580 { 00581 if ((res2= (*b)->val_str(&owner->tmp_value2))) 00582 { 00583 owner->null_value= 0; 00584 uint res1_length= res1->length(); 00585 uint res2_length= res2->length(); 00586 int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length)); 00587 return cmp ? cmp : (int) (res1_length - res2_length); 00588 } 00589 } 00590 owner->null_value= 1; 00591 return -1; 00592 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int Arg_comparator::compare_decimal | ( | ) |
Definition at line 645 of file item_cmpfunc.cc.
References my_decimal_cmp(), Item::null_value, and owner.
00646 { 00647 my_decimal value1; 00648 my_decimal *val1= (*a)->val_decimal(&value1); 00649 if (!(*a)->null_value) 00650 { 00651 my_decimal value2; 00652 my_decimal *val2= (*b)->val_decimal(&value2); 00653 if (!(*b)->null_value) 00654 { 00655 owner->null_value= 0; 00656 return my_decimal_cmp(val1, val2); 00657 } 00658 } 00659 owner->null_value= 1; 00660 return -1; 00661 }
Here is the call graph for this function:

| int Arg_comparator::compare_e_binary_string | ( | ) |
Definition at line 610 of file item_cmpfunc.cc.
References owner, stringcmp(), test, Item_bool_func2::tmp_value1, and Item_bool_func2::tmp_value2.
Referenced by set_compare_func().
00611 { 00612 String *res1,*res2; 00613 res1= (*a)->val_str(&owner->tmp_value1); 00614 res2= (*b)->val_str(&owner->tmp_value2); 00615 if (!res1 || !res2) 00616 return test(res1 == res2); 00617 return test(stringcmp(res1, res2) == 0); 00618 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int Arg_comparator::compare_e_decimal | ( | ) |
Definition at line 672 of file item_cmpfunc.cc.
References my_decimal_cmp(), and test.
00673 { 00674 my_decimal value1, value2; 00675 my_decimal *val1= (*a)->val_decimal(&value1); 00676 my_decimal *val2= (*b)->val_decimal(&value2); 00677 if ((*a)->null_value || (*b)->null_value) 00678 return test((*a)->null_value && (*b)->null_value); 00679 return test(my_decimal_cmp(val1, val2) == 0); 00680 }
Here is the call graph for this function:

| int Arg_comparator::compare_e_int | ( | ) |
Definition at line 776 of file item_cmpfunc.cc.
References test.
Referenced by set_compare_func().
00777 { 00778 longlong val1= (*a)->val_int(); 00779 longlong val2= (*b)->val_int(); 00780 if ((*a)->null_value || (*b)->null_value) 00781 return test((*a)->null_value && (*b)->null_value); 00782 return test(val1 == val2); 00783 }
Here is the caller graph for this function:

| int Arg_comparator::compare_e_int_diff_signedness | ( | ) |
Definition at line 788 of file item_cmpfunc.cc.
References test.
Referenced by set_compare_func().
00789 { 00790 longlong val1= (*a)->val_int(); 00791 longlong val2= (*b)->val_int(); 00792 if ((*a)->null_value || (*b)->null_value) 00793 return test((*a)->null_value && (*b)->null_value); 00794 return (val1 >= 0) && test(val1 == val2); 00795 }
Here is the caller graph for this function:

| int Arg_comparator::compare_e_real | ( | ) |
Definition at line 663 of file item_cmpfunc.cc.
References test.
00664 { 00665 double val1= (*a)->val_real(); 00666 double val2= (*b)->val_real(); 00667 if ((*a)->null_value || (*b)->null_value) 00668 return test((*a)->null_value && (*b)->null_value); 00669 return test(val1 == val2); 00670 }
| int Arg_comparator::compare_e_row | ( | ) |
Definition at line 832 of file item_cmpfunc.cc.
References comparators, compare(), and n.
00833 { 00834 (*a)->bring_value(); 00835 (*b)->bring_value(); 00836 uint n= (*a)->cols(); 00837 for (uint i= 0; i<n; i++) 00838 { 00839 if (!comparators[i].compare()) 00840 return 0; 00841 } 00842 return 1; 00843 }
Here is the call graph for this function:

| int Arg_comparator::compare_e_string | ( | ) |
Definition at line 599 of file item_cmpfunc.cc.
References cmp_collation, DTCollation::collation, owner, sortcmp(), test, Item_bool_func2::tmp_value1, and Item_bool_func2::tmp_value2.
Referenced by set_compare_func().
00600 { 00601 String *res1,*res2; 00602 res1= (*a)->val_str(&owner->tmp_value1); 00603 res2= (*b)->val_str(&owner->tmp_value2); 00604 if (!res1 || !res2) 00605 return test(res1 == res2); 00606 return test(sortcmp(res1, res2, cmp_collation.collation) == 0); 00607 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int Arg_comparator::compare_int_signed | ( | ) |
Definition at line 682 of file item_cmpfunc.cc.
References Item::null_value, and owner.
Referenced by set_compare_func().
00683 { 00684 longlong val1= (*a)->val_int(); 00685 if (!(*a)->null_value) 00686 { 00687 longlong val2= (*b)->val_int(); 00688 if (!(*b)->null_value) 00689 { 00690 owner->null_value= 0; 00691 if (val1 < val2) return -1; 00692 if (val1 == val2) return 0; 00693 return 1; 00694 } 00695 } 00696 owner->null_value= 1; 00697 return -1; 00698 }
Here is the caller graph for this function:

| int Arg_comparator::compare_int_signed_unsigned | ( | ) |
Definition at line 728 of file item_cmpfunc.cc.
References Item::null_value, and owner.
Referenced by set_compare_func().
00729 { 00730 longlong sval1= (*a)->val_int(); 00731 if (!(*a)->null_value) 00732 { 00733 ulonglong uval2= (ulonglong)(*b)->val_int(); 00734 if (!(*b)->null_value) 00735 { 00736 owner->null_value= 0; 00737 if (sval1 < 0 || (ulonglong)sval1 < uval2) 00738 return -1; 00739 if ((ulonglong)sval1 == uval2) 00740 return 0; 00741 return 1; 00742 } 00743 } 00744 owner->null_value= 1; 00745 return -1; 00746 }
Here is the caller graph for this function:

| int Arg_comparator::compare_int_unsigned | ( | ) |
Definition at line 705 of file item_cmpfunc.cc.
References Item::null_value, and owner.
Referenced by set_compare_func().
00706 { 00707 ulonglong val1= (*a)->val_int(); 00708 if (!(*a)->null_value) 00709 { 00710 ulonglong val2= (*b)->val_int(); 00711 if (!(*b)->null_value) 00712 { 00713 owner->null_value= 0; 00714 if (val1 < val2) return -1; 00715 if (val1 == val2) return 0; 00716 return 1; 00717 } 00718 } 00719 owner->null_value= 1; 00720 return -1; 00721 }
Here is the caller graph for this function:

| int Arg_comparator::compare_int_unsigned_signed | ( | ) |
Definition at line 753 of file item_cmpfunc.cc.
References Item::null_value, and owner.
Referenced by set_compare_func().
00754 { 00755 ulonglong uval1= (ulonglong)(*a)->val_int(); 00756 if (!(*a)->null_value) 00757 { 00758 longlong sval2= (*b)->val_int(); 00759 if (!(*b)->null_value) 00760 { 00761 owner->null_value= 0; 00762 if (sval2 < 0) 00763 return 1; 00764 if (uval1 < (ulonglong)sval2) 00765 return -1; 00766 if (uval1 == (ulonglong)sval2) 00767 return 0; 00768 return 1; 00769 } 00770 } 00771 owner->null_value= 1; 00772 return -1; 00773 }
Here is the caller graph for this function:

| int Arg_comparator::compare_real | ( | ) |
Definition at line 621 of file item_cmpfunc.cc.
References Item::null_value, and owner.
00622 { 00623 /* 00624 Fix yet another manifestation of Bug#2338. 'Volatile' will instruct 00625 gcc to flush double values out of 80-bit Intel FPU registers before 00626 performing the comparison. 00627 */ 00628 volatile double val1, val2; 00629 val1= (*a)->val_real(); 00630 if (!(*a)->null_value) 00631 { 00632 val2= (*b)->val_real(); 00633 if (!(*b)->null_value) 00634 { 00635 owner->null_value= 0; 00636 if (val1 < val2) return -1; 00637 if (val1 == val2) return 0; 00638 return 1; 00639 } 00640 } 00641 owner->null_value= 1; 00642 return -1; 00643 }
| int Arg_comparator::compare_row | ( | ) |
Definition at line 797 of file item_cmpfunc.cc.
References Item_bool_func2::abort_on_null, comparators, compare(), n, Item::null_value, and owner.
00798 { 00799 int res= 0; 00800 bool was_null= 0; 00801 (*a)->bring_value(); 00802 (*b)->bring_value(); 00803 uint n= (*a)->cols(); 00804 for (uint i= 0; i<n; i++) 00805 { 00806 res= comparators[i].compare(); 00807 if (owner->null_value) 00808 { 00809 // NULL was compared 00810 if (owner->abort_on_null) 00811 return -1; // We do not need correct NULL returning 00812 was_null= 1; 00813 owner->null_value= 0; 00814 res= 0; // continue comparison (maybe we will meet explicit difference) 00815 } 00816 else if (res) 00817 return res; 00818 } 00819 if (was_null) 00820 { 00821 /* 00822 There was NULL(s) in comparison in some parts, but there was not 00823 explicit difference in other parts, so we have to return NULL 00824 */ 00825 owner->null_value= 1; 00826 return -1; 00827 } 00828 return 0; 00829 }
Here is the call graph for this function:

| int Arg_comparator::compare_string | ( | ) |
Definition at line 551 of file item_cmpfunc.cc.
References cmp_collation, DTCollation::collation, Item::null_value, owner, sortcmp(), Item_bool_func2::tmp_value1, and Item_bool_func2::tmp_value2.
Referenced by set_compare_func().
00552 { 00553 String *res1,*res2; 00554 if ((res1= (*a)->val_str(&owner->tmp_value1))) 00555 { 00556 if ((res2= (*b)->val_str(&owner->tmp_value2))) 00557 { 00558 owner->null_value= 0; 00559 return sortcmp(res1,res2,cmp_collation.collation); 00560 } 00561 } 00562 owner->null_value= 1; 00563 return -1; 00564 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int Arg_comparator::set_cmp_func | ( | Item_bool_func2 * | owner_arg, | |
| Item ** | a1, | |||
| Item ** | a2 | |||
| ) | [inline] |
Definition at line 59 of file item_cmpfunc.h.
References item_cmp_type(), and set_cmp_func().
00061 { 00062 return set_cmp_func(owner_arg, a1, a2, 00063 item_cmp_type((*a1)->result_type(), 00064 (*a2)->result_type())); 00065 }
Here is the call graph for this function:

| int Arg_comparator::set_cmp_func | ( | Item_bool_func2 * | owner_arg, | |
| Item ** | a1, | |||
| Item ** | a2, | |||
| Item_result | type | |||
| ) | [inline] |
Definition at line 51 of file item_cmpfunc.h.
References a, b, and set_compare_func().
Referenced by Item_bool_func2::fix_length_and_dec(), Item_bool_func2::set_cmp_func(), set_cmp_func(), and set_compare_func().
00054 { 00055 a= a1; 00056 b= a2; 00057 return set_compare_func(owner_arg, type); 00058 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int Arg_comparator::set_compare_func | ( | Item_bool_func2 * | owner_arg | ) | [inline] |
Definition at line 46 of file item_cmpfunc.h.
References item_cmp_type(), and set_compare_func().
00047 { 00048 return set_compare_func(owner_arg, item_cmp_type((*a)->result_type(), 00049 (*b)->result_type())); 00050 }
Here is the call graph for this function:

| int Arg_comparator::set_compare_func | ( | Item_bool_func2 * | owner, | |
| Item_result | type | |||
| ) |
Definition at line 459 of file item_cmpfunc.cc.
References Item::addr(), cmp_collation, DTCollation::collation, comparator_matrix, comparators, compare_binary_string(), compare_e_binary_string(), compare_e_int(), compare_e_int_diff_signedness(), compare_e_string(), compare_int_signed(), compare_int_signed_unsigned(), compare_int_unsigned(), compare_int_unsigned_signed(), compare_string(), DBUG_ASSERT, DECIMAL_RESULT, DTCollation::derivation, DERIVATION_NONE, Item_func::EQUAL_FUNC, ER_OPERAND_COLUMNS, func, Item_func::func_name(), Item_func::functype(), INT_RESULT, my_charset_bin, my_coll_agg_error(), my_error(), MYF, n, owner, REAL_RESULT, ROW_RESULT, DTCollation::set(), set_cmp_func(), Item::set_no_const_sub(), STRING_RESULT, and test.
Referenced by set_cmp_func(), and set_compare_func().
00460 { 00461 owner= item; 00462 func= comparator_matrix[type] 00463 [test(owner->functype() == Item_func::EQUAL_FUNC)]; 00464 switch (type) { 00465 case ROW_RESULT: 00466 { 00467 uint n= (*a)->cols(); 00468 if (n != (*b)->cols()) 00469 { 00470 my_error(ER_OPERAND_COLUMNS, MYF(0), n); 00471 comparators= 0; 00472 return 1; 00473 } 00474 if (!(comparators= new Arg_comparator[n])) 00475 return 1; 00476 for (uint i=0; i < n; i++) 00477 { 00478 if ((*a)->el(i)->cols() != (*b)->el(i)->cols()) 00479 { 00480 my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->el(i)->cols()); 00481 return 1; 00482 } 00483 comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i)); 00484 } 00485 break; 00486 } 00487 case STRING_RESULT: 00488 { 00489 /* 00490 We must set cmp_charset here as we may be called from for an automatic 00491 generated item, like in natural join 00492 */ 00493 if (cmp_collation.set((*a)->collation, (*b)->collation) || 00494 cmp_collation.derivation == DERIVATION_NONE) 00495 { 00496 my_coll_agg_error((*a)->collation, (*b)->collation, owner->func_name()); 00497 return 1; 00498 } 00499 if (cmp_collation.collation == &my_charset_bin) 00500 { 00501 /* 00502 We are using BLOB/BINARY/VARBINARY, change to compare byte by byte, 00503 without removing end space 00504 */ 00505 if (func == &Arg_comparator::compare_string) 00506 func= &Arg_comparator::compare_binary_string; 00507 else if (func == &Arg_comparator::compare_e_string) 00508 func= &Arg_comparator::compare_e_binary_string; 00509 00510 /* 00511 As this is binary compassion, mark all fields that they can't be 00512 transformed. Otherwise we would get into trouble with comparisons 00513 like: 00514 WHERE col= 'j' AND col LIKE BINARY 'j' 00515 which would be transformed to: 00516 WHERE col= 'j' 00517 */ 00518 (*a)->transform(&Item::set_no_const_sub, (byte*) 0); 00519 (*b)->transform(&Item::set_no_const_sub, (byte*) 0); 00520 } 00521 break; 00522 } 00523 case INT_RESULT: 00524 { 00525 if (func == &Arg_comparator::compare_int_signed) 00526 { 00527 if ((*a)->unsigned_flag) 00528 func= (((*b)->unsigned_flag)? 00529 &Arg_comparator::compare_int_unsigned : 00530 &Arg_comparator::compare_int_unsigned_signed); 00531 else if ((*b)->unsigned_flag) 00532 func= &Arg_comparator::compare_int_signed_unsigned; 00533 } 00534 else if (func== &Arg_comparator::compare_e_int) 00535 { 00536 if ((*a)->unsigned_flag ^ (*b)->unsigned_flag) 00537 func= &Arg_comparator::compare_e_int_diff_signedness; 00538 } 00539 break; 00540 } 00541 case DECIMAL_RESULT: 00542 case REAL_RESULT: 00543 break; 00544 default: 00545 DBUG_ASSERT(0); 00546 } 00547 return 0; 00548 }
Here is the call graph for this function:

Here is the caller graph for this function:

friend class Item_func [friend] |
Definition at line 87 of file item_cmpfunc.h.
Item** Arg_comparator::a [private] |
Item ** Arg_comparator::b [private] |
Definition at line 40 of file item_cmpfunc.h.
Referenced by Item_bool_func2::compare_collation(), compare_e_string(), compare_string(), Item_func_like::fix_fields(), set_compare_func(), Item_func_like::turboBM_compute_bad_character_shifts(), Item_func_like::turboBM_compute_suffixes(), Item_func_like::turboBM_matches(), Item_func_like::val_int(), and Item_func_strcmp::val_int().
Initial value:
{{&Arg_comparator::compare_string, &Arg_comparator::compare_e_string},
{&Arg_comparator::compare_real, &Arg_comparator::compare_e_real},
{&Arg_comparator::compare_int_signed, &Arg_comparator::compare_e_int},
{&Arg_comparator::compare_row, &Arg_comparator::compare_e_row},
{&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}}
Definition at line 85 of file item_cmpfunc.h.
Referenced by set_compare_func().
Arg_comparator* Arg_comparator::comparators [private] |
Definition at line 37 of file item_cmpfunc.h.
Referenced by compare_e_row(), compare_row(), and set_compare_func().
arg_cmp_func Arg_comparator::func [private] |
Item_bool_func2* Arg_comparator::owner [private] |
Definition at line 36 of file item_cmpfunc.h.
Referenced by compare_binary_string(), compare_decimal(), compare_e_binary_string(), compare_e_string(), compare_int_signed(), compare_int_signed_unsigned(), compare_int_unsigned(), compare_int_unsigned_signed(), compare_real(), compare_row(), compare_string(), and set_compare_func().
1.4.7

