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
05a2329f
Commit
05a2329f
authored
Jun 26, 2009
by
Evgeny Potemkin
Browse files
Options
Browse Files
Download
Plain Diff
Merged bug#45266.
parents
4c1333e6
0e64988a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
170 additions
and
1 deletion
+170
-1
mysql-test/r/select.result
mysql-test/r/select.result
+79
-0
mysql-test/t/select.test
mysql-test/t/select.test
+86
-0
sql/sql_base.cc
sql/sql_base.cc
+1
-0
sql/sql_select.cc
sql/sql_select.cc
+0
-1
sql/structs.h
sql/structs.h
+4
-0
No files found.
mysql-test/r/select.result
View file @
05a2329f
...
...
@@ -4457,4 +4457,83 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1003 select '0' AS `a`,'0' AS `b`,'0' AS `c` from `test`.`t1` where 1
DROP TABLE t1;
#
# Bug#45266: Uninitialized variable lead to an empty result.
#
drop table if exists A,AA,B,BB;
CREATE TABLE `A` (
`pk` int(11) NOT NULL AUTO_INCREMENT,
`date_key` date NOT NULL,
`date_nokey` date NOT NULL,
`datetime_key` datetime NOT NULL,
`int_nokey` int(11) NOT NULL,
`time_key` time NOT NULL,
`time_nokey` time NOT NULL,
PRIMARY KEY (`pk`),
KEY `date_key` (`date_key`),
KEY `time_key` (`time_key`),
KEY `datetime_key` (`datetime_key`)
);
CREATE TABLE `AA` (
`pk` int(11) NOT NULL AUTO_INCREMENT,
`int_nokey` int(11) NOT NULL,
`time_key` time NOT NULL,
KEY `time_key` (`time_key`),
PRIMARY KEY (`pk`)
);
CREATE TABLE `B` (
`date_nokey` date NOT NULL,
`date_key` date NOT NULL,
`time_key` time NOT NULL,
`datetime_nokey` datetime NOT NULL,
`varchar_key` varchar(1) NOT NULL,
KEY `date_key` (`date_key`),
KEY `time_key` (`time_key`),
KEY `varchar_key` (`varchar_key`)
);
INSERT INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x');
CREATE TABLE `BB` (
`pk` int(11) NOT NULL AUTO_INCREMENT,
`int_nokey` int(11) NOT NULL,
`date_key` date NOT NULL,
`varchar_nokey` varchar(1) NOT NULL,
`date_nokey` date NOT NULL,
PRIMARY KEY (`pk`),
KEY `date_key` (`date_key`)
);
INSERT INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18');
SELECT table1 . `pk` AS field1
FROM
(BB AS table1 INNER JOIN
(AA AS table2 STRAIGHT_JOIN A AS table3
ON ( table3 . `date_key` = table2 . `pk` ))
ON ( table3 . `datetime_key` = table2 . `int_nokey` ))
WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`)
GROUP BY field1 ;
field1
SELECT table3 .`date_key` field1
FROM
B table1 LEFT JOIN B table3 JOIN
(BB table6 JOIN A table7 ON table6 .`varchar_nokey`)
ON table6 .`int_nokey` ON table6 .`date_key`
WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1;
field1
NULL
SELECT table4 . `time_nokey` AS field1 FROM
(AA AS table1 CROSS JOIN
(AA AS table2 STRAIGHT_JOIN
(B AS table3 STRAIGHT_JOIN A AS table4
ON ( table4 . `date_key` = table3 . `time_key` ))
ON ( table4 . `pk` = table3 . `date_nokey` ))
ON ( table4 . `time_key` = table3 . `datetime_nokey` ))
WHERE ( table4 . `time_key` < table1 . `time_key` AND
table1 . `int_nokey` != 'f')
GROUP BY field1 ORDER BY field1 , field1;
field1
SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2;
field2
00:05:48
15:13:38
drop table A,AA,B,BB;
#end of test for bug#45266
End of 5.1 tests
mysql-test/t/select.test
View file @
05a2329f
...
...
@@ -3799,4 +3799,90 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20;
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
(
a
=
a
AND
b
=
b
AND
a
=
a
)
OR
b
>
20
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# Bug#45266: Uninitialized variable lead to an empty result.
--
echo
#
--
disable_warnings
drop
table
if
exists
A
,
AA
,
B
,
BB
;
CREATE
TABLE
`A`
(
`pk`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`date_key`
date
NOT
NULL
,
`date_nokey`
date
NOT
NULL
,
`datetime_key`
datetime
NOT
NULL
,
`int_nokey`
int
(
11
)
NOT
NULL
,
`time_key`
time
NOT
NULL
,
`time_nokey`
time
NOT
NULL
,
PRIMARY
KEY
(
`pk`
),
KEY
`date_key`
(
`date_key`
),
KEY
`time_key`
(
`time_key`
),
KEY
`datetime_key`
(
`datetime_key`
)
);
CREATE
TABLE
`AA`
(
`pk`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`int_nokey`
int
(
11
)
NOT
NULL
,
`time_key`
time
NOT
NULL
,
KEY
`time_key`
(
`time_key`
),
PRIMARY
KEY
(
`pk`
)
);
CREATE
TABLE
`B`
(
`date_nokey`
date
NOT
NULL
,
`date_key`
date
NOT
NULL
,
`time_key`
time
NOT
NULL
,
`datetime_nokey`
datetime
NOT
NULL
,
`varchar_key`
varchar
(
1
)
NOT
NULL
,
KEY
`date_key`
(
`date_key`
),
KEY
`time_key`
(
`time_key`
),
KEY
`varchar_key`
(
`varchar_key`
)
);
INSERT
INTO
`B`
VALUES
(
'2003-07-28'
,
'2003-07-28'
,
'15:13:38'
,
'0000-00-00 00:00:00'
,
'f'
),(
'0000-00-00'
,
'0000-00-00'
,
'00:05:48'
,
'2004-07-02 14:34:13'
,
'x'
);
CREATE
TABLE
`BB`
(
`pk`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`int_nokey`
int
(
11
)
NOT
NULL
,
`date_key`
date
NOT
NULL
,
`varchar_nokey`
varchar
(
1
)
NOT
NULL
,
`date_nokey`
date
NOT
NULL
,
PRIMARY
KEY
(
`pk`
),
KEY
`date_key`
(
`date_key`
)
);
INSERT
INTO
`BB`
VALUES
(
10
,
8
,
'0000-00-00'
,
'i'
,
'0000-00-00'
),(
11
,
0
,
'2005-08-18'
,
''
,
'2005-08-18'
);
# Test #1
SELECT
table1
.
`pk`
AS
field1
FROM
(
BB
AS
table1
INNER
JOIN
(
AA
AS
table2
STRAIGHT_JOIN
A
AS
table3
ON
(
table3
.
`date_key`
=
table2
.
`pk`
))
ON
(
table3
.
`datetime_key`
=
table2
.
`int_nokey`
))
WHERE
(
table3
.
`date_key`
<=
4
AND
table2
.
`pk`
=
table1
.
`varchar_nokey`
)
GROUP
BY
field1
;
SELECT
table3
.
`date_key`
field1
FROM
B
table1
LEFT
JOIN
B
table3
JOIN
(
BB
table6
JOIN
A
table7
ON
table6
.
`varchar_nokey`
)
ON
table6
.
`int_nokey`
ON
table6
.
`date_key`
WHERE
NOT
(
table1
.
`varchar_key`
AND
table7
.
`pk`
)
GROUP
BY
field1
;
# Test #2
SELECT
table4
.
`time_nokey`
AS
field1
FROM
(
AA
AS
table1
CROSS
JOIN
(
AA
AS
table2
STRAIGHT_JOIN
(
B
AS
table3
STRAIGHT_JOIN
A
AS
table4
ON
(
table4
.
`date_key`
=
table3
.
`time_key`
))
ON
(
table4
.
`pk`
=
table3
.
`date_nokey`
))
ON
(
table4
.
`time_key`
=
table3
.
`datetime_nokey`
))
WHERE
(
table4
.
`time_key`
<
table1
.
`time_key`
AND
table1
.
`int_nokey`
!=
'f'
)
GROUP
BY
field1
ORDER
BY
field1
,
field1
;
SELECT
table1
.
`time_key`
field2
FROM
B
table1
LEFT
JOIN
BB
JOIN
A
table5
ON
table5
.
`date_nokey`
ON
table5
.
`int_nokey`
GROUP
BY
field2
;
--
enable_warnings
drop
table
A
,
AA
,
B
,
BB
;
--
echo
#end of test for bug#45266
--
echo
End
of
5.1
tests
sql/sql_base.cc
View file @
05a2329f
...
...
@@ -2963,6 +2963,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
table
->
insert_values
=
0
;
table
->
fulltext_searched
=
0
;
table
->
file
->
ft_handler
=
0
;
table
->
reginfo
.
impossible_range
=
0
;
/* Catch wrong handling of the auto_increment_field_not_null. */
DBUG_ASSERT
(
!
table
->
auto_increment_field_not_null
);
table
->
auto_increment_field_not_null
=
FALSE
;
...
...
sql/sql_select.cc
View file @
05a2329f
...
...
@@ -2432,7 +2432,6 @@ static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select,
if
(
select
)
{
select
->
head
=
table
;
table
->
reginfo
.
impossible_range
=
0
;
if
((
error
=
select
->
test_quick_select
(
thd
,
*
(
key_map
*
)
keys
,(
table_map
)
0
,
limit
,
0
))
==
1
)
DBUG_RETURN
(
select
->
quick
->
records
);
...
...
sql/structs.h
View file @
05a2329f
...
...
@@ -107,6 +107,10 @@ typedef struct st_reginfo { /* Extra info about reg */
struct
st_join_table
*
join_tab
;
/* Used by SELECT() */
enum
thr_lock_type
lock_type
;
/* How database is used */
bool
not_exists_optimize
;
/*
TRUE <=> range optimizer found that there is no rows satisfying
table conditions.
*/
bool
impossible_range
;
}
REGINFO
;
...
...
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