mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Move handling of suffix_length from strnxfrm_bin() to filesort to ensure proper sorting of all kind of binary objects
field::sort_key() now adds length last for varbinary/blob VARBINARY/BLOB is now sorted by filesort so that shorter strings comes before longer ones Fixed issues in test cases from last merge mysql-test/r/select.result: Change column name in test to get GROUP BY to use the alias mysql-test/r/type_blob.result: Test BLOB and VARCHAR sorting mysql-test/t/select.test: Change column name in test to get GROUP BY to use the alias Drop used tables at start of test Don't use table names 'a', 'b' or 'c' mysql-test/t/type_blob.test: Test BLOB and VARCHAR sorting sql/field.cc: Store length last in VARBINARY() and BLOB() columns to get shorter strings sorted before longer onces sql/field.h: Added method 'sort_length()' to allow one to have length bytes last for VARBINARY/BLOB to get these to sort properly sql/filesort.cc: Use 'sort_length()' instead of 'pack_length()' to get length of field. Store suffix_length last for varbinary (blob) objects. The above ensures that BLOB/VARBINARY are correctly sorted (shorter strings before longer ones) sql/sql_class.h: Added sort suffix length (to get varbinary/blob to sort correctly) sql/sql_select.cc: Use sort_length() instead of pack_lengths() strings/ctype-bin.c: Don't let strnxfrm_bin store length last Better to do it in MySQL field object to ensure it's done properly for all cases
This commit is contained in:
@ -2668,10 +2668,9 @@ a c
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) );
|
||||
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4);
|
||||
CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, c INT );
|
||||
INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),
|
||||
(1,2,3);
|
||||
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
|
||||
CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT );
|
||||
INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3);
|
||||
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
|
||||
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;
|
||||
a b c d
|
||||
1 2 1 1
|
||||
@ -2679,14 +2678,14 @@ a b c d
|
||||
1 2 3 1
|
||||
1 10 2
|
||||
1 11 2
|
||||
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
|
||||
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
|
||||
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c;
|
||||
a b c d
|
||||
1 10 4
|
||||
1 2 1 1
|
||||
1 2 2 1
|
||||
1 2 3 1
|
||||
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
|
||||
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN
|
||||
t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c;
|
||||
a b c d
|
||||
1 2 1 1
|
||||
@ -2694,7 +2693,7 @@ a b c d
|
||||
1 2 3 1
|
||||
1 10 2
|
||||
1 11 2
|
||||
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2,t1
|
||||
SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1
|
||||
WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;
|
||||
a b c d
|
||||
1 2 1 1
|
||||
|
Reference in New Issue
Block a user