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
7451ffcd
Commit
7451ffcd
authored
Aug 02, 2006
by
evgen@moonbone.local
Browse files
Options
Browse Files
Download
Plain Diff
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-4.1
into moonbone.local:/work/tmp_merge-4.1-opt-mysql
parents
2119067e
cac5ad03
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
326 additions
and
15 deletions
+326
-15
mysql-test/r/func_group.result
mysql-test/r/func_group.result
+2
-0
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+28
-0
mysql-test/r/select.result
mysql-test/r/select.result
+75
-0
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+28
-1
mysql-test/r/subselect2.result
mysql-test/r/subselect2.result
+12
-0
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+15
-0
mysql-test/t/select.test
mysql-test/t/select.test
+45
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+17
-0
mysql-test/t/subselect2.test
mysql-test/t/subselect2.test
+18
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+22
-0
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+2
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+17
-0
sql/item_strfunc.h
sql/item_strfunc.h
+4
-0
sql/item_subselect.cc
sql/item_subselect.cc
+3
-3
sql/item_subselect.h
sql/item_subselect.h
+4
-5
sql/mysql_priv.h
sql/mysql_priv.h
+2
-1
sql/sql_parse.cc
sql/sql_parse.cc
+1
-1
sql/sql_select.cc
sql/sql_select.cc
+31
-4
No files found.
mysql-test/r/func_group.result
View file @
7451ffcd
...
...
@@ -824,6 +824,7 @@ select 1, min(a) from t1m where 1=99;
1 NULL
select 1, min(1) from t1m where a=99;
1 min(1)
1 NULL
select 1, min(1) from t1m where 1=99;
1 min(1)
1 NULL
...
...
@@ -835,6 +836,7 @@ select 1, max(a) from t1m where 1=99;
1 NULL
select 1, max(1) from t1m where a=99;
1 max(1)
1 NULL
select 1, max(1) from t1m where 1=99;
1 max(1)
1 NULL
...
...
mysql-test/r/func_str.result
View file @
7451ffcd
...
...
@@ -1036,4 +1036,32 @@ a c
abc abc abc
xyz xyz xyz
DROP TABLE t1;
CREATE TABLE t1 (s varchar(10));
INSERT INTO t1 VALUES ('yadda'), ('yaddy');
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(s) > 'ab';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
Warnings:
Note 1003 select test.t1.s AS `s` from test.t1 where (trim(test.t1.s) > _latin1'ab')
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
Warnings:
Note 1003 select test.t1.s AS `s` from test.t1 where (trim(both _latin1'y' from test.t1.s) > _latin1'ab')
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
Warnings:
Note 1003 select test.t1.s AS `s` from test.t1 where (trim(leading _latin1'y' from test.t1.s) > _latin1'ab')
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
Warnings:
Note 1003 select test.t1.s AS `s` from test.t1 where (trim(trailing _latin1'y' from test.t1.s) > _latin1'ab')
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
Warnings:
Note 1003 select test.t1.s AS `s` from test.t1 where (trim(both _latin1'y' from test.t1.s) > _latin1'ab')
DROP TABLE t1;
End of 4.1 tests
mysql-test/r/select.result
View file @
7451ffcd
...
...
@@ -2744,3 +2744,78 @@ SELECT i='1e+01',i=1e+01, i in (1e+01), i in ('1e+01') FROM t1;
i='1e+01' i=1e+01 i in (1e+01) i in ('1e+01')
0 1 1 1
DROP TABLE t1;
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (1,1), (2,1), (4,10);
CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b));
INSERT INTO t2 VALUES (1,NULL), (2,10);
ALTER TABLE t1 ENABLE KEYS;
EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index b b 5 NULL 2 Using index
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
a b a b
1 NULL 1 1
1 NULL 2 1
1 NULL 4 10
2 10 4 10
EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index b b 5 NULL 2 Using index
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
a b a b
1 NULL 1 1
1 NULL 2 1
1 NULL 4 10
2 10 4 10
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (key1 float default NULL, UNIQUE KEY key1 (key1));
CREATE TABLE t2 (key2 float default NULL, UNIQUE KEY key2 (key2));
INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941);
INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941);
explain select max(key1) from t1 where key1 <= 0.6158;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select max(key2) from t2 where key2 <= 1.6158;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select min(key1) from t1 where key1 >= 0.3762;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select min(key2) from t2 where key2 >= 1.3762;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select max(key1), min(key2) from t1, t2
where key1 <= 0.6158 and key2 >= 1.3762;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
select max(key1) from t1 where key1 <= 0.6158;
max(key1)
0.61580002307892
select max(key2) from t2 where key2 <= 1.6158;
max(key2)
1.6158000230789
select min(key1) from t1 where key1 >= 0.3762;
min(key1)
0.37619999051094
select min(key2) from t2 where key2 >= 1.3762;
min(key2)
1.3761999607086
select max(key1), min(key2) from t1, t2
where key1 <= 0.6158 and key2 >= 1.3762;
max(key1) min(key2)
0.61580002307892 1.3761999607086
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
max(key1)
0.61580002307892
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
min(key1)
0.37619999051094
DROP TABLE t1,t2;
mysql-test/r/subselect.result
View file @
7451ffcd
...
...
@@ -539,7 +539,7 @@ EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings:
Note 1003 select max(test.t1.numreponse) AS `MAX(numreponse)` from test.t1
where (test.t1.numeropost = _latin1'1')
Note 1003 select max(test.t1.numreponse) AS `MAX(numreponse)` from test.t1
EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 Using index
...
...
@@ -2868,3 +2868,30 @@ select 1 from dual where 1 < any (select 2 from dual);
select 1 from dual where 1 < all (select 2 from dual where 1!=1);
1
1
create table t1 (s1 char);
insert into t1 values (1),(2);
select * from t1 where (s1 < any (select s1 from t1));
s1
1
select * from t1 where not (s1 < any (select s1 from t1));
s1
2
select * from t1 where (s1 < ALL (select s1+1 from t1));
s1
1
select * from t1 where not(s1 < ALL (select s1+1 from t1));
s1
2
select * from t1 where (s1+1 = ANY (select s1 from t1));
s1
1
select * from t1 where NOT(s1+1 = ANY (select s1 from t1));
s1
2
select * from t1 where (s1 = ALL (select s1/s1 from t1));
s1
1
select * from t1 where NOT(s1 = ALL (select s1/s1 from t1));
s1
2
drop table t1;
mysql-test/r/subselect2.result
View file @
7451ffcd
...
...
@@ -130,3 +130,15 @@ id select_type table type possible_keys key key_len ref rows Extra
5 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
6 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 32 func 1 Using index; Using where
drop table t1, t2, t3, t4;
CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (a int(10), PRIMARY KEY (a)) Engine=InnoDB;
INSERT INTO t2 VALUES (1);
CREATE TABLE t3 (a int(10), b int(10), c int(10),
PRIMARY KEY (a)) Engine=InnoDB;
INSERT INTO t3 VALUES (1,2,1);
SELECT t1.* FROM t1 WHERE (SELECT COUNT(*) FROM t3,t2 WHERE t3.c=t2.a
and t2.a='1' AND t1.a=t3.b) > 0;
a
2
DROP TABLE t1,t2,t3;
mysql-test/t/func_str.test
View file @
7451ffcd
...
...
@@ -697,5 +697,20 @@ SELECT a, CONCAT(a,' ',a) AS c FROM t1
INSTR
(
REVERSE
(
CONCAT
(
a
,
' '
,
a
)),
" "
))
=
a
;
DROP
TABLE
t1
;
#
# Bug#17526: WRONG PRINT for TRIM FUNCTION with two arguments
#
CREATE
TABLE
t1
(
s
varchar
(
10
));
INSERT
INTO
t1
VALUES
(
'yadda'
),
(
'yaddy'
);
EXPLAIN
EXTENDED
SELECT
s
FROM
t1
WHERE
TRIM
(
s
)
>
'ab'
;
EXPLAIN
EXTENDED
SELECT
s
FROM
t1
WHERE
TRIM
(
'y'
FROM
s
)
>
'ab'
;
EXPLAIN
EXTENDED
SELECT
s
FROM
t1
WHERE
TRIM
(
LEADING
'y'
FROM
s
)
>
'ab'
;
EXPLAIN
EXTENDED
SELECT
s
FROM
t1
WHERE
TRIM
(
TRAILING
'y'
FROM
s
)
>
'ab'
;
EXPLAIN
EXTENDED
SELECT
s
FROM
t1
WHERE
TRIM
(
BOTH
'y'
FROM
s
)
>
'ab'
;
DROP
TABLE
t1
;
--
echo
End
of
4.1
tests
mysql-test/t/select.test
View file @
7451ffcd
...
...
@@ -2297,4 +2297,49 @@ INSERT INTO t1 VALUES (10);
SELECT
i
=
'1e+01'
,
i
=
1
e
+
01
,
i
in
(
1
e
+
01
),
i
in
(
'1e+01'
)
FROM
t1
;
DROP
TABLE
t1
;
#
# Bug #21019: First result of SELECT COUNT(*) different than consecutive runs
#
CREATE
TABLE
t1
(
a
int
,
b
int
);
INSERT
INTO
t1
VALUES
(
1
,
1
),
(
2
,
1
),
(
4
,
10
);
CREATE
TABLE
t2
(
a
int
PRIMARY
KEY
,
b
int
,
KEY
b
(
b
));
INSERT
INTO
t2
VALUES
(
1
,
NULL
),
(
2
,
10
);
ALTER
TABLE
t1
ENABLE
KEYS
;
EXPLAIN
SELECT
STRAIGHT_JOIN
SQL_NO_CACHE
COUNT
(
*
)
FROM
t2
,
t1
WHERE
t1
.
b
=
t2
.
b
OR
t2
.
b
IS
NULL
;
SELECT
STRAIGHT_JOIN
SQL_NO_CACHE
*
FROM
t2
,
t1
WHERE
t1
.
b
=
t2
.
b
OR
t2
.
b
IS
NULL
;
EXPLAIN
SELECT
STRAIGHT_JOIN
SQL_NO_CACHE
COUNT
(
*
)
FROM
t2
,
t1
WHERE
t1
.
b
=
t2
.
b
OR
t2
.
b
IS
NULL
;
SELECT
STRAIGHT_JOIN
SQL_NO_CACHE
*
FROM
t2
,
t1
WHERE
t1
.
b
=
t2
.
b
OR
t2
.
b
IS
NULL
;
DROP
TABLE
IF
EXISTS
t1
,
t2
;
#
# Bug #20954 "avg(keyval) retuns 0.38 but max(keyval) returns an empty set"
#
--
disable_ps_protocol
CREATE
TABLE
t1
(
key1
float
default
NULL
,
UNIQUE
KEY
key1
(
key1
));
CREATE
TABLE
t2
(
key2
float
default
NULL
,
UNIQUE
KEY
key2
(
key2
));
INSERT
INTO
t1
VALUES
(
0.3762
),(
0.3845
),(
0.6158
),(
0.7941
);
INSERT
INTO
t2
VALUES
(
1.3762
),(
1.3845
),(
1.6158
),(
1.7941
);
explain
select
max
(
key1
)
from
t1
where
key1
<=
0.6158
;
explain
select
max
(
key2
)
from
t2
where
key2
<=
1.6158
;
explain
select
min
(
key1
)
from
t1
where
key1
>=
0.3762
;
explain
select
min
(
key2
)
from
t2
where
key2
>=
1.3762
;
explain
select
max
(
key1
),
min
(
key2
)
from
t1
,
t2
where
key1
<=
0.6158
and
key2
>=
1.3762
;
explain
select
max
(
key1
)
from
t1
where
key1
<=
0.6158
and
rand
()
+
0.5
>=
0.5
;
explain
select
min
(
key1
)
from
t1
where
key1
>=
0.3762
and
rand
()
+
0.5
>=
0.5
;
select
max
(
key1
)
from
t1
where
key1
<=
0.6158
;
select
max
(
key2
)
from
t2
where
key2
<=
1.6158
;
select
min
(
key1
)
from
t1
where
key1
>=
0.3762
;
select
min
(
key2
)
from
t2
where
key2
>=
1.3762
;
select
max
(
key1
),
min
(
key2
)
from
t1
,
t2
where
key1
<=
0.6158
and
key2
>=
1.3762
;
select
max
(
key1
)
from
t1
where
key1
<=
0.6158
and
rand
()
+
0.5
>=
0.5
;
select
min
(
key1
)
from
t1
where
key1
>=
0.3762
and
rand
()
+
0.5
>=
0.5
;
DROP
TABLE
t1
,
t2
;
--
enable_ps_protocol
# End of 4.1 tests
mysql-test/t/subselect.test
View file @
7451ffcd
...
...
@@ -1844,4 +1844,21 @@ select 1 from dual where 2 > any (select 1);
select
1
from
dual
where
2
>
all
(
select
1
);
select
1
from
dual
where
1
<
any
(
select
2
from
dual
);
select
1
from
dual
where
1
<
all
(
select
2
from
dual
where
1
!=
1
);
# BUG#20975 Wrong query results for subqueries within NOT
create
table
t1
(
s1
char
);
insert
into
t1
values
(
1
),(
2
);
select
*
from
t1
where
(
s1
<
any
(
select
s1
from
t1
));
select
*
from
t1
where
not
(
s1
<
any
(
select
s1
from
t1
));
select
*
from
t1
where
(
s1
<
ALL
(
select
s1
+
1
from
t1
));
select
*
from
t1
where
not
(
s1
<
ALL
(
select
s1
+
1
from
t1
));
select
*
from
t1
where
(
s1
+
1
=
ANY
(
select
s1
from
t1
));
select
*
from
t1
where
NOT
(
s1
+
1
=
ANY
(
select
s1
from
t1
));
select
*
from
t1
where
(
s1
=
ALL
(
select
s1
/
s1
from
t1
));
select
*
from
t1
where
NOT
(
s1
=
ALL
(
select
s1
/
s1
from
t1
));
drop
table
t1
;
# End of 4.1 tests
mysql-test/t/subselect2.test
View file @
7451ffcd
...
...
@@ -150,3 +150,21 @@ EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JO
drop
table
t1
,
t2
,
t3
,
t4
;
# End of 4.1 tests
#
# Bug #20792: Incorrect results from aggregate subquery
#
CREATE
TABLE
t1
(
a
int
(
10
)
,
PRIMARY
KEY
(
a
))
Engine
=
InnoDB
;
INSERT
INTO
t1
VALUES
(
1
),(
2
);
CREATE
TABLE
t2
(
a
int
(
10
),
PRIMARY
KEY
(
a
))
Engine
=
InnoDB
;
INSERT
INTO
t2
VALUES
(
1
);
CREATE
TABLE
t3
(
a
int
(
10
),
b
int
(
10
),
c
int
(
10
),
PRIMARY
KEY
(
a
))
Engine
=
InnoDB
;
INSERT
INTO
t3
VALUES
(
1
,
2
,
1
);
SELECT
t1
.*
FROM
t1
WHERE
(
SELECT
COUNT
(
*
)
FROM
t3
,
t2
WHERE
t3
.
c
=
t2
.
a
and
t2
.
a
=
'1'
AND
t1
.
a
=
t3
.
b
)
>
0
;
DROP
TABLE
t1
,
t2
,
t3
;
sql/item_cmpfunc.cc
View file @
7451ffcd
...
...
@@ -3099,6 +3099,28 @@ Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */
}
Item
*
Item_func_nop_all
::
neg_transformer
(
THD
*
thd
)
{
/* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */
Item_func_not_all
*
new_item
=
new
Item_func_not_all
(
args
[
0
]);
Item_allany_subselect
*
allany
=
(
Item_allany_subselect
*
)
args
[
0
];
allany
->
func
=
allany
->
func_creator
(
FALSE
);
allany
->
all
=
!
allany
->
all
;
allany
->
upper_item
=
new_item
;
return
new_item
;
}
Item
*
Item_func_not_all
::
neg_transformer
(
THD
*
thd
)
{
/* "NOT (e $cmp$ ALL (SELECT ...)) -> e $rev_cmp$" ANY (SELECT ...) */
Item_func_nop_all
*
new_item
=
new
Item_func_nop_all
(
args
[
0
]);
Item_allany_subselect
*
allany
=
(
Item_allany_subselect
*
)
args
[
0
];
allany
->
all
=
!
allany
->
all
;
allany
->
func
=
allany
->
func_creator
(
TRUE
);
allany
->
upper_item
=
new_item
;
return
new_item
;
}
Item
*
Item_func_eq
::
negated_item
()
/* a = b -> a != b */
{
return
new
Item_func_ne
(
args
[
0
],
args
[
1
]);
...
...
sql/item_cmpfunc.h
View file @
7451ffcd
...
...
@@ -268,6 +268,7 @@ public:
void
set_sum_test
(
Item_sum_hybrid
*
item
)
{
test_sum_item
=
item
;
};
void
set_sub_test
(
Item_maxmin_subselect
*
item
)
{
test_sub_item
=
item
;
};
bool
empty_underlying_subquery
();
Item
*
neg_transformer
(
THD
*
thd
);
};
...
...
@@ -278,6 +279,7 @@ public:
Item_func_nop_all
(
Item
*
a
)
:
Item_func_not_all
(
a
)
{}
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"<nop>"
;
}
Item
*
neg_transformer
(
THD
*
thd
);
};
...
...
sql/item_strfunc.cc
View file @
7451ffcd
...
...
@@ -1444,6 +1444,23 @@ void Item_func_trim::fix_length_and_dec()
}
}
void
Item_func_trim
::
print
(
String
*
str
)
{
if
(
arg_count
==
1
)
{
Item_func
::
print
(
str
);
return
;
}
str
->
append
(
Item_func_trim
::
func_name
());
str
->
append
(
'('
);
str
->
append
(
mode_name
());
str
->
append
(
' '
);
args
[
1
]
->
print
(
str
);
str
->
append
(
" from "
,
6
);
args
[
0
]
->
print
(
str
);
str
->
append
(
')'
);
}
/* Item_func_password */
...
...
sql/item_strfunc.h
View file @
7451ffcd
...
...
@@ -218,6 +218,8 @@ public:
String
*
val_str
(
String
*
);
void
fix_length_and_dec
();
const
char
*
func_name
()
const
{
return
"trim"
;
}
void
print
(
String
*
str
);
virtual
const
char
*
mode_name
()
const
{
return
"both"
;
}
};
...
...
@@ -228,6 +230,7 @@ public:
Item_func_ltrim
(
Item
*
a
)
:
Item_func_trim
(
a
)
{}
String
*
val_str
(
String
*
);
const
char
*
func_name
()
const
{
return
"ltrim"
;
}
const
char
*
mode_name
()
const
{
return
"leading"
;
}
};
...
...
@@ -238,6 +241,7 @@ public:
Item_func_rtrim
(
Item
*
a
)
:
Item_func_trim
(
a
)
{}
String
*
val_str
(
String
*
);
const
char
*
func_name
()
const
{
return
"rtrim"
;
}
const
char
*
mode_name
()
const
{
return
"trailing"
;
}
};
...
...
sql/item_subselect.cc
View file @
7451ffcd
...
...
@@ -542,14 +542,14 @@ Item_in_subselect::Item_in_subselect(Item * left_exp,
}
Item_allany_subselect
::
Item_allany_subselect
(
Item
*
left_exp
,
Comp_creator
*
fn
,
chooser_compare_func_creator
fc
,
st_select_lex
*
select_lex
,
bool
all_arg
)
:
Item_in_subselect
(),
all
(
all_arg
)
:
Item_in_subselect
(),
all
(
all_arg
)
,
func_creator
(
fc
)
{
DBUG_ENTER
(
"Item_in_subselect::Item_in_subselect"
);
left_expr
=
left_exp
;
func
=
f
n
;
func
=
f
unc_creator
(
all_arg
)
;
init
(
select_lex
,
new
select_exists_subselect
(
this
));
max_columns
=
1
;
abort_on_null
=
0
;
...
...
sql/item_subselect.h
View file @
7451ffcd
...
...
@@ -251,14 +251,13 @@ public:
/* ALL/ANY/SOME subselect */
class
Item_allany_subselect
:
public
Item_in_subselect
{
protected:
Comp_creator
*
func
;
public:
chooser_compare_func_creator
func_creator
;
Comp_creator
*
func
;
bool
all
;
Item_allany_subselect
(
Item
*
left_expr
,
Comp_creator
*
f
,
st_select_lex
*
select_lex
,
bool
all
);
Item_allany_subselect
(
Item
*
left_expr
,
chooser_compare_func_creator
fc
,
st_select_lex
*
select_lex
,
bool
all
);
// only ALL subquery has upper not
subs_type
substype
()
{
return
all
?
ALL_SUBS
:
ANY_SUBS
;
}
...
...
sql/mysql_priv.h
View file @
7451ffcd
...
...
@@ -387,8 +387,9 @@ enum enum_var_type
OPT_DEFAULT
,
OPT_SESSION
,
OPT_GLOBAL
};
class
sys_var
;
#include "item.h"
class
Comp_creator
;
typedef
Comp_creator
*
(
*
chooser_compare_func_creator
)(
bool
invert
);
#include "item.h"
/* sql_parse.cc */
void
free_items
(
Item
*
item
);
void
cleanup_items
(
Item
*
item
);
...
...
sql/sql_parse.cc
View file @
7451ffcd
...
...
@@ -5442,7 +5442,7 @@ Item * all_any_subquery_creator(Item *left_expr,
return
new
Item_func_not
(
new
Item_in_subselect
(
left_expr
,
select_lex
));
Item_allany_subselect
*
it
=
new
Item_allany_subselect
(
left_expr
,
(
*
cmp
)(
all
)
,
select_lex
,
all
);
new
Item_allany_subselect
(
left_expr
,
cmp
,
select_lex
,
all
);
if
(
all
)
return
it
->
upper_item
=
new
Item_func_not_all
(
it
);
/* ALL */
...
...
sql/sql_select.cc
View file @
7451ffcd
...
...
@@ -547,6 +547,24 @@ JOIN::optimize()
}
zero_result_cause
=
"Select tables optimized away"
;
tables_list
=
0
;
// All tables resolved
/*
Extract all table-independent conditions and replace the WHERE
clause with them. All other conditions were computed by opt_sum_query
and the MIN/MAX/COUNT function(s) have been replaced by constants,
so there is no need to compute the whole WHERE clause again.
Notice that make_cond_for_table() will always succeed to remove all
computed conditions, because opt_sum_query() is applicable only to
conjunctions.
*/
if
(
conds
)
{
COND
*
table_independent_conds
=
make_cond_for_table
(
conds
,
PSEUDO_TABLE_BITS
,
0
);
DBUG_EXECUTE
(
"where"
,
print_where
(
table_independent_conds
,
"where after opt_sum_query()"
););
conds
=
table_independent_conds
;
}
}
}
if
(
!
tables_list
)
...
...
@@ -2143,8 +2161,11 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end,
/* field = expression OR field IS NULL */
old
->
level
=
and_level
;
old
->
optimize
=
KEY_OPTIMIZE_REF_OR_NULL
;
/* Remember the NOT NULL value */
if
(
old
->
val
->
is_null
())
/*
Remember the NOT NULL value unless the value does not depend
on other tables.
*/
if
(
!
old
->
val
->
used_tables
()
&&
old
->
val
->
is_null
())
old
->
val
=
new_fields
->
val
;
/* The referred expression can be NULL: */
old
->
null_rejecting
=
0
;
...
...
@@ -4452,10 +4473,16 @@ return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables,
DBUG_RETURN
(
0
);
}
/*
used only in JOIN::clear
*/
static
void
clear_tables
(
JOIN
*
join
)
{
for
(
uint
i
=
0
;
i
<
join
->
tables
;
i
++
)
/*
must clear only the non-const tables, as const tables
are not re-calculated.
*/
for
(
uint
i
=
join
->
const_tables
;
i
<
join
->
tables
;
i
++
)
mark_as_null_row
(
join
->
table
[
i
]);
// All fields are NULL
}
...
...
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