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
f31625e6
Commit
f31625e6
authored
Jul 28, 2005
by
igor@rurik.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Manual merge
parents
16963e6d
bcbde8af
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
1 deletion
+64
-1
mysql-test/r/null_key.result
mysql-test/r/null_key.result
+31
-0
mysql-test/t/null_key.test
mysql-test/t/null_key.test
+25
-0
sql/sql_select.cc
sql/sql_select.cc
+8
-1
No files found.
mysql-test/r/null_key.result
View file @
f31625e6
...
...
@@ -364,3 +364,34 @@ select * from t1;
id id2
1 1
drop table t1;
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int, b int, INDEX idx(a));
CREATE TABLE t3 (b int, INDEX idx(b));
INSERT INTO t1 VALUES (1), (2), (3), (4);
INSERT INTO t2 VALUES (1, 1), (3, 1);
INSERT INTO t3 VALUES
(NULL), (NULL), (NULL), (NULL), (NULL),
(NULL), (NULL), (NULL), (NULL), (NULL),
(2);
ANALYZE table t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
test.t3 analyze status OK
EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a
LEFT JOIN t3 ON t2.b=t3.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
1 SIMPLE t2 ref idx idx 5 test.t1.a 1
1 SIMPLE t3 ref idx idx 5 test.t2.b 1 Using index
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a
LEFT JOIN t3 ON t2.b=t3.b;
a a b b
1 1 1 NULL
2 NULL NULL NULL
3 3 1 NULL
4 NULL NULL NULL
SELECT FOUND_ROWS();
FOUND_ROWS()
4
DROP TABLE t1,t2,t3;
mysql-test/t/null_key.test
View file @
f31625e6
...
...
@@ -192,4 +192,29 @@ delete from t1 where id <=> NULL;
select
*
from
t1
;
drop
table
t1
;
#
# Test for bug #12144: optimizations for key access with null keys
# used for outer joins
#
CREATE
TABLE
t1
(
a
int
);
CREATE
TABLE
t2
(
a
int
,
b
int
,
INDEX
idx
(
a
));
CREATE
TABLE
t3
(
b
int
,
INDEX
idx
(
b
));
INSERT
INTO
t1
VALUES
(
1
),
(
2
),
(
3
),
(
4
);
INSERT
INTO
t2
VALUES
(
1
,
1
),
(
3
,
1
);
INSERT
INTO
t3
VALUES
(
NULL
),
(
NULL
),
(
NULL
),
(
NULL
),
(
NULL
),
(
NULL
),
(
NULL
),
(
NULL
),
(
NULL
),
(
NULL
),
(
2
);
ANALYZE
table
t1
,
t2
,
t3
;
EXPLAIN
SELECT
SQL_CALC_FOUND_ROWS
*
FROM
t1
LEFT
JOIN
t2
ON
t1
.
a
=
t2
.
a
LEFT
JOIN
t3
ON
t2
.
b
=
t3
.
b
;
SELECT
SQL_CALC_FOUND_ROWS
*
FROM
t1
LEFT
JOIN
t2
ON
t1
.
a
=
t2
.
a
LEFT
JOIN
t3
ON
t2
.
b
=
t3
.
b
;
SELECT
FOUND_ROWS
();
DROP
TABLE
t1
,
t2
,
t3
;
# End of 4.1 tests
sql/sql_select.cc
View file @
f31625e6
...
...
@@ -2262,7 +2262,9 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, Item_func *cond,
*/
(
*
key_fields
)
->
null_rejecting
=
(
cond
->
functype
()
==
Item_func
::
EQ_FUNC
)
&&
((
*
value
)
->
type
()
==
Item
::
FIELD_ITEM
)
&&
((
Item_field
*
)
*
value
)
->
field
->
maybe_null
();
(((
Item_field
*
)
*
value
)
->
field
->
maybe_null
()
||
((
Item_field
*
)
*
value
)
->
field
->
table
->
maybe_null
);
(
*
key_fields
)
++
;
}
...
...
@@ -6317,6 +6319,11 @@ join_read_always_key(JOIN_TAB *tab)
int
error
;
TABLE
*
table
=
tab
->
table
;
for
(
uint
i
=
0
;
i
<
tab
->
ref
.
key_parts
;
i
++
)
{
if
((
tab
->
ref
.
null_rejecting
&
1
<<
i
)
&&
tab
->
ref
.
items
[
i
]
->
is_null
())
return
-
1
;
}
if
(
!
table
->
file
->
inited
)
table
->
file
->
ha_index_init
(
tab
->
ref
.
key
);
if
(
cp_buffer_from_ref
(
tab
->
join
->
thd
,
&
tab
->
ref
))
...
...
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