summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2005-01-13 17:31:49 +0300
committerunknown <konstantin@mysql.com>2005-01-13 17:31:49 +0300
commit6a7956dce0e510c2cb3c127be2be2e4960fd258f (patch)
tree589a6b326750729b4c6b6133c6f985394d9d387a
parent0906c576bd12f5bdcf78a17a1e03d22815279204 (diff)
parent8dea326cf9f060588cda6a824e8a90a222ac0285 (diff)
downloadmariadb-git-6a7956dce0e510c2cb3c127be2be2e4960fd258f.tar.gz
manual merge
mysql-test/r/ctype_latin1_de.result: Auto merged mysql-test/r/ctype_tis620.result: Auto merged mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/ctype_ujis.result: Auto merged mysql-test/r/ctype_utf8.result: Auto merged mysql-test/t/ctype_ucs.test: Auto merged sql/field.cc: Auto merged sql/filesort.cc: Auto merged strings/ctype-big5.c: Auto merged strings/ctype-bin.c: Auto merged strings/ctype-czech.c: Auto merged strings/ctype-gbk.c: Auto merged strings/ctype-latin1.c: Auto merged strings/ctype-mb.c: Auto merged strings/ctype-simple.c: Auto merged strings/ctype-sjis.c: Auto merged strings/ctype-tis620.c: Auto merged strings/ctype-uca.c: Auto merged strings/ctype-ucs2.c: Auto merged strings/ctype-utf8.c: Auto merged strings/ctype-win1250ch.c: Auto merged
-rw-r--r--mysql-test/include/ctype_filesort.inc15
-rw-r--r--mysql-test/r/ctype_big5.result21
-rw-r--r--mysql-test/r/ctype_latin1.result20
-rw-r--r--mysql-test/r/ctype_latin1_de.result9
-rw-r--r--mysql-test/r/ctype_sjis.result20
-rw-r--r--mysql-test/r/ctype_tis620.result20
-rw-r--r--mysql-test/r/ctype_uca.result10
-rw-r--r--mysql-test/r/ctype_ucs.result21
-rw-r--r--mysql-test/r/ctype_ujis.result20
-rw-r--r--mysql-test/r/ctype_utf8.result20
-rw-r--r--mysql-test/r/ps_1general.result2
-rw-r--r--mysql-test/t/ctype_big5.test6
-rw-r--r--mysql-test/t/ctype_latin1.test6
-rw-r--r--mysql-test/t/ctype_latin1_de.test2
-rw-r--r--mysql-test/t/ctype_sjis.test6
-rw-r--r--mysql-test/t/ctype_tis620.test6
-rw-r--r--mysql-test/t/ctype_uca.test3
-rw-r--r--mysql-test/t/ctype_ucs.test6
-rw-r--r--mysql-test/t/ctype_ujis.test6
-rw-r--r--mysql-test/t/ctype_utf8.test6
-rw-r--r--mysql-test/t/ps_1general.test11
-rw-r--r--sql/field.cc12
-rw-r--r--sql/filesort.cc5
-rw-r--r--strings/ctype-big5.c5
-rw-r--r--strings/ctype-bin.c26
-rw-r--r--strings/ctype-czech.c8
-rw-r--r--strings/ctype-gbk.c5
-rw-r--r--strings/ctype-latin1.c5
-rw-r--r--strings/ctype-mb.c11
-rw-r--r--strings/ctype-simple.c45
-rw-r--r--strings/ctype-sjis.c4
-rw-r--r--strings/ctype-tis620.c6
-rw-r--r--strings/ctype-uca.c16
-rw-r--r--strings/ctype-ucs2.c9
-rw-r--r--strings/ctype-utf8.c5
-rw-r--r--strings/ctype-win1250ch.c4
36 files changed, 351 insertions, 51 deletions
diff --git a/mysql-test/include/ctype_filesort.inc b/mysql-test/include/ctype_filesort.inc
new file mode 100644
index 00000000000..2068463d4e2
--- /dev/null
+++ b/mysql-test/include/ctype_filesort.inc
@@ -0,0 +1,15 @@
+#
+# Set desired charset_connection and collation_collation
+# before including this file.
+#
+
+# The next query creates a LONGTEXT column
+# using the current character_set_connection
+# and collation_connection.
+
+create table t1 select repeat('a',4000) a;
+delete from t1;
+
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+drop table t1;
diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result
index 9b9fcbccbe0..8f4ee3d0558 100644
--- a/mysql-test/r/ctype_big5.result
+++ b/mysql-test/r/ctype_big5.result
@@ -56,3 +56,24 @@ DROP DATABASE d1;
USE test;
SET character_set_server= @safe_character_set_server;
SET collation_server= @safe_collation_server;
+SET NAMES big5;
+SET collation_connection='big5_chinese_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+big5_chinese_ci 6109
+big5_chinese_ci 61
+big5_chinese_ci 6120
+drop table t1;
+SET collation_connection='big5_bin';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+big5_bin 6109
+big5_bin 61
+big5_bin 6120
+drop table t1;
diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result
index 355f53b63a5..cd804939a75 100644
--- a/mysql-test/r/ctype_latin1.result
+++ b/mysql-test/r/ctype_latin1.result
@@ -305,3 +305,23 @@ select 'a' regexp 'A' collate latin1_general_cs;
select 'a' regexp 'A' collate latin1_bin;
'a' regexp 'A' collate latin1_bin
0
+SET collation_connection='latin1_swedish_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+latin1_swedish_ci 6109
+latin1_swedish_ci 61
+latin1_swedish_ci 6120
+drop table t1;
+SET collation_connection='latin1_bin';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+latin1_bin 6109
+latin1_bin 61
+latin1_bin 6120
+drop table t1;
diff --git a/mysql-test/r/ctype_latin1_de.result b/mysql-test/r/ctype_latin1_de.result
index f890250e0a3..f9deca3a771 100644
--- a/mysql-test/r/ctype_latin1_de.result
+++ b/mysql-test/r/ctype_latin1_de.result
@@ -317,3 +317,12 @@ FIELD('ue',s1) FIELD('Ü',s1) s1='ue' s1='Ü'
1 1 1 1
1 1 1 1
DROP TABLE t1;
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+latin1_german2_ci 6109
+latin1_german2_ci 61
+latin1_german2_ci 6120
+drop table t1;
diff --git a/mysql-test/r/ctype_sjis.result b/mysql-test/r/ctype_sjis.result
index 944fa0602a9..1f414f89e20 100644
--- a/mysql-test/r/ctype_sjis.result
+++ b/mysql-test/r/ctype_sjis.result
@@ -71,3 +71,23 @@ B1
B2
B3
drop table t1;
+SET collation_connection='sjis_japanese_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+sjis_japanese_ci 6109
+sjis_japanese_ci 61
+sjis_japanese_ci 6120
+drop table t1;
+SET collation_connection='sjis_bin';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+sjis_bin 6109
+sjis_bin 61
+sjis_bin 6120
+drop table t1;
diff --git a/mysql-test/r/ctype_tis620.result b/mysql-test/r/ctype_tis620.result
index 0f29c564fa8..5734f7cac86 100644
--- a/mysql-test/r/ctype_tis620.result
+++ b/mysql-test/r/ctype_tis620.result
@@ -2937,3 +2937,23 @@ Screensaver 2 2002-01-22 491 0 519 0 0
3 http://www.siamzone.com/download/download/000003-jasonx2(800x600).jpg Jaso
n X Wallpapers 1 2002-05-31 579 0 1091 0 0
DROP TABLE t1;
+SET collation_connection='tis620_thai_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+tis620_thai_ci 6109
+tis620_thai_ci 61
+tis620_thai_ci 6120
+drop table t1;
+SET collation_connection='tis620_bin';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+tis620_bin 6109
+tis620_bin 61
+tis620_bin 6120
+drop table t1;
diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result
index 0573092e39b..dd5a7ebf6a4 100644
--- a/mysql-test/r/ctype_uca.result
+++ b/mysql-test/r/ctype_uca.result
@@ -2386,3 +2386,13 @@ a 1
b 0
c 0
drop table t1;
+SET collation_connection='utf8_unicode_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+utf8_unicode_ci 6109
+utf8_unicode_ci 61
+utf8_unicode_ci 6120
+drop table t1;
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index 891786961b1..175a02b63f1 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -602,3 +602,24 @@ a NULL
b NULL
c NULL
drop table t1;
+SET collation_connection='ucs2_general_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+ucs2_general_ci 00610009
+ucs2_general_ci 0061
+ucs2_general_ci 00610020
+drop table t1;
+SET NAMES latin1;
+SET collation_connection='ucs2_bin';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+ucs2_bin 00610009
+ucs2_bin 0061
+ucs2_bin 00610020
+drop table t1;
diff --git a/mysql-test/r/ctype_ujis.result b/mysql-test/r/ctype_ujis.result
index 263da67e16b..a00e68b596e 100644
--- a/mysql-test/r/ctype_ujis.result
+++ b/mysql-test/r/ctype_ujis.result
@@ -2207,3 +2207,23 @@ F4FC
F4FD
F4FE
DROP TABLE t1;
+SET collation_connection='ujis_japanese_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+ujis_japanese_ci 6109
+ujis_japanese_ci 61
+ujis_japanese_ci 6120
+drop table t1;
+SET collation_connection='ujis_bin';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+ujis_bin 6109
+ujis_bin 61
+ujis_bin 6120
+drop table t1;
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index c7d1d94e208..23e2881f36a 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -829,3 +829,23 @@ select * from t1 where soundex(a) = soundex('test');
id a
1 Test
drop table t1;
+SET collation_connection='utf8_general_ci';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+utf8_general_ci 6109
+utf8_general_ci 61
+utf8_general_ci 6120
+drop table t1;
+SET collation_connection='utf8_bin';
+create table t1 select repeat('a',4000) a;
+delete from t1;
+insert into t1 values ('a'), ('a '), ('a\t');
+select collation(a),hex(a) from t1 order by a;
+collation(a) hex(a)
+utf8_bin 6109
+utf8_bin 61
+utf8_bin 6120
+drop table t1;
diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result
index 29309564c45..6df5f633b88 100644
--- a/mysql-test/r/ps_1general.result
+++ b/mysql-test/r/ps_1general.result
@@ -295,7 +295,7 @@ execute stmt4;
prepare stmt4 from ' show full processlist ';
execute stmt4;
Id User Host db Command Time State Info
-number root localhost test Query seconds NULL show full processlist
+number root localhost test Query time NULL show full processlist
prepare stmt4 from ' show grants for user ';
prepare stmt4 from ' show create table t2 ';
ERROR HY000: This command is not supported in the prepared statement protocol yet
diff --git a/mysql-test/t/ctype_big5.test b/mysql-test/t/ctype_big5.test
index b1d71a6af15..8b75123ca32 100644
--- a/mysql-test/t/ctype_big5.test
+++ b/mysql-test/t/ctype_big5.test
@@ -10,3 +10,9 @@ drop table if exists t1;
SET @test_character_set= 'big5';
SET @test_collation= 'big5_chinese_ci';
-- source include/ctype_common.inc
+
+SET NAMES big5;
+SET collation_connection='big5_chinese_ci';
+-- source include/ctype_filesort.inc
+SET collation_connection='big5_bin';
+-- source include/ctype_filesort.inc
diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test
index 677acd9faa9..cee0324d12f 100644
--- a/mysql-test/t/ctype_latin1.test
+++ b/mysql-test/t/ctype_latin1.test
@@ -60,3 +60,9 @@ DROP TABLE t1;
select 'a' regexp 'A' collate latin1_general_ci;
select 'a' regexp 'A' collate latin1_general_cs;
select 'a' regexp 'A' collate latin1_bin;
+
+
+SET collation_connection='latin1_swedish_ci';
+-- source include/ctype_filesort.inc
+SET collation_connection='latin1_bin';
+-- source include/ctype_filesort.inc
diff --git a/mysql-test/t/ctype_latin1_de.test b/mysql-test/t/ctype_latin1_de.test
index 1c9576c1c56..ce4fdc4e3c9 100644
--- a/mysql-test/t/ctype_latin1_de.test
+++ b/mysql-test/t/ctype_latin1_de.test
@@ -114,3 +114,5 @@ SELECT s1,COUNT(*) FROM t1 GROUP BY s1;
SELECT COUNT(DISTINCT s1) FROM t1;
SELECT FIELD('ue',s1), FIELD('Ü',s1), s1='ue', s1='Ü' FROM t1;
DROP TABLE t1;
+
+-- source include/ctype_filesort.inc
diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test
index a3a44789975..58ca3c6a997 100644
--- a/mysql-test/t/ctype_sjis.test
+++ b/mysql-test/t/ctype_sjis.test
@@ -62,3 +62,9 @@ CREATE TABLE t1 (
insert into t1 values(0xb1),(0xb2),(0xb3);
select hex(c) from t1;
drop table t1;
+
+
+SET collation_connection='sjis_japanese_ci';
+-- source include/ctype_filesort.inc
+SET collation_connection='sjis_bin';
+-- source include/ctype_filesort.inc
diff --git a/mysql-test/t/ctype_tis620.test b/mysql-test/t/ctype_tis620.test
index 21ec314dca7..87047db9b54 100644
--- a/mysql-test/t/ctype_tis620.test
+++ b/mysql-test/t/ctype_tis620.test
@@ -151,3 +151,9 @@ INSERT INTO t1 VALUES
n X Wallpapers',1,'','2002-05-31','',579,0,'',1091,0,0,'');
select * from t1 order by id;
DROP TABLE t1;
+
+
+SET collation_connection='tis620_thai_ci';
+-- source include/ctype_filesort.inc
+SET collation_connection='tis620_bin';
+-- source include/ctype_filesort.inc
diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test
index 8bca2a4b3c2..dfca82fa70a 100644
--- a/mysql-test/t/ctype_uca.test
+++ b/mysql-test/t/ctype_uca.test
@@ -452,3 +452,6 @@ create table t1 (a varchar(1)) character set utf8 collate utf8_estonian_ci;
insert into t1 values ('A'),('B'),('C'),('a'),('b'),('c');
select a, a regexp '[a]' from t1 order by binary a;
drop table t1;
+
+SET collation_connection='utf8_unicode_ci';
+-- source include/ctype_filesort.inc
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index 506c47ae55a..4780f51ebaa 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -386,3 +386,9 @@ alter table t1 add b char(1);
show warnings;
select * from t1 order by a;
drop table t1;
+
+SET collation_connection='ucs2_general_ci';
+-- source include/ctype_filesort.inc
+SET NAMES latin1;
+SET collation_connection='ucs2_bin';
+-- source include/ctype_filesort.inc
diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test
index 3f0e9882179..407287be30a 100644
--- a/mysql-test/t/ctype_ujis.test
+++ b/mysql-test/t/ctype_ujis.test
@@ -1141,3 +1141,9 @@ INSERT INTO t1 VALUES(0xF4FD);
INSERT INTO t1 VALUES(0xF4FE);
SELECT HEX(c) FROM t1 ORDER BY BINARY c;
DROP TABLE t1;
+
+
+SET collation_connection='ujis_japanese_ci';
+-- source include/ctype_filesort.inc
+SET collation_connection='ujis_bin';
+-- source include/ctype_filesort.inc
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index 214c2712665..a57db4455ab 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -675,3 +675,9 @@ select * from t1 where soundex(a) = soundex('Test');
select * from t1 where soundex(a) = soundex('TEST');
select * from t1 where soundex(a) = soundex('test');
drop table t1;
+
+
+SET collation_connection='utf8_general_ci';
+-- source include/ctype_filesort.inc
+SET collation_connection='utf8_bin';
+-- source include/ctype_filesort.inc
diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test
index d46a88b9166..d9cc9de6ff1 100644
--- a/mysql-test/t/ps_1general.test
+++ b/mysql-test/t/ps_1general.test
@@ -11,10 +11,6 @@
--disable_warnings
drop table if exists t5, t6, t7, t8;
drop database if exists mysqltest ;
-# Cleanup from other tests
-drop database if exists testtets;
-drop table if exists t1Aa,t2Aa,v1Aa,v2Aa;
-drop view if exists t1Aa,t2Aa,v1Aa,v2Aa;
--enable_warnings
--disable_query_log
@@ -321,7 +317,7 @@ prepare stmt4 from ' show engine bdb logs ';
execute stmt4;
--enable_result_log
prepare stmt4 from ' show full processlist ';
---replace_column 1 number 6 seconds
+--replace_column 1 number 6 time
execute stmt4;
prepare stmt4 from ' show grants for user ';
--error 1295
@@ -478,7 +474,9 @@ prepare stmt1 from ' handler t1 open ';
## commit/rollback
+--error 1295
prepare stmt3 from ' commit ' ;
+--error 1295
prepare stmt3 from ' rollback ' ;
@@ -579,8 +577,11 @@ execute stmt3 using @arg00;
select m from t3;
drop table t3;
+--error 1295
prepare stmt3 from ' create index t2_idx on t2(b) ';
+--error 1295
prepare stmt3 from ' drop index t2_idx on t2 ' ;
+--error 1295
prepare stmt3 from ' alter table t2 drop primary key ';
## RENAME TABLE
diff --git a/sql/field.cc b/sql/field.cc
index 175ca09df37..41b6eba695c 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -4482,8 +4482,7 @@ void Field_string::sort_string(char *to,uint length)
uint tmp=my_strnxfrm(field_charset,
(unsigned char *) to, length,
(unsigned char *) ptr, field_length);
- if (tmp < length)
- field_charset->cset->fill(field_charset, to + tmp, length - tmp, ' ');
+ DBUG_ASSERT(tmp == length);
}
@@ -4834,9 +4833,7 @@ void Field_varstring::sort_string(char *to,uint length)
(uchar*) to, length,
(uchar*) ptr + length_bytes,
tot_length);
- if (tot_length < length)
- field_charset->cset->fill(field_charset, to+tot_length,length-tot_length,
- binary() ? (char) 0 : ' ');
+ DBUG_ASSERT(tot_length == length);
}
@@ -5511,10 +5508,7 @@ void Field_blob::sort_string(char *to,uint length)
blob_length=my_strnxfrm(field_charset,
(uchar*) to, length,
(uchar*) blob, blob_length);
- if (blob_length < length)
- field_charset->cset->fill(field_charset, to+blob_length,
- length-blob_length,
- binary() ? (char) 0 : ' ');
+ DBUG_ASSERT(blob_length == length);
}
}
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 41104106048..fc8e27c5f94 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -660,10 +660,7 @@ static void make_sortkey(register SORTPARAM *param,
}
uint tmp_length=my_strnxfrm(cs,to,sort_field->length,
(unsigned char *) from, length);
- if (tmp_length < sort_field->length)
- cs->cset->fill(cs, (char*) to+tmp_length,
- sort_field->length-tmp_length,
- fill_char);
+ DBUG_ASSERT(tmp_length == sort_field->length);
}
else
{
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index d9532cddc4d..a2db7de244e 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -307,6 +307,7 @@ static int my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)),
const uchar * src, uint srclen)
{
uint16 e;
+ uint dstlen= len;
len = srclen;
while (len--)
@@ -321,7 +322,9 @@ static int my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)),
} else
*dest++ = sort_order_big5[(uchar) *src++];
}
- return srclen;
+ if (dstlen > srclen)
+ bfill(dest, dstlen - srclen, ' ');
+ return dstlen;
}
#if 0
diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c
index db57c75d9f1..401605a462f 100644
--- a/strings/ctype-bin.c
+++ b/strings/ctype-bin.c
@@ -356,13 +356,27 @@ static int my_wildcmp_bin(CHARSET_INFO *cs,
static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)),
- uchar * dest, uint len,
- const uchar *src,
- uint srclen __attribute__((unused)))
+ uchar * dest, uint dstlen,
+ const uchar *src, uint srclen)
{
if (dest != src)
- memcpy(dest,src,len= min(len,srclen));
- return len;
+ memcpy(dest, src, min(dstlen,srclen));
+ if (dstlen > srclen)
+ bfill(dest + srclen, dstlen - srclen, 0);
+ return dstlen;
+}
+
+
+static
+int my_strnxfrm_8bit_bin(CHARSET_INFO *cs __attribute__((unused)),
+ uchar * dest, uint dstlen,
+ const uchar *src, uint srclen)
+{
+ if (dest != src)
+ memcpy(dest, src, min(dstlen,srclen));
+ if (dstlen > srclen)
+ bfill(dest + srclen, dstlen - srclen, ' ');
+ return dstlen;
}
@@ -432,7 +446,7 @@ MY_COLLATION_HANDLER my_collation_8bit_bin_handler =
NULL, /* init */
my_strnncoll_8bit_bin,
my_strnncollsp_8bit_bin,
- my_strnxfrm_bin,
+ my_strnxfrm_8bit_bin,
my_like_range_simple,
my_wildcmp_bin,
my_strcasecmp_bin,
diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c
index 76981200a4d..2834dbb28ff 100644
--- a/strings/ctype-czech.c
+++ b/strings/ctype-czech.c
@@ -298,16 +298,18 @@ static int my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)),
int value;
const uchar * p, * store;
int pass = 0;
- int totlen = 0;
+ uint totlen = 0;
p = src; store = src;
do
{
NEXT_CMP_VALUE(src, p, store, pass, value, (int)srclen);
- ADD_TO_RESULT(dest, (int)len, totlen, value);
+ ADD_TO_RESULT(dest, len, totlen, value);
}
while (value);
- return totlen;
+ if (len > totlen)
+ bfill(dest + totlen, len - totlen, ' ');
+ return len;
}
#undef IS_END
diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c
index 858624c0600..dc4aea60096 100644
--- a/strings/ctype-gbk.c
+++ b/strings/ctype-gbk.c
@@ -2668,6 +2668,7 @@ static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)),
const uchar * src, uint srclen)
{
uint16 e;
+ uint dstlen= len;
len = srclen;
while (len--)
@@ -2682,7 +2683,9 @@ static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)),
} else
*dest++ = sort_order_gbk[(uchar) *src++];
}
- return srclen;
+ if (dstlen > srclen)
+ bfill(dest, dstlen - srclen, ' ');
+ return dstlen;
}
diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c
index 69c9ed4b023..b5da99a7452 100644
--- a/strings/ctype-latin1.c
+++ b/strings/ctype-latin1.c
@@ -646,7 +646,6 @@ static int my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
uchar * dest, uint len,
const uchar * src, uint srclen)
{
- const uchar *dest_orig = dest;
const uchar *de = dest + len;
const uchar *se = src + srclen;
for ( ; src < se && dest < de ; src++)
@@ -656,7 +655,9 @@ static int my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
if ((chr=combo2map[*src]) && dest < de)
*dest++=chr;
}
- return (int) (dest - dest_orig);
+ if (dest < de)
+ bfill(dest, de - dest, ' ');
+ return (int) len;
}
diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c
index 0475fb0fbb1..4be21599fef 100644
--- a/strings/ctype-mb.c
+++ b/strings/ctype-mb.c
@@ -425,13 +425,14 @@ static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
static int my_strnxfrm_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
- uchar * dest, uint len,
- const uchar *src,
- uint srclen __attribute__((unused)))
+ uchar * dest, uint dstlen,
+ const uchar *src, uint srclen)
{
if (dest != src)
- memcpy(dest,src,len= min(len,srclen));
- return len;
+ memcpy(dest, src, min(dstlen, srclen));
+ if (dstlen > srclen)
+ bfill(dest + srclen, dstlen - srclen, ' ');
+ return dstlen;
}
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 0659cb5d387..1df81c88258 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -21,27 +21,68 @@
#include "stdarg.h"
+/*
+ Converts a string into its sort key.
+
+ SYNOPSIS
+ my_strnxfrm_xxx()
+
+ IMPLEMENTATION
+
+ The my_strxfrm_xxx() function transforms a string pointed to by
+ 'src' with length 'srclen' according to the charset+collation
+ pair 'cs' and copies the result key into 'dest'.
+
+ Comparing two strings using memcmp() after my_strnxfrm_xxx()
+ is equal to comparing two original strings with my_strnncollsp_xxx().
+
+ Not more than 'dstlen' bytes are written into 'dst'.
+ To garantee that the whole string is transformed, 'dstlen' must be
+ at least srclen*cs->strnxfrm_multiply bytes long. Otherwise,
+ consequent memcmp() may return a non-accurate result.
+
+ If the source string is too short to fill whole 'dstlen' bytes,
+ then the 'dest' string is padded up to 'dstlen', ensuring that:
+
+ "a" == "a "
+ "a\0" < "a"
+ "a\0" < "a "
+
+ my_strnxfrm_simple() is implemented for 8bit charsets and
+ simple collations with one-to-one string->key transformation.
+
+ See also implementations for various charsets/collations in
+ other ctype-xxx.c files.
+
+ RETURN
+
+ Target len 'dstlen'.
+
+*/
+
int my_strnxfrm_simple(CHARSET_INFO * cs,
uchar *dest, uint len,
const uchar *src, uint srclen)
{
uchar *map= cs->sort_order;
+ uint dstlen= len;
set_if_smaller(len, srclen);
if (dest != src)
{
const uchar *end;
for ( end=src+len; src < end ; )
*dest++= map[*src++];
- return len;
}
else
{
const uchar *end;
for ( end=dest+len; dest < end ; dest++)
*dest= (char) map[(uchar) *dest];
- return len;
}
+ if (dstlen > len)
+ bfill(dest, dstlen - len, ' ');
+ return dstlen;
}
int my_strnncoll_simple(CHARSET_INFO * cs, const uchar *s, uint slen,
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index 12bee9082b6..c1e41dc2d94 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -299,7 +299,9 @@ static int my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)),
else
*dest++ = sort_order_sjis[(uchar)*src++];
}
- return srclen;
+ if (len > srclen)
+ bfill(dest, len - srclen, ' ');
+ return len;
}
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c
index 80af8e2014b..c6bdd106ad4 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -638,9 +638,13 @@ int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)),
uchar * dest, uint len,
const uchar * src, uint srclen)
{
+ uint dstlen= len;
len= (uint) (strmake((char*) dest, (char*) src, min(len, srclen)) -
(char*) dest);
- return (int) thai2sortable(dest, len);
+ len= thai2sortable(dest, len);
+ if (dstlen > len)
+ bfill(dest + len, dstlen - len, ' ');
+ return dstlen;
}
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c
index fb44a56ef0f..605dd2cdab0 100644
--- a/strings/ctype-uca.c
+++ b/strings/ctype-uca.c
@@ -7220,8 +7220,7 @@ static int my_strnxfrm_uca(CHARSET_INFO *cs,
uchar *dst, uint dstlen,
const uchar *src, uint srclen)
{
- uchar *de = dst + dstlen;
- const uchar *dst_orig = dst;
+ uchar *de = dst + (dstlen & (uint) ~1); // add even length for easier code
int s_res;
my_uca_scanner scanner;
scanner_handler->init(&scanner, cs, src, srclen);
@@ -7232,8 +7231,17 @@ static int my_strnxfrm_uca(CHARSET_INFO *cs,
dst[1]= s_res & 0xFF;
dst+= 2;
}
- for ( ; dst < de; *dst++='\0');
- return dst - dst_orig;
+ s_res= cs->sort_order_big[0][0x20 * cs->sort_order[0]];
+ while (dst < de)
+ {
+ dst[0]= s_res >> 8;
+ dst[1]= s_res & 0xFF;
+ dst+= 2;
+ }
+ if (dstlen & 1) // if odd number then fill the last char
+ *dst= '\0';
+
+ return dstlen;
}
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index d21b340e768..6bd93a93e8a 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -352,7 +352,6 @@ static int my_strnxfrm_ucs2(CHARSET_INFO *cs,
int plane;
uchar *de = dst + dstlen;
const uchar *se = src + srclen;
- const uchar *dst_orig = dst;
while( src < se && dst < de )
{
@@ -372,7 +371,9 @@ static int my_strnxfrm_ucs2(CHARSET_INFO *cs,
}
dst+=res;
}
- return dst - dst_orig;
+ if (dst < de)
+ cs->cset->fill(cs, dst, de - dst, ' ');
+ return dstlen;
}
@@ -1385,7 +1386,9 @@ int my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)),
{
if (dst != src)
memcpy(dst,src,srclen= min(dstlen,srclen));
- return srclen;
+ if (dstlen > srclen)
+ cs->cset->fill(cs, dst + srclen, dstlen - srclen, ' ');
+ return dstlen;
}
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index ab646d36e25..1f9f158a73d 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -2247,7 +2247,6 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs,
int plane;
uchar *de = dst + dstlen;
const uchar *se = src + srclen;
- const uchar *dst_orig = dst;
while( src < se && dst < de )
{
@@ -2267,7 +2266,9 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs,
}
dst+=res;
}
- return dst - dst_orig;
+ if (dst < de)
+ bfill(dst, de - dst, ' ');
+ return dstlen;
}
static int my_ismbchar_utf8(CHARSET_INFO *cs,const char *b, const char *e)
diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c
index 397dcd6f2f2..b58a8f0f1e5 100644
--- a/strings/ctype-win1250ch.c
+++ b/strings/ctype-win1250ch.c
@@ -505,7 +505,9 @@ static int my_strnxfrm_win1250ch(CHARSET_INFO * cs __attribute__((unused)),
dest[totlen] = value;
totlen++;
} while (value) ;
- return totlen;
+ if (len > totlen)
+ bfill(dest + totlen, len - totlen, ' ');
+ return len;
}
#undef IS_END