diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl
index bc44c440c3244bec89d668b0725d2abfba25ca93..0ab09a40b37fc4e6a9dd1d6b3cc815c820798a14 100644
--- a/mysql-test/lib/mtr_misc.pl
+++ b/mysql-test/lib/mtr_misc.pl
@@ -83,7 +83,14 @@ sub mtr_path_exists (@) {
 sub mtr_script_exists (@) {
   foreach my $path ( @_ )
   {
-    return $path if -x $path;
+    if($::glob_win32)
+    {
+      return $path if -f $path;
+    }
+    else
+    {
+      return $path if -x $path;
+    }
   }
   if ( @_ == 1 )
   {
diff --git a/mysql-test/r/ctype_cp1250_ch.result b/mysql-test/r/ctype_cp1250_ch.result
index fad06dd288130921a2bc670a06720cc088c05e6d..007d6103b8a9268bf4eee7a1233e684da847819e 100644
--- a/mysql-test/r/ctype_cp1250_ch.result
+++ b/mysql-test/r/ctype_cp1250_ch.result
@@ -43,3 +43,11 @@ id	str
 6	aaaaaa
 7	aaaaaaa
 drop table t1;
+set names cp1250;
+create table t1 (a varchar(15) collate cp1250_czech_cs NOT NULL, primary key(a));
+insert into t1 values("abcdefghá");
+insert into t1 values("ááèè");
+select a from t1 where a like "abcdefghá";
+a
+abcdefghá
+drop table t1;
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index 2f82cb2aecb33438f74ecba1ff5656d0cdc1800d..6e75e4477634c52417eebd84b63227810a7db365 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -1281,6 +1281,22 @@ id	tid	val
 42749	72	VOLNÝ ADSL
 44205	72	VOLNÝ ADSL
 DROP TABLE t1;
+create table t1(a char(200) collate utf8_unicode_ci NOT NULL default '')
+default charset=utf8 collate=utf8_unicode_ci;
+insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65'));
+explain select distinct a from t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using temporary
+select distinct a from t1;
+a
+e
+explain select a from t1 group by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using temporary; Using filesort
+select a from t1 group by a;
+a
+e
+drop table t1;
 CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8;
 INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
 SELECT id FROM t1;
diff --git a/mysql-test/t/ctype_cp1250_ch.test b/mysql-test/t/ctype_cp1250_ch.test
index 8391582cfde9e9e6924437c3886245acab3ae23d..89f82d1a758cc7a74c5163e5eea19d00b5054eb1 100644
--- a/mysql-test/t/ctype_cp1250_ch.test
+++ b/mysql-test/t/ctype_cp1250_ch.test
@@ -47,4 +47,14 @@ INSERT INTO t1 VALUES (NULL, 'aaaaaaa');
 select * from t1 where str like 'aa%';
 drop table t1;
 
+#
+# Bug#19741 segfault with cp1250 charset + like + primary key + 64bit os
+#
+set names cp1250;
+create table t1 (a varchar(15) collate cp1250_czech_cs NOT NULL, primary key(a));
+insert into t1 values("abcdefghá");
+insert into t1 values("ááèè");
+select a from t1 where a like "abcdefghá";
+drop table t1;
+
 # End of 4.1 tests
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index ccb3e7f718c32584a2392315465e7081e8a2f453..30dab7c5170480e14650b2d0ba9395330993bf1a 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -1026,6 +1026,20 @@ ALTER TABLE t1 ADD KEY idx (tid,val(11));
 SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL'; 
 
 DROP TABLE t1;
+
+#
+# Bug 20709: problem with utf8 fields in temporary tables
+#
+
+create table t1(a char(200) collate utf8_unicode_ci NOT NULL default '')
+  default charset=utf8 collate=utf8_unicode_ci;
+insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65'));
+explain select distinct a from t1;
+select distinct a from t1;
+explain select a from t1 group by a;
+select a from t1 group by a;
+drop table t1;
+
 # End of 4.1 tests
 
 #
diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c
index 0bc465f16eab8e7c69a802da6ea4d2d341e80e0a..39948964a42d41765989da0832d21b1313c17571 100644
--- a/strings/ctype-win1250ch.c
+++ b/strings/ctype-win1250ch.c
@@ -636,11 +636,11 @@ my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)),
       ptr++;					/* Skip escape */
     else if (*ptr == w_one || *ptr == w_many)	/* '_' or '%' in SQL */
       break;
-    *min_str = like_range_prefix_min_win1250ch[(uint)(*ptr)];
+    *min_str= like_range_prefix_min_win1250ch[(uint) (uchar) (*ptr)];
     if (*min_str != min_sort_char)
       only_min_found= 0;
     min_str++;
-    *max_str++= like_range_prefix_max_win1250ch[(uint)(*ptr)];
+    *max_str++= like_range_prefix_max_win1250ch[(uint) (uchar) (*ptr)];
   }
 
   if (cs->state & MY_CS_BINSORT)