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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
44bcc5ef
Commit
44bcc5ef
authored
Nov 10, 2009
by
Georgi Kodinov
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
eaef8ba8
b41d9093
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
50 deletions
+107
-50
mysql-test/r/order_by.result
mysql-test/r/order_by.result
+21
-0
mysql-test/t/order_by.test
mysql-test/t/order_by.test
+25
-0
sql/sql_select.cc
sql/sql_select.cc
+61
-50
No files found.
mysql-test/r/order_by.result
View file @
44bcc5ef
...
@@ -1444,6 +1444,27 @@ FROM t3;
...
@@ -1444,6 +1444,27 @@ FROM t3;
2
2
NULL
NULL
DROP TABLE t1, t2, t3;
DROP TABLE t1, t2, t3;
#
# Bug #42760: Select doesn't return desired results when we have null
# values
#
CREATE TABLE t1 (
a INT,
c INT,
UNIQUE KEY a_c (a,c),
KEY (a));
INSERT INTO t1 VALUES (1, 10), (2, NULL);
# Must use ref-or-null on the a_c index
EXPLAIN
SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref_or_null a_c,a a_c 10 const,const 1 Using where
# Must return 1 row
SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
col
1
DROP TABLE t1;
End of 5.0 tests
CREATE TABLE t2 (a varchar(32), b int(11), c float, d double,
CREATE TABLE t2 (a varchar(32), b int(11), c float, d double,
UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c));
UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c));
CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b));
CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b));
...
...
mysql-test/t/order_by.test
View file @
44bcc5ef
...
@@ -867,6 +867,31 @@ SELECT
...
@@ -867,6 +867,31 @@ SELECT
DROP
TABLE
t1
,
t2
,
t3
;
DROP
TABLE
t1
,
t2
,
t3
;
--
echo
#
--
echo
# Bug #42760: Select doesn't return desired results when we have null
--
echo
# values
--
echo
#
CREATE
TABLE
t1
(
a
INT
,
c
INT
,
UNIQUE
KEY
a_c
(
a
,
c
),
KEY
(
a
));
INSERT
INTO
t1
VALUES
(
1
,
10
),
(
2
,
NULL
);
--
echo
# Must use ref-or-null on the a_c index
EXPLAIN
SELECT
1
AS
col
FROM
t1
WHERE
a
=
2
AND
(
c
=
10
OR
c
IS
NULL
)
ORDER
BY
c
;
--
echo
# Must return 1 row
SELECT
1
AS
col
FROM
t1
WHERE
a
=
2
AND
(
c
=
10
OR
c
IS
NULL
)
ORDER
BY
c
;
DROP
TABLE
t1
;
--
echo
End
of
5.0
tests
#
#
# Bug #35206: select query result different if the key is indexed or not
# Bug #35206: select query result different if the key is indexed or not
#
#
...
...
sql/sql_select.cc
View file @
44bcc5ef
...
@@ -6487,6 +6487,56 @@ void rr_unlock_row(st_join_table *tab)
...
@@ -6487,6 +6487,56 @@ void rr_unlock_row(st_join_table *tab)
/**
Pick the appropriate access method functions
Sets the functions for the selected table access method
@param tab Table reference to put access method
*/
static
void
pick_table_access_method
(
JOIN_TAB
*
tab
)
{
switch
(
tab
->
type
)
{
case
JT_REF
:
tab
->
read_first_record
=
join_read_always_key
;
tab
->
read_record
.
read_record
=
join_read_next_same
;
break
;
case
JT_REF_OR_NULL
:
tab
->
read_first_record
=
join_read_always_key_or_null
;
tab
->
read_record
.
read_record
=
join_read_next_same_or_null
;
break
;
case
JT_CONST
:
tab
->
read_first_record
=
join_read_const
;
tab
->
read_record
.
read_record
=
join_no_more_records
;
break
;
case
JT_EQ_REF
:
tab
->
read_first_record
=
join_read_key
;
tab
->
read_record
.
read_record
=
join_no_more_records
;
break
;
case
JT_FT
:
tab
->
read_first_record
=
join_ft_read_first
;
tab
->
read_record
.
read_record
=
join_ft_read_next
;
break
;
case
JT_SYSTEM
:
tab
->
read_first_record
=
join_read_system
;
tab
->
read_record
.
read_record
=
join_no_more_records
;
break
;
/* keep gcc happy */
default:
break
;
}
}
static
void
static
void
make_join_readinfo
(
JOIN
*
join
,
ulonglong
options
)
make_join_readinfo
(
JOIN
*
join
,
ulonglong
options
)
{
{
...
@@ -6521,45 +6571,15 @@ make_join_readinfo(JOIN *join, ulonglong options)
...
@@ -6521,45 +6571,15 @@ make_join_readinfo(JOIN *join, ulonglong options)
tab
->
sorted
=
sorted
;
tab
->
sorted
=
sorted
;
sorted
=
0
;
// only first must be sorted
sorted
=
0
;
// only first must be sorted
switch
(
tab
->
type
)
{
case
JT_SYSTEM
:
// Only happens with left join
table
->
status
=
STATUS_NO_RECORD
;
tab
->
read_first_record
=
join_read_system
;
tab
->
read_record
.
read_record
=
join_no_more_records
;
break
;
case
JT_CONST
:
// Only happens with left join
table
->
status
=
STATUS_NO_RECORD
;
table
->
status
=
STATUS_NO_RECORD
;
tab
->
read_first_record
=
join_read_const
;
pick_table_access_method
(
tab
);
tab
->
read_record
.
read_record
=
join_no_more_records
;
if
(
table
->
covering_keys
.
is_set
(
tab
->
ref
.
key
)
&&
switch
(
tab
->
type
)
{
!
table
->
no_keyread
)
{
table
->
key_read
=
1
;
table
->
file
->
extra
(
HA_EXTRA_KEYREAD
);
}
break
;
case
JT_EQ_REF
:
case
JT_EQ_REF
:
table
->
status
=
STATUS_NO_RECORD
;
if
(
tab
->
select
)
{
delete
tab
->
select
->
quick
;
tab
->
select
->
quick
=
0
;
}
delete
tab
->
quick
;
tab
->
quick
=
0
;
tab
->
read_first_record
=
join_read_key
;
tab
->
read_record
.
unlock_row
=
join_read_key_unlock_row
;
tab
->
read_record
.
unlock_row
=
join_read_key_unlock_row
;
tab
->
read_record
.
read_record
=
join_no_more_records
;
/* fall through */
if
(
table
->
covering_keys
.
is_set
(
tab
->
ref
.
key
)
&&
!
table
->
no_keyread
)
{
table
->
key_read
=
1
;
table
->
file
->
extra
(
HA_EXTRA_KEYREAD
);
}
break
;
case
JT_REF_OR_NULL
:
case
JT_REF_OR_NULL
:
case
JT_REF
:
case
JT_REF
:
table
->
status
=
STATUS_NO_RECORD
;
if
(
tab
->
select
)
if
(
tab
->
select
)
{
{
delete
tab
->
select
->
quick
;
delete
tab
->
select
->
quick
;
...
@@ -6567,34 +6587,20 @@ make_join_readinfo(JOIN *join, ulonglong options)
...
@@ -6567,34 +6587,20 @@ make_join_readinfo(JOIN *join, ulonglong options)
}
}
delete
tab
->
quick
;
delete
tab
->
quick
;
tab
->
quick
=
0
;
tab
->
quick
=
0
;
/* fall through */
case
JT_CONST
:
// Only happens with left join
if
(
table
->
covering_keys
.
is_set
(
tab
->
ref
.
key
)
&&
if
(
table
->
covering_keys
.
is_set
(
tab
->
ref
.
key
)
&&
!
table
->
no_keyread
)
!
table
->
no_keyread
)
{
{
table
->
key_read
=
1
;
table
->
key_read
=
1
;
table
->
file
->
extra
(
HA_EXTRA_KEYREAD
);
table
->
file
->
extra
(
HA_EXTRA_KEYREAD
);
}
}
if
(
tab
->
type
==
JT_REF
)
{
tab
->
read_first_record
=
join_read_always_key
;
tab
->
read_record
.
read_record
=
join_read_next_same
;
}
else
{
tab
->
read_first_record
=
join_read_always_key_or_null
;
tab
->
read_record
.
read_record
=
join_read_next_same_or_null
;
}
break
;
case
JT_FT
:
table
->
status
=
STATUS_NO_RECORD
;
tab
->
read_first_record
=
join_ft_read_first
;
tab
->
read_record
.
read_record
=
join_ft_read_next
;
break
;
break
;
case
JT_ALL
:
case
JT_ALL
:
/*
/*
If previous table use cache
If previous table use cache
If the incoming data set is already sorted don't use cache.
If the incoming data set is already sorted don't use cache.
*/
*/
table
->
status
=
STATUS_NO_RECORD
;
if
(
i
!=
join
->
const_tables
&&
!
(
options
&
SELECT_NO_JOIN_CACHE
)
&&
if
(
i
!=
join
->
const_tables
&&
!
(
options
&
SELECT_NO_JOIN_CACHE
)
&&
tab
->
use_quick
!=
2
&&
!
tab
->
first_inner
&&
!
ordered_set
)
tab
->
use_quick
!=
2
&&
!
tab
->
first_inner
&&
!
ordered_set
)
{
{
...
@@ -6674,6 +6680,9 @@ make_join_readinfo(JOIN *join, ulonglong options)
...
@@ -6674,6 +6680,9 @@ make_join_readinfo(JOIN *join, ulonglong options)
}
}
}
}
break
;
break
;
case
JT_FT
:
case
JT_SYSTEM
:
break
;
default:
default:
DBUG_PRINT
(
"error"
,(
"Table type %d found"
,
tab
->
type
));
/* purecov: deadcode */
DBUG_PRINT
(
"error"
,(
"Table type %d found"
,
tab
->
type
));
/* purecov: deadcode */
break
;
/* purecov: deadcode */
break
;
/* purecov: deadcode */
...
@@ -13195,6 +13204,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
...
@@ -13195,6 +13204,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
if
(
create_ref_for_key
(
tab
->
join
,
tab
,
keyuse
,
if
(
create_ref_for_key
(
tab
->
join
,
tab
,
keyuse
,
tab
->
join
->
const_table_map
))
tab
->
join
->
const_table_map
))
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
pick_table_access_method
(
tab
);
}
}
else
else
{
{
...
...
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