572
572
func= comparator_matrix[type]
573
[test(owner->functype() == Item_func::EQUAL_FUNC)];
573
[test(owner->functype() == Item_func::EQUAL_FUNC)];
577
uint32_t n= (*a)->cols();
578
if (n != (*b)->cols())
580
my_error(ER_OPERAND_COLUMNS, MYF(0), n);
584
if (!(comparators= new Arg_comparator[n]))
586
for (uint32_t i=0; i < n; i++)
588
if ((*a)->element_index(i)->cols() != (*b)->element_index(i)->cols())
590
my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->element_index(i)->cols());
593
comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i));
578
uint32_t n= (*a)->cols();
579
if (n != (*b)->cols())
581
my_error(ER_OPERAND_COLUMNS, MYF(0), n);
585
if (!(comparators= new Arg_comparator[n]))
587
for (uint32_t i=0; i < n; i++)
589
if ((*a)->element_index(i)->cols() != (*b)->element_index(i)->cols())
591
my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->element_index(i)->cols());
594
comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i));
597
599
case STRING_RESULT:
600
We must set cmp_charset here as we may be called from for an automatic
601
generated item, like in natural join
603
if (cmp_collation.set((*a)->collation, (*b)->collation) ||
604
cmp_collation.derivation == DERIVATION_NONE)
606
my_coll_agg_error((*a)->collation, (*b)->collation, owner->func_name());
609
if (cmp_collation.collation == &my_charset_bin)
612
We are using BLOB/BINARY/VARBINARY, change to compare byte by byte,
613
without removing end space
602
We must set cmp_charset here as we may be called from for an automatic
603
generated item, like in natural join
615
if (func == &Arg_comparator::compare_string)
616
func= &Arg_comparator::compare_binary_string;
617
else if (func == &Arg_comparator::compare_e_string)
618
func= &Arg_comparator::compare_e_binary_string;
605
if (cmp_collation.set((*a)->collation, (*b)->collation) ||
606
cmp_collation.derivation == DERIVATION_NONE)
608
my_coll_agg_error((*a)->collation, (*b)->collation, owner->func_name());
611
if (cmp_collation.collation == &my_charset_bin)
614
We are using BLOB/BINARY/VARBINARY, change to compare byte by byte,
615
without removing end space
617
if (func == &Arg_comparator::compare_string)
618
func= &Arg_comparator::compare_binary_string;
619
else if (func == &Arg_comparator::compare_e_string)
620
func= &Arg_comparator::compare_e_binary_string;
621
As this is binary compassion, mark all fields that they can't be
622
transformed. Otherwise we would get into trouble with comparisons
624
WHERE col= 'j' AND col LIKE BINARY 'j'
625
which would be transformed to:
623
As this is binary compassion, mark all fields that they can't be
624
transformed. Otherwise we would get into trouble with comparisons
626
WHERE col= 'j' AND col LIKE BINARY 'j'
627
which would be transformed to:
628
(*a)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
629
(*b)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
630
(*a)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
631
(*b)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
635
if (func == &Arg_comparator::compare_int_signed)
637
if ((*a)->unsigned_flag)
638
func= (((*b)->unsigned_flag)?
639
&Arg_comparator::compare_int_unsigned :
640
&Arg_comparator::compare_int_unsigned_signed);
641
else if ((*b)->unsigned_flag)
642
func= &Arg_comparator::compare_int_signed_unsigned;
644
else if (func== &Arg_comparator::compare_e_int)
646
if ((*a)->unsigned_flag ^ (*b)->unsigned_flag)
647
func= &Arg_comparator::compare_e_int_diff_signedness;
637
if (func == &Arg_comparator::compare_int_signed)
639
if ((*a)->unsigned_flag)
640
func= (((*b)->unsigned_flag)?
641
&Arg_comparator::compare_int_unsigned :
642
&Arg_comparator::compare_int_unsigned_signed);
643
else if ((*b)->unsigned_flag)
644
func= &Arg_comparator::compare_int_signed_unsigned;
646
else if (func== &Arg_comparator::compare_e_int)
648
if ((*a)->unsigned_flag ^ (*b)->unsigned_flag)
649
func= &Arg_comparator::compare_e_int_diff_signedness;
651
653
case DECIMAL_RESULT:
653
655
case REAL_RESULT:
655
if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
657
precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
658
if (func == &Arg_comparator::compare_real)
659
func= &Arg_comparator::compare_real_fixed;
660
else if (func == &Arg_comparator::compare_e_real)
661
func= &Arg_comparator::compare_e_real_fixed;
657
if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
659
precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
660
if (func == &Arg_comparator::compare_real)
661
func= &Arg_comparator::compare_real_fixed;
662
else if (func == &Arg_comparator::compare_e_real)
663
func= &Arg_comparator::compare_e_real_fixed;