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
99b3beae
Commit
99b3beae
authored
Nov 25, 2010
by
Michael Widenius
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge with 5.1
parents
d1b731d0
61359576
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
4 deletions
+95
-4
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+19
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+24
-0
sql/sql_class.cc
sql/sql_class.cc
+30
-0
sql/sql_class.h
sql/sql_class.h
+19
-1
sql/sql_lex.cc
sql/sql_lex.cc
+3
-3
No files found.
mysql-test/r/subselect.result
View file @
99b3beae
...
...
@@ -4730,4 +4730,23 @@ ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE));
SELECT * FROM t2 UNION SELECT * FROM t2
ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE));
DROP TABLE t1,t2;
# LP BUG#675248 - select->prep_where references on freed memory
CREATE TABLE t1 (a int, b int);
insert into t1 values (1,1),(0,0);
CREATE TABLE t2 (c int);
insert into t2 values (1),(2);
prepare stmt1 from "select sum(a),(select sum(c) from t2 where table1.b) as sub
from t1 as table1 group by sub";
execute stmt1;
sum(a) sub
0 NULL
1 3
deallocate prepare stmt1;
prepare stmt1 from "select sum(a),(select sum(c) from t2 having table1.b) as sub
from t1 as table1";
execute stmt1;
sum(a) sub
1 3
deallocate prepare stmt1;
drop table t1,t2;
End of 5.1 tests
mysql-test/t/subselect.test
View file @
99b3beae
...
...
@@ -3735,4 +3735,28 @@ SELECT * FROM t2 UNION SELECT * FROM t2
DROP
TABLE
t1
,
t2
;
--
enable_result_log
--
echo
# LP BUG#675248 - select->prep_where references on freed memory
CREATE
TABLE
t1
(
a
int
,
b
int
);
insert
into
t1
values
(
1
,
1
),(
0
,
0
);
CREATE
TABLE
t2
(
c
int
);
insert
into
t2
values
(
1
),(
2
);
prepare
stmt1
from
"select sum(a),(select sum(c) from t2 where table1.b) as sub
from t1 as table1 group by sub"
;
execute
stmt1
;
deallocate
prepare
stmt1
;
prepare
stmt1
from
"select sum(a),(select sum(c) from t2 having table1.b) as sub
from t1 as table1"
;
execute
stmt1
;
deallocate
prepare
stmt1
;
drop
table
t1
,
t2
;
--
echo
End
of
5.1
tests
sql/sql_class.cc
View file @
99b3beae
...
...
@@ -1623,6 +1623,36 @@ void THD::nocheck_register_item_tree_change(Item **place, Item *old_value,
change_list
.
append
(
change
);
}
/**
Check and register item change if needed
@param place place where we should assign new value
@param new_value place of the new value
@details
Let C be a reference to an item that changed the reference A
at the location (occurrence) L1 and this change has been registered.
If C is substituted for reference A another location (occurrence) L2
that is to be registered as well than this change has to be
consistent with the first change in order the procedure that rollback
changes to substitute the same reference at both locations L1 and L2.
*/
void
THD
::
check_and_register_item_tree_change
(
Item
**
place
,
Item
**
new_value
,
MEM_ROOT
*
runtime_memroot
)
{
Item_change_record
*
change
;
I_List_iterator
<
Item_change_record
>
it
(
change_list
);
while
((
change
=
it
++
))
{
if
(
change
->
place
==
new_value
)
break
;
// we need only very first value
}
if
(
change
)
nocheck_register_item_tree_change
(
place
,
change
->
old_value
,
runtime_memroot
);
}
void
THD
::
rollback_item_tree_changes
()
{
...
...
sql/sql_class.h
View file @
99b3beae
...
...
@@ -1568,7 +1568,7 @@ class THD :public Statement,
/*
This is to track items changed during execution of a prepared
statement/stored procedure. It's created by
register_item_tree_change() in memory root of THD, and freed in
nocheck_
register_item_tree_change() in memory root of THD, and freed in
rollback_item_tree_changes(). For conventional execution it's always
empty.
*/
...
...
@@ -2175,8 +2175,26 @@ class THD :public Statement,
nocheck_register_item_tree_change
(
place
,
*
place
,
mem_root
);
*
place
=
new_value
;
}
/**
Make change in item tree after checking whether it needs registering
@param place place where we should assign new value
@param new_value place of the new value
@details
see check_and_register_item_tree_change details
*/
void
check_and_register_item_tree
(
Item
**
place
,
Item
**
new_value
)
{
if
(
!
stmt_arena
->
is_conventional
())
check_and_register_item_tree_change
(
place
,
new_value
,
mem_root
);
*
place
=
*
new_value
;
}
void
nocheck_register_item_tree_change
(
Item
**
place
,
Item
*
old_value
,
MEM_ROOT
*
runtime_memroot
);
void
check_and_register_item_tree_change
(
Item
**
place
,
Item
**
new_value
,
MEM_ROOT
*
runtime_memroot
);
void
rollback_item_tree_changes
();
/*
...
...
sql/sql_lex.cc
View file @
99b3beae
...
...
@@ -2890,7 +2890,7 @@ static void fix_prepare_info_in_table_list(THD *thd, TABLE_LIST *tbl)
{
if
(
tbl
->
on_expr
)
{
t
bl
->
prep_on_expr
=
tbl
->
on_expr
;
t
hd
->
check_and_register_item_tree
(
&
tbl
->
prep_on_expr
,
&
tbl
->
on_expr
)
;
tbl
->
on_expr
=
tbl
->
on_expr
->
copy_andor_structure
(
thd
);
}
fix_prepare_info_in_table_list
(
thd
,
tbl
->
merge_underlying_list
);
...
...
@@ -2924,12 +2924,12 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds,
first_execution
=
0
;
if
(
*
conds
)
{
prep_where
=
*
conds
;
thd
->
check_and_register_item_tree
(
&
prep_where
,
conds
)
;
*
conds
=
where
=
prep_where
->
copy_andor_structure
(
thd
);
}
if
(
*
having_conds
)
{
prep_having
=
*
having_conds
;
thd
->
check_and_register_item_tree
(
&
prep_having
,
having_conds
)
;
*
having_conds
=
having
=
prep_having
->
copy_andor_structure
(
thd
);
}
fix_prepare_info_in_table_list
(
thd
,
table_list
.
first
);
...
...
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