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
0fdb0bdf
Commit
0fdb0bdf
authored
Nov 09, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/10.0' into 10.1
parents
644ffdeb
c2c93fc6
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
190 additions
and
52 deletions
+190
-52
mysql-test/r/func_misc.result
mysql-test/r/func_misc.result
+14
-0
mysql-test/r/subselect_exists2in.result
mysql-test/r/subselect_exists2in.result
+37
-0
mysql-test/t/func_misc.test
mysql-test/t/func_misc.test
+16
-0
mysql-test/t/subselect_exists2in.test
mysql-test/t/subselect_exists2in.test
+40
-0
sql/item.cc
sql/item.cc
+20
-5
sql/item.h
sql/item.h
+8
-6
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+15
-10
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+5
-5
sql/item_func.cc
sql/item_func.cc
+3
-2
sql/item_func.h
sql/item_func.h
+1
-1
sql/item_inetfunc.cc
sql/item_inetfunc.cc
+4
-3
sql/item_inetfunc.h
sql/item_inetfunc.h
+3
-3
sql/item_row.cc
sql/item_row.cc
+3
-2
sql/item_row.h
sql/item_row.h
+1
-1
sql/item_subselect.cc
sql/item_subselect.cc
+9
-6
sql/item_subselect.h
sql/item_subselect.h
+2
-2
sql/opt_subselect.cc
sql/opt_subselect.cc
+5
-4
sql/sql_derived.cc
sql/sql_derived.cc
+4
-2
No files found.
mysql-test/r/func_misc.result
View file @
0fdb0bdf
...
...
@@ -1446,3 +1446,17 @@ SELECT CONCAT(NAME_CONST('name',15),'오');
CONCAT(NAME_CONST('name',15),'오')
15오
SET NAMES latin1;
#
# MDEV-14116 INET6_NTOA output is set as null to varchar(39) variable
#
CREATE PROCEDURE p1()
BEGIN
DECLARE ip_full_addr varchar(39) DEFAULT "";
SELECT INET6_NTOA(UNHEX('20000000000000000000000000000000')) into ip_full_addr;
SELECT ip_full_addr;
END;
$$
CALL p1();
ip_full_addr
2000::
DROP PROCEDURE p1;
mysql-test/r/subselect_exists2in.result
View file @
0fdb0bdf
...
...
@@ -934,5 +934,42 @@ f2
foo
set optimizer_switch= @optimizer_switch_save;
DROP TABLE t1;
#
# MDEV-14164: Unknown column error when adding aggregate to function
# in oracle style procedure FOR loop
#
CREATE TABLE t1(id INT, val INT);
CREATE PROCEDURE p1()
BEGIN
DECLARE cur1 CURSOR FOR SELECT * FROM (
SELECT DISTINCT id FROM t1) a
WHERE NOT EXISTS (SELECT * FROM ( SELECT id FROM t1) b
WHERE a.id=b.id);
OPEN cur1;
CLOSE cur1;
OPEN cur1;
CLOSE cur1;
END;
//
CALL p1();
DROP PROCEDURE p1;
DROP TABLE t1;
CREATE TABLE t1(id INT, val INT);
CREATE PROCEDURE p1()
BEGIN
SELECT * FROM (SELECT DISTINCT id FROM t1) a
WHERE NOT a.id IN (SELECT b.id FROM t1 b);
SELECT * FROM (SELECT DISTINCT id FROM t1) a
WHERE NOT EXISTS (SELECT * FROM t1 b WHERE a.id=b.id);
END;
//
CALL p1();
id
id
CALL p1();
id
id
DROP PROCEDURE p1;
DROP TABLE t1;
# End of 10.0 tests
set optimizer_switch=default;
mysql-test/t/func_misc.test
View file @
0fdb0bdf
...
...
@@ -1118,3 +1118,19 @@ SELECT COERCIBILITY(NAME_CONST('name',TIME'00:00:00'));
SELECT
COERCIBILITY
(
NAME_CONST
(
'name'
,
15
));
SELECT
CONCAT
(
NAME_CONST
(
'name'
,
15
),
'오'
);
SET
NAMES
latin1
;
--
echo
#
--
echo
# MDEV-14116 INET6_NTOA output is set as null to varchar(39) variable
--
echo
#
DELIMITER
$$
;
CREATE
PROCEDURE
p1
()
BEGIN
DECLARE
ip_full_addr
varchar
(
39
)
DEFAULT
""
;
SELECT
INET6_NTOA
(
UNHEX
(
'20000000000000000000000000000000'
))
into
ip_full_addr
;
SELECT
ip_full_addr
;
END
;
$$
DELIMITER
;
$$
CALL
p1
();
DROP
PROCEDURE
p1
;
mysql-test/t/subselect_exists2in.test
View file @
0fdb0bdf
...
...
@@ -786,6 +786,46 @@ set optimizer_switch= @optimizer_switch_save;
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-14164: Unknown column error when adding aggregate to function
--
echo
# in oracle style procedure FOR loop
--
echo
#
CREATE
TABLE
t1
(
id
INT
,
val
INT
);
DELIMITER
//;
CREATE
PROCEDURE
p1
()
BEGIN
DECLARE
cur1
CURSOR
FOR
SELECT
*
FROM
(
SELECT
DISTINCT
id
FROM
t1
)
a
WHERE
NOT
EXISTS
(
SELECT
*
FROM
(
SELECT
id
FROM
t1
)
b
WHERE
a
.
id
=
b
.
id
);
OPEN
cur1
;
CLOSE
cur1
;
OPEN
cur1
;
CLOSE
cur1
;
END
;
//
DELIMITER
;
//
CALL
p1
();
DROP
PROCEDURE
p1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
id
INT
,
val
INT
);
DELIMITER
//;
CREATE
PROCEDURE
p1
()
BEGIN
SELECT
*
FROM
(
SELECT
DISTINCT
id
FROM
t1
)
a
WHERE
NOT
a
.
id
IN
(
SELECT
b
.
id
FROM
t1
b
);
SELECT
*
FROM
(
SELECT
DISTINCT
id
FROM
t1
)
a
WHERE
NOT
EXISTS
(
SELECT
*
FROM
t1
b
WHERE
a
.
id
=
b
.
id
);
END
;
//
DELIMITER
;
//
CALL
p1
();
CALL
p1
();
DROP
PROCEDURE
p1
;
DROP
TABLE
t1
;
--
echo
# End of 10.0 tests
#restore defaults
...
...
sql/item.cc
View file @
0fdb0bdf
...
...
@@ -2681,7 +2681,8 @@ table_map Item_field::all_used_tables() const
return
(
get_depended_from
()
?
OUTER_REF_TABLE_BIT
:
field
->
table
->
map
);
}
void
Item_field
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
)
void
Item_field
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
)
{
if
(
new_parent
==
get_depended_from
())
depended_from
=
NULL
;
...
...
@@ -2725,6 +2726,19 @@ void Item_field::fix_after_pullout(st_select_lex *new_parent, Item **ref)
if
(
!
need_change
)
return
;
if
(
!
merge
)
{
/*
It is transformation without merge.
This field was "outer" for the inner SELECT where it was taken and
moved up.
"Outer" fields uses normal SELECT_LEX context of upper SELECTs for
name resolution, so we can switch everything to it safely.
*/
this
->
context
=
&
new_parent
->
context
;
return
;
}
Name_resolution_context
*
ctx
=
new
Name_resolution_context
();
if
(
context
->
select_lex
==
new_parent
)
{
...
...
@@ -8061,18 +8075,19 @@ bool Item_outer_ref::fix_fields(THD *thd, Item **reference)
void
Item_outer_ref
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref_arg
)
Item
**
ref_arg
,
bool
merge
)
{
if
(
get_depended_from
()
==
new_parent
)
{
*
ref_arg
=
outer_ref
;
(
*
ref_arg
)
->
fix_after_pullout
(
new_parent
,
ref_arg
);
(
*
ref_arg
)
->
fix_after_pullout
(
new_parent
,
ref_arg
,
merge
);
}
}
void
Item_ref
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
refptr
)
void
Item_ref
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
refptr
,
bool
merge
)
{
(
*
ref
)
->
fix_after_pullout
(
new_parent
,
ref
);
(
*
ref
)
->
fix_after_pullout
(
new_parent
,
ref
,
merge
);
if
(
get_depended_from
()
==
new_parent
)
depended_from
=
NULL
;
}
...
...
sql/item.h
View file @
0fdb0bdf
...
...
@@ -729,7 +729,9 @@ class Item: public Value_source,
Fix after some tables has been pulled out. Basically re-calculate all
attributes that are dependent on the tables.
*/
virtual
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
)
{};
virtual
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
)
{};
/*
This method should be used in case where we are sure that we do not need
...
...
@@ -2384,7 +2386,7 @@ class Item_field :public Item_ident
bool
send
(
Protocol
*
protocol
,
String
*
str_arg
);
void
reset_field
(
Field
*
f
);
bool
fix_fields
(
THD
*
,
Item
**
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
void
make_field
(
Send_field
*
tmp_field
);
int
save_in_field
(
Field
*
field
,
bool
no_conversions
);
void
save_org_in_field
(
Field
*
field
,
fast_field_copier
optimizer_data
);
...
...
@@ -3905,7 +3907,7 @@ class Item_ref :public Item_ident
bool
send
(
Protocol
*
prot
,
String
*
tmp
);
void
make_field
(
Send_field
*
field
);
bool
fix_fields
(
THD
*
,
Item
**
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
int
save_in_field
(
Field
*
field
,
bool
no_conversions
);
void
save_org_in_field
(
Field
*
field
,
fast_field_copier
optimizer_data
);
fast_field_copier
setup_fast_field_copier
(
Field
*
field
)
...
...
@@ -4175,9 +4177,9 @@ class Item_cache_wrapper :public Item_result_field
Item
*
it
=
((
Item
*
)
item
)
->
real_item
();
return
orig_item
->
eq
(
it
,
binary_cmp
);
}
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
refptr
)
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
refptr
,
bool
merge
)
{
orig_item
->
fix_after_pullout
(
new_parent
,
&
orig_item
);
orig_item
->
fix_after_pullout
(
new_parent
,
&
orig_item
,
merge
);
}
int
save_in_field
(
Field
*
to
,
bool
no_conversions
);
enum
Item_result
result_type
()
const
{
return
orig_item
->
result_type
();
}
...
...
@@ -4435,7 +4437,7 @@ class Item_outer_ref :public Item_direct_ref
outer_ref
->
save_org_in_field
(
result_field
,
NULL
);
}
bool
fix_fields
(
THD
*
,
Item
**
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
table_map
used_tables
()
const
{
return
(
*
ref
)
->
const_item
()
?
0
:
OUTER_REF_TABLE_BIT
;
...
...
sql/item_cmpfunc.cc
View file @
0fdb0bdf
...
...
@@ -1229,10 +1229,11 @@ bool Item_in_optimizer::is_top_level_item()
}
void
Item_in_optimizer
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
)
void
Item_in_optimizer
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
)
{
/* This will re-calculate attributes of our Item_in_subselect: */
Item_bool_func
::
fix_after_pullout
(
new_parent
,
ref
);
Item_bool_func
::
fix_after_pullout
(
new_parent
,
ref
,
merge
);
/* Then, re-calculate not_null_tables_cache: */
eval_not_null_tables
(
NULL
);
...
...
@@ -2060,10 +2061,11 @@ bool Item_func_between::count_sargable_conds(uchar *arg)
}
void
Item_func_between
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
)
void
Item_func_between
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
)
{
/* This will re-calculate attributes of the arguments */
Item_func_opt_neg
::
fix_after_pullout
(
new_parent
,
ref
);
Item_func_opt_neg
::
fix_after_pullout
(
new_parent
,
ref
,
merge
);
/* Then, re-calculate not_null_tables_cache according to our special rules */
eval_not_null_tables
(
NULL
);
}
...
...
@@ -2406,10 +2408,11 @@ Item_func_if::eval_not_null_tables(uchar *opt_arg)
}
void
Item_func_if
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
)
void
Item_func_if
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
)
{
/* This will re-calculate attributes of the arguments */
Item_func
::
fix_after_pullout
(
new_parent
,
ref
);
Item_func
::
fix_after_pullout
(
new_parent
,
ref
,
merge
);
/* Then, re-calculate not_null_tables_cache according to our special rules */
eval_not_null_tables
(
NULL
);
}
...
...
@@ -4138,10 +4141,11 @@ Item_func_in::eval_not_null_tables(uchar *opt_arg)
}
void
Item_func_in
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
)
void
Item_func_in
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
)
{
/* This will re-calculate attributes of the arguments */
Item_func_opt_neg
::
fix_after_pullout
(
new_parent
,
ref
);
Item_func_opt_neg
::
fix_after_pullout
(
new_parent
,
ref
,
merge
);
/* Then, re-calculate not_null_tables_cache according to our special rules */
eval_not_null_tables
(
NULL
);
}
...
...
@@ -4663,7 +4667,8 @@ Item_cond::eval_not_null_tables(uchar *opt_arg)
}
void
Item_cond
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
)
void
Item_cond
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
)
{
List_iterator
<
Item
>
li
(
list
);
Item
*
item
;
...
...
@@ -4676,7 +4681,7 @@ void Item_cond::fix_after_pullout(st_select_lex *new_parent, Item **ref)
while
((
item
=
li
++
))
{
table_map
tmp_table_map
;
item
->
fix_after_pullout
(
new_parent
,
li
.
ref
());
item
->
fix_after_pullout
(
new_parent
,
li
.
ref
()
,
merge
);
item
=
*
li
.
ref
();
used_tables_and_const_cache_join
(
item
);
...
...
sql/item_cmpfunc.h
View file @
0fdb0bdf
...
...
@@ -342,7 +342,7 @@ class Item_in_optimizer: public Item_bool_func
virtual
void
get_cache_parameters
(
List
<
Item
>
&
parameters
);
bool
is_top_level_item
();
bool
eval_not_null_tables
(
uchar
*
opt_arg
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
bool
invisible_mode
();
void
reset_cache
()
{
cache
=
NULL
;
}
};
...
...
@@ -824,7 +824,7 @@ class Item_func_between :public Item_func_opt_neg
void
fix_length_and_dec
();
virtual
void
print
(
String
*
str
,
enum_query_type
query_type
);
bool
eval_not_null_tables
(
uchar
*
opt_arg
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
bool
count_sargable_conds
(
uchar
*
arg
);
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
...
...
@@ -980,7 +980,7 @@ class Item_func_if :public Item_func_case_abbreviation2
}
const
char
*
func_name
()
const
{
return
"if"
;
}
bool
eval_not_null_tables
(
uchar
*
opt_arg
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
private:
void
cache_type_info
(
Item
*
source
);
};
...
...
@@ -1595,7 +1595,7 @@ class Item_func_in :public Item_func_opt_neg
enum
Functype
functype
()
const
{
return
IN_FUNC
;
}
const
char
*
func_name
()
const
{
return
" IN "
;
}
bool
eval_not_null_tables
(
uchar
*
opt_arg
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
bool
count_sargable_conds
(
uchar
*
arg
);
};
...
...
@@ -2063,7 +2063,7 @@ class Item_cond :public Item_bool_func
list
.
append
(
nlist
);
}
bool
fix_fields
(
THD
*
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
enum
Type
type
()
const
{
return
COND_ITEM
;
}
List
<
Item
>*
argument_list
()
{
return
&
list
;
}
...
...
sql/item_func.cc
View file @
0fdb0bdf
...
...
@@ -270,7 +270,8 @@ Item_func::eval_not_null_tables(uchar *opt_arg)
}
void
Item_func
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
)
void
Item_func
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
)
{
Item
**
arg
,
**
arg_end
;
...
...
@@ -281,7 +282,7 @@ void Item_func::fix_after_pullout(st_select_lex *new_parent, Item **ref)
{
for
(
arg
=
args
,
arg_end
=
args
+
arg_count
;
arg
!=
arg_end
;
arg
++
)
{
(
*
arg
)
->
fix_after_pullout
(
new_parent
,
arg
);
(
*
arg
)
->
fix_after_pullout
(
new_parent
,
arg
,
merge
);
Item
*
item
=
*
arg
;
used_tables_and_const_cache_join
(
item
);
...
...
sql/item_func.h
View file @
0fdb0bdf
...
...
@@ -126,7 +126,7 @@ class Item_func :public Item_func_or_sum
Item_func_or_sum
::
cleanup
();
used_tables_and_const_cache_init
();
}
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
void
quick_fix_field
();
table_map
not_null_tables
()
const
;
void
update_used_tables
()
...
...
sql/item_inetfunc.cc
View file @
0fdb0bdf
...
...
@@ -181,7 +181,8 @@ String *Item_func_inet_str_base::val_str_ascii(String *buffer)
return
NULL
;
}
String
*
arg_str
=
args
[
0
]
->
val_str
(
buffer
);
StringBuffer
<
STRING_BUFFER_USUAL_SIZE
>
tmp
;
String
*
arg_str
=
args
[
0
]
->
val_str
(
&
tmp
);
if
(
!
arg_str
)
// Out-of memory happened. The error has been reported.
{
// Or: the underlying field is NULL
null_value
=
true
;
...
...
@@ -679,7 +680,7 @@ static void ipv6_to_str(const in6_addr *ipv6, char *str)
@retval true The string has been converted sucessfully.
*/
bool
Item_func_inet6_aton
::
calc_value
(
String
*
arg
,
String
*
buffer
)
bool
Item_func_inet6_aton
::
calc_value
(
const
String
*
arg
,
String
*
buffer
)
{
// ipv4-string -> varbinary(4)
// ipv6-string -> varbinary(16)
...
...
@@ -719,7 +720,7 @@ bool Item_func_inet6_aton::calc_value(String *arg, String *buffer)
@retval true The string has been converted sucessfully.
*/
bool
Item_func_inet6_ntoa
::
calc_value
(
String
*
arg
,
String
*
buffer
)
bool
Item_func_inet6_ntoa
::
calc_value
(
const
String
*
arg
,
String
*
buffer
)
{
if
(
arg
->
charset
()
!=
&
my_charset_bin
)
return
false
;
...
...
sql/item_inetfunc.h
View file @
0fdb0bdf
...
...
@@ -98,7 +98,7 @@ class Item_func_inet_str_base : public Item_str_ascii_func
virtual
String
*
val_str_ascii
(
String
*
buffer
);
protected:
virtual
bool
calc_value
(
String
*
arg
,
String
*
buffer
)
=
0
;
virtual
bool
calc_value
(
const
String
*
arg
,
String
*
buffer
)
=
0
;
};
...
...
@@ -125,7 +125,7 @@ class Item_func_inet6_aton : public Item_func_inet_str_base
}
protected:
virtual
bool
calc_value
(
String
*
arg
,
String
*
buffer
);
virtual
bool
calc_value
(
const
String
*
arg
,
String
*
buffer
);
};
...
...
@@ -157,7 +157,7 @@ class Item_func_inet6_ntoa : public Item_func_inet_str_base
}
protected:
virtual
bool
calc_value
(
String
*
arg
,
String
*
buffer
);
virtual
bool
calc_value
(
const
String
*
arg
,
String
*
buffer
);
};
...
...
sql/item_row.cc
View file @
0fdb0bdf
...
...
@@ -109,13 +109,14 @@ void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array,
}
void
Item_row
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
)
void
Item_row
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
)
{
used_tables_and_const_cache_init
();
not_null_tables_cache
=
0
;
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
{
args
[
i
]
->
fix_after_pullout
(
new_parent
,
&
args
[
i
]);
args
[
i
]
->
fix_after_pullout
(
new_parent
,
&
args
[
i
]
,
merge
);
used_tables_and_const_cache_join
(
args
[
i
]);
not_null_tables_cache
|=
args
[
i
]
->
not_null_tables
();
}
...
...
sql/item_row.h
View file @
0fdb0bdf
...
...
@@ -80,7 +80,7 @@ class Item_row: public Item,
return
0
;
};
bool
fix_fields
(
THD
*
thd
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
void
cleanup
();
void
split_sum_func
(
THD
*
thd
,
Item
**
ref_pointer_array
,
List
<
Item
>
&
fields
,
uint
flags
);
...
...
sql/item_subselect.cc
View file @
0fdb0bdf
...
...
@@ -447,7 +447,8 @@ bool Item_subselect::mark_as_dependent(THD *thd, st_select_lex *select,
OUTER_REF_TABLE_BIT.
*/
void
Item_subselect
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
)
void
Item_subselect
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
)
{
recalc_used_tables
(
new_parent
,
TRUE
);
parent_select
=
new_parent
;
...
...
@@ -1153,7 +1154,8 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
/*
as far as we moved content to upper level we have to fix dependences & Co
*/
substitution
->
fix_after_pullout
(
select_lex
->
outer_select
(),
&
substitution
);
substitution
->
fix_after_pullout
(
select_lex
->
outer_select
(),
&
substitution
,
TRUE
);
}
DBUG_RETURN
(
false
);
}
...
...
@@ -2934,7 +2936,7 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg)
goto
out
;
}
}
outer_exp
->
fix_after_pullout
(
unit
->
outer_select
(),
&
outer_exp
);
outer_exp
->
fix_after_pullout
(
unit
->
outer_select
(),
&
outer_exp
,
FALSE
);
outer_exp
->
update_used_tables
();
outer
.
push_back
(
outer_exp
,
thd
->
mem_root
);
}
...
...
@@ -3315,10 +3317,11 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
}
void
Item_in_subselect
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
)
void
Item_in_subselect
::
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
)
{
left_expr
->
fix_after_pullout
(
new_parent
,
&
left_expr
);
Item_subselect
::
fix_after_pullout
(
new_parent
,
ref
);
left_expr
->
fix_after_pullout
(
new_parent
,
&
left_expr
,
merge
);
Item_subselect
::
fix_after_pullout
(
new_parent
,
ref
,
merge
);
used_tables_cache
|=
left_expr
->
used_tables
();
}
...
...
sql/item_subselect.h
View file @
0fdb0bdf
...
...
@@ -169,7 +169,7 @@ class Item_subselect :public Item_result_field,
}
bool
fix_fields
(
THD
*
thd
,
Item
**
ref
);
bool
mark_as_dependent
(
THD
*
thd
,
st_select_lex
*
select
,
Item
*
item
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
void
recalc_used_tables
(
st_select_lex
*
new_parent
,
bool
after_pullout
);
virtual
bool
exec
();
/*
...
...
@@ -607,7 +607,7 @@ class Item_in_subselect :public Item_exists_subselect
virtual
void
print
(
String
*
str
,
enum_query_type
query_type
);
bool
fix_fields
(
THD
*
thd
,
Item
**
ref
);
void
fix_length_and_dec
();
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
,
bool
merge
);
bool
const_item
()
const
{
return
Item_subselect
::
const_item
()
&&
left_expr
->
const_item
();
...
...
sql/opt_subselect.cc
View file @
0fdb0bdf
...
...
@@ -1665,7 +1665,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
{
tl
->
jtbm_table_no
=
table_no
;
Item
*
dummy
=
tl
->
jtbm_subselect
;
tl
->
jtbm_subselect
->
fix_after_pullout
(
parent_lex
,
&
dummy
);
tl
->
jtbm_subselect
->
fix_after_pullout
(
parent_lex
,
&
dummy
,
true
);
DBUG_ASSERT
(
dummy
==
tl
->
jtbm_subselect
);
}
SELECT_LEX
*
old_sl
=
tl
->
select_lex
;
...
...
@@ -1806,7 +1806,8 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
Walk through sj nest's WHERE and ON expressions and call
item->fix_table_changes() for all items.
*/
sj_nest
->
sj_on_expr
->
fix_after_pullout
(
parent_lex
,
&
sj_nest
->
sj_on_expr
);
sj_nest
->
sj_on_expr
->
fix_after_pullout
(
parent_lex
,
&
sj_nest
->
sj_on_expr
,
TRUE
);
fix_list_after_tbl_changes
(
parent_lex
,
&
sj_nest
->
nested_join
->
join_list
);
...
...
@@ -1965,7 +1966,7 @@ static bool convert_subq_to_jtbm(JOIN *parent_join,
DBUG_ASSERT
(
parent_join
->
table_count
<
MAX_TABLES
);
Item
*
conds
=
hash_sj_engine
->
semi_join_conds
;
conds
->
fix_after_pullout
(
parent_lex
,
&
conds
);
conds
->
fix_after_pullout
(
parent_lex
,
&
conds
,
TRUE
);
DBUG_EXECUTE
(
"where"
,
print_where
(
conds
,
"SJ-EXPR"
,
QT_ORDINARY
););
...
...
@@ -2017,7 +2018,7 @@ void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TABLE_LIST> *tlist)
while
((
table
=
it
++
))
{
if
(
table
->
on_expr
)
table
->
on_expr
->
fix_after_pullout
(
new_parent
,
&
table
->
on_expr
);
table
->
on_expr
->
fix_after_pullout
(
new_parent
,
&
table
->
on_expr
,
TRUE
);
if
(
table
->
nested_join
)
fix_list_after_tbl_changes
(
new_parent
,
&
table
->
nested_join
->
join_list
);
}
...
...
sql/sql_derived.cc
View file @
0fdb0bdf
...
...
@@ -466,7 +466,8 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
// Update used tables cache according to new table map
if
(
derived
->
on_expr
)
{
derived
->
on_expr
->
fix_after_pullout
(
parent_lex
,
&
derived
->
on_expr
);
derived
->
on_expr
->
fix_after_pullout
(
parent_lex
,
&
derived
->
on_expr
,
TRUE
);
fix_list_after_tbl_changes
(
parent_lex
,
&
derived
->
nested_join
->
join_list
);
}
}
...
...
@@ -636,7 +637,8 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
SELECT_LEX_UNIT
*
unit
=
derived
->
get_unit
();
DBUG_ENTER
(
"mysql_derived_prepare"
);
bool
res
=
FALSE
;
DBUG_PRINT
(
"enter"
,
(
"unit 0x%lx"
,
(
ulong
)
unit
));
DBUG_PRINT
(
"enter"
,
(
"unit: %p table_list: %p Alias '%s'"
,
unit
,
derived
,
derived
->
alias
));
// Skip already prepared views/DT
if
(
!
unit
||
unit
->
prepared
||
...
...
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