Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
b6534b66
Commit
b6534b66
authored
Apr 26, 2003
by
igor@hundin.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filesort.cc, order_by.result:
Fixed bug 263 order_by.test: Fixed bug 263
parent
2ad37c06
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
4 deletions
+46
-4
mysql-test/r/order_by.result
mysql-test/r/order_by.result
+25
-0
mysql-test/t/order_by.test
mysql-test/t/order_by.test
+14
-0
sql/filesort.cc
sql/filesort.cc
+7
-4
No files found.
mysql-test/r/order_by.result
View file @
b6534b66
...
...
@@ -517,3 +517,28 @@ SELECT titre,t1.numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,des
titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest
test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug
drop table t1,t2;
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (1, 2);
INSERT INTO t1 VALUES (3, 4);
INSERT INTO t1 VALUES (5, NULL);
SELECT * FROM t1 ORDER BY b;
a b
5 NULL
1 2
3 4
SELECT * FROM t1 ORDER BY b DESC;
a b
3 4
1 2
5 NULL
SELECT * FROM t1 ORDER BY (a + b);
a b
5 NULL
1 2
3 4
SELECT * FROM t1 ORDER BY (a + b) DESC;
a b
3 4
1 2
5 NULL
DROP TABLE t1;
mysql-test/t/order_by.test
View file @
b6534b66
...
...
@@ -331,3 +331,17 @@ INSERT INTO t2 (numeropost,pseudo) VALUES (1,'joce'),(1,'bug');
SELECT
titre
,
t1
.
numeropost
,
auteur
,
icone
,
nbrep
,
0
,
date
,
vue
,
ouvert
,
lastauteur
,
dest
FROM
t2
LEFT
JOIN
t1
USING
(
numeropost
)
WHERE
t2
.
pseudo
=
'joce'
ORDER
BY
date
DESC
LIMIT
0
,
30
;
SELECT
titre
,
t1
.
numeropost
,
auteur
,
icone
,
nbrep
,
'0'
,
date
,
vue
,
ouvert
,
lastauteur
,
dest
FROM
t2
LEFT
JOIN
t1
USING
(
numeropost
)
WHERE
t2
.
pseudo
=
'joce'
ORDER
BY
date
DESC
LIMIT
0
,
30
;
drop
table
t1
,
t2
;
#
# Test order by with NULL values
#
CREATE
TABLE
t1
(
a
int
,
b
int
);
INSERT
INTO
t1
VALUES
(
1
,
2
);
INSERT
INTO
t1
VALUES
(
3
,
4
);
INSERT
INTO
t1
VALUES
(
5
,
NULL
);
SELECT
*
FROM
t1
ORDER
BY
b
;
SELECT
*
FROM
t1
ORDER
BY
b
DESC
;
SELECT
*
FROM
t1
ORDER
BY
(
a
+
b
);
SELECT
*
FROM
t1
ORDER
BY
(
a
+
b
)
DESC
;
DROP
TABLE
t1
;
sql/filesort.cc
View file @
b6534b66
...
...
@@ -456,6 +456,7 @@ static void make_sortkey(register SORTPARAM *param,
sort_field
!=
param
->
end
;
sort_field
++
)
{
bool
maybe_null
=
0
;
if
((
field
=
sort_field
->
field
))
{
// Field
if
(
field
->
maybe_null
())
...
...
@@ -480,7 +481,7 @@ static void make_sortkey(register SORTPARAM *param,
switch
(
sort_field
->
result_type
)
{
case
STRING_RESULT
:
{
if
(
item
->
maybe_null
)
if
(
(
maybe_null
=
item
->
maybe_null
)
)
*
to
++=
1
;
/* All item->str() to use some extra byte for end null.. */
String
tmp
((
char
*
)
to
,
sort_field
->
length
+
4
);
...
...
@@ -546,7 +547,7 @@ static void make_sortkey(register SORTPARAM *param,
case
INT_RESULT
:
{
longlong
value
=
item
->
val_int
();
if
(
item
->
maybe_null
)
if
(
(
maybe_null
=
item
->
maybe_null
)
)
*
to
++=
1
;
/* purecov: inspected */
if
(
item
->
null_value
)
{
...
...
@@ -580,13 +581,13 @@ static void make_sortkey(register SORTPARAM *param,
case
REAL_RESULT
:
{
double
value
=
item
->
val
();
if
(
item
->
null_value
)
if
(
(
maybe_null
=
item
->
null_value
)
)
{
bzero
((
char
*
)
to
,
sort_field
->
length
+
1
);
to
++
;
break
;
}
if
(
item
->
maybe_null
)
if
(
(
maybe_null
=
item
->
maybe_null
)
)
*
to
++=
1
;
change_double_for_sort
(
value
,(
byte
*
)
to
);
break
;
...
...
@@ -595,6 +596,8 @@ static void make_sortkey(register SORTPARAM *param,
}
if
(
sort_field
->
reverse
)
{
/* Revers key */
if
(
maybe_null
)
to
[
-
1
]
=
~
to
[
-
1
];
length
=
sort_field
->
length
;
while
(
length
--
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment