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
8f5429be
Commit
8f5429be
authored
Dec 15, 2006
by
evgen@moonbone.local
Browse files
Options
Browse Files
Download
Plain Diff
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into moonbone.local:/home/evgen/bk-trees/mysql-5.0-opt
parents
7820d1b9
026196c4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
4 deletions
+77
-4
mysql-test/r/ps.result
mysql-test/r/ps.result
+15
-0
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+13
-0
mysql-test/t/ps.test
mysql-test/t/ps.test
+18
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+12
-0
sql/item_subselect.cc
sql/item_subselect.cc
+17
-2
sql/item_subselect.h
sql/item_subselect.h
+2
-1
sql/sql_lex.cc
sql/sql_lex.cc
+0
-1
No files found.
mysql-test/r/ps.result
View file @
8f5429be
...
...
@@ -1514,4 +1514,19 @@ Variable_name Value
Slow_queries 1
deallocate prepare no_index;
deallocate prepare sq;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1), (2);
CREATE TABLE t2 (b int);
INSERT INTO t2 VALUES (NULL);
SELECT a FROM t1 WHERE (SELECT b FROM t2) IS NULL;
a
1
2
PREPARE stmt FROM 'SELECT a FROM t1 WHERE (SELECT b FROM t2) IS NULL';
EXECUTE stmt;
a
1
2
DEALLOCATE PREPARE stmt;
DROP TABLE t1,t2;
End of 5.0 tests.
mysql-test/r/subselect.result
View file @
8f5429be
...
...
@@ -3033,6 +3033,19 @@ t3 CREATE TABLE `t3` (
`a` datetime default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1,t2,t3;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1), (2);
SELECT a FROM t1 WHERE (SELECT 1 FROM DUAL WHERE 1=0) > 0;
a
SELECT a FROM t1 WHERE (SELECT 1 FROM DUAL WHERE 1=0) IS NULL;
a
1
2
EXPLAIN SELECT a FROM t1 WHERE (SELECT 1 FROM DUAL WHERE 1=0) IS NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
DROP TABLE t1;
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
...
...
mysql-test/t/ps.test
View file @
8f5429be
...
...
@@ -1563,4 +1563,22 @@ execute sq;
deallocate
prepare
no_index
;
deallocate
prepare
sq
;
#
# Bug 25027: query with a single-row non-correlated subquery
# and IS NULL predicate
#
CREATE
TABLE
t1
(
a
int
);
INSERT
INTO
t1
VALUES
(
1
),
(
2
);
CREATE
TABLE
t2
(
b
int
);
INSERT
INTO
t2
VALUES
(
NULL
);
SELECT
a
FROM
t1
WHERE
(
SELECT
b
FROM
t2
)
IS
NULL
;
PREPARE
stmt
FROM
'SELECT a FROM t1 WHERE (SELECT b FROM t2) IS NULL'
;
EXECUTE
stmt
;
DEALLOCATE
PREPARE
stmt
;
DROP
TABLE
t1
,
t2
;
--
echo
End
of
5.0
tests
.
mysql-test/t/subselect.test
View file @
8f5429be
...
...
@@ -1988,6 +1988,18 @@ SHOW CREATE TABLE t3;
DROP
TABLE
t1
,
t2
,
t3
;
#
# Bug 24670: subquery witout tables but with a WHERE clause
#
CREATE
TABLE
t1
(
a
int
);
INSERT
INTO
t1
VALUES
(
1
),
(
2
);
SELECT
a
FROM
t1
WHERE
(
SELECT
1
FROM
DUAL
WHERE
1
=
0
)
>
0
;
SELECT
a
FROM
t1
WHERE
(
SELECT
1
FROM
DUAL
WHERE
1
=
0
)
IS
NULL
;
EXPLAIN
SELECT
a
FROM
t1
WHERE
(
SELECT
1
FROM
DUAL
WHERE
1
=
0
)
IS
NULL
;
DROP
TABLE
t1
;
# End of 4.1 tests
#
...
...
sql/item_subselect.cc
View file @
8f5429be
...
...
@@ -349,6 +349,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
*/
!
(
select_lex
->
item_list
.
head
()
->
type
()
==
FIELD_ITEM
||
select_lex
->
item_list
.
head
()
->
type
()
==
REF_ITEM
)
&&
!
join
->
conds
&&
!
join
->
having
&&
/*
switch off this optimization for prepare statement,
because we do not rollback this changes
...
...
@@ -373,8 +374,6 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
*/
substitution
->
walk
(
&
Item
::
remove_dependence_processor
,
(
byte
*
)
select_lex
->
outer_select
());
/* SELECT without FROM clause can't have WHERE or HAVING clause */
DBUG_ASSERT
(
join
->
conds
==
0
&&
join
->
having
==
0
);
return
RES_REDUCE
;
}
return
RES_OK
;
...
...
@@ -2277,6 +2276,22 @@ bool subselect_single_select_engine::no_tables()
}
/*
Check statically whether the subquery can return NULL
SINOPSYS
subselect_single_select_engine::may_be_null()
RETURN
FALSE can guarantee that the subquery never return NULL
TRUE otherwise
*/
bool
subselect_single_select_engine
::
may_be_null
()
{
return
((
no_tables
()
&&
!
join
->
conds
&&
!
join
->
having
)
?
maybe_null
:
1
);
}
/*
Report about presence of tables in subquery
...
...
sql/item_subselect.h
View file @
8f5429be
...
...
@@ -363,7 +363,7 @@ public:
enum
Item_result
type
()
{
return
res_type
;
}
enum_field_types
field_type
()
{
return
res_field_type
;
}
virtual
void
exclude
()
=
0
;
bool
may_be_null
()
{
return
maybe_null
;
};
virtual
bool
may_be_null
()
{
return
maybe_null
;
};
virtual
table_map
upper_select_const_tables
()
=
0
;
static
table_map
calc_const_tables
(
TABLE_LIST
*
);
virtual
void
print
(
String
*
str
)
=
0
;
...
...
@@ -400,6 +400,7 @@ public:
void
print
(
String
*
str
);
bool
change_result
(
Item_subselect
*
si
,
select_subselect
*
result
);
bool
no_tables
();
bool
may_be_null
();
bool
is_executed
()
const
{
return
executed
;
}
bool
no_rows
();
};
...
...
sql/sql_lex.cc
View file @
8f5429be
...
...
@@ -1903,7 +1903,6 @@ void st_select_lex_unit::set_limit(SELECT_LEX *sl)
{
ha_rows
select_limit_val
;
DBUG_ASSERT
(
!
thd
->
stmt_arena
->
is_stmt_prepare
());
select_limit_val
=
(
ha_rows
)(
sl
->
select_limit
?
sl
->
select_limit
->
val_uint
()
:
HA_POS_ERROR
);
offset_limit_cnt
=
(
ha_rows
)(
sl
->
offset_limit
?
sl
->
offset_limit
->
val_uint
()
:
...
...
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