summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorevgen@moonbone.local <>2005-06-21 20:14:50 +0400
committerevgen@moonbone.local <>2005-06-21 20:14:50 +0400
commite94f16a12592a713468091526f6fa4cfe259bedd (patch)
tree6501029548efdd69348739e2cb1394f4ffb960c0
parent637a353d93a549587993c9edad52e7bada67ad88 (diff)
downloadmariadb-git-e94f16a12592a713468091526f6fa4cfe259bedd.tar.gz
Fix bug #7422 "order by" doesn't work
Field with wrong buffer was used to make sort key, which results in producing same sort key for all records.
-rw-r--r--mysql-test/r/view.result14
-rw-r--r--mysql-test/t/view.test12
-rw-r--r--sql/filesort.cc10
3 files changed, 31 insertions, 5 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 84be086ae37..1c96ceb6439 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -1726,3 +1726,17 @@ sum(a)
drop procedure p1;
drop view v1;
drop table t1;
+CREATE TABLE t1(a char(2) primary key, b char(2));
+CREATE TABLE t2(a char(2), b char(2), index i(a));
+INSERT INTO t1 VALUES ('a','1'), ('b','2');
+INSERT INTO t2 VALUES ('a','5'), ('a','6'), ('b','5'), ('b','6');
+CREATE VIEW v1 AS
+SELECT t1.b as c, t2.b as d FROM t1,t2 WHERE t1.a=t2.a;
+SELECT d, c FROM v1 ORDER BY d;
+d c
+5 1
+5 2
+6 1
+6 2
+DROP VIEW v1;
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 0477ab0ea20..7d075f10abe 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -1569,3 +1569,15 @@ drop procedure p1;
drop view v1;
drop table t1;
+#
+# Bug#7422 "order by" doesn't work
+#
+CREATE TABLE t1(a char(2) primary key, b char(2));
+CREATE TABLE t2(a char(2), b char(2), index i(a));
+INSERT INTO t1 VALUES ('a','1'), ('b','2');
+INSERT INTO t2 VALUES ('a','5'), ('a','6'), ('b','5'), ('b','6');
+CREATE VIEW v1 AS
+ SELECT t1.b as c, t2.b as d FROM t1,t2 WHERE t1.a=t2.a;
+SELECT d, c FROM v1 ORDER BY d;
+DROP VIEW v1;
+DROP TABLE t1, t2;
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 30ebd8d59e1..75da43afed5 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -631,7 +631,7 @@ static void make_sortkey(register SORTPARAM *param,
*to++=1;
/* All item->str() to use some extra byte for end null.. */
String tmp((char*) to,sort_field->length+4,cs);
- String *res=item->val_str(&tmp);
+ String *res= item->str_result(&tmp);
if (!res)
{
if (maybe_null)
@@ -673,8 +673,8 @@ static void make_sortkey(register SORTPARAM *param,
}
case INT_RESULT:
{
- longlong value=item->val_int();
- if (maybe_null)
+ longlong value= item->val_int_result();
+ if (maybe_null)
{
*to++=1; /* purecov: inspected */
if (item->null_value)
@@ -715,7 +715,7 @@ static void make_sortkey(register SORTPARAM *param,
}
case DECIMAL_RESULT:
{
- my_decimal dec_buf, *dec_val= item->val_decimal(&dec_buf);
+ my_decimal dec_buf, *dec_val= item->val_decimal_result(&dec_buf);
if (maybe_null)
{
if (item->null_value)
@@ -733,7 +733,7 @@ static void make_sortkey(register SORTPARAM *param,
}
case REAL_RESULT:
{
- double value= item->val_real();
+ double value= item->val_result();
if (maybe_null)
{
if (item->null_value)