Commit d8cf7e01 authored by unknown's avatar unknown
Browse files

Bug#9509 Optimizer: wrong result after AND with latin1_german2_ci

We cannot propagate constants with tricky collations.

parent b6317e3a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ typedef struct my_collation_handler_st
  /* Hash calculation */
  void (*hash_sort)(struct charset_info_st *cs, const uchar *key, uint len,
		    ulong *nr1, ulong *nr2); 
  my_bool (*propagate)(struct charset_info_st *cs, const uchar *str, uint len);
} MY_COLLATION_HANDLER;

extern MY_COLLATION_HANDLER my_collation_mb_bin_handler;
@@ -385,6 +386,10 @@ int my_wildcmp_unicode(CHARSET_INFO *cs,
extern my_bool my_parse_charset_xml(const char *bug, uint len,
				    int (*add)(CHARSET_INFO *cs));

my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, uint len);
my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, uint len);


#define	_MY_U	01	/* Upper case */
#define	_MY_L	02	/* Lower case */
#define	_MY_NMR	04	/* Numeral (digit) */
+6 −0
Original line number Diff line number Diff line
@@ -338,3 +338,9 @@ ss
ss

DROP TABLE t1;
create table t1 (s1 char(5) character set latin1 collate latin1_german2_ci);
insert into t1 values (0xf6) /* this is o-umlaut */;
select * from t1 where length(s1)=1 and s1='oe';
s1

drop table t1;
+8 −0
Original line number Diff line number Diff line
@@ -132,3 +132,11 @@ INSERT INTO t1 VALUES ('
ALTER TABLE t1 ADD KEY ifword(col1);
SELECT * FROM t1 WHERE col1='' ORDER BY col1, BINARY col1;
DROP TABLE t1;

#
# Bug#9509
#
create table t1 (s1 char(5) character set latin1 collate latin1_german2_ci);
insert into t1 values (0xf6) /* this is o-umlaut */;
select * from t1 where length(s1)=1 and s1='oe';
drop table t1;
+7 −4
Original line number Diff line number Diff line
@@ -6435,10 +6435,13 @@ static bool check_equality(Item *item, COND_EQUAL *cond_equal)
      {
        bool copyfl;

        if (field_item->result_type() == STRING_RESULT &&
              ((Field_str *) field_item->field)->charset() !=
               ((Item_cond *) item)->compare_collation())
        if (field_item->result_type() == STRING_RESULT)
        {
          CHARSET_INFO *cs= ((Field_str*) field_item->field)->charset();
          if ((cs != ((Item_cond *) item)->compare_collation()) ||
              !cs->coll->propagate(cs, 0, 0))
            return FALSE;
        }

        Item_equal *item_equal = find_item_equal(cond_equal,
                                                 field_item->field, &copyfl);
+2 −1
Original line number Diff line number Diff line
@@ -6335,7 +6335,8 @@ static MY_COLLATION_HANDLER my_collation_big5_chinese_ci_handler =
  my_wildcmp_mb,
  my_strcasecmp_mb,
  my_instr_mb,
  my_hash_sort_simple
  my_hash_sort_simple,
  my_propagate_simple
};

static MY_CHARSET_HANDLER my_charset_big5_handler=
Loading