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
f4ddcfee
Commit
f4ddcfee
authored
Aug 25, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/cps/mysql/devel/mysql-5.0-sp11333
parents
0f94385b
da7a46ad
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
3 deletions
+90
-3
mysql-test/r/sp.result
mysql-test/r/sp.result
+19
-0
mysql-test/t/sp.test
mysql-test/t/sp.test
+34
-0
sql/item.cc
sql/item.cc
+1
-0
sql/item.h
sql/item.h
+18
-0
sql/sp_head.cc
sql/sp_head.cc
+18
-3
No files found.
mysql-test/r/sp.result
View file @
f4ddcfee
...
@@ -3167,4 +3167,23 @@ a
...
@@ -3167,4 +3167,23 @@ a
truncate t4|
truncate t4|
drop table t3, t4|
drop table t3, t4|
drop procedure if exists bug12168|
drop procedure if exists bug12168|
drop table if exists t3|
drop procedure if exists bug11333|
create table t3 (c1 char(128))|
insert into t3 values
('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')|
create procedure bug11333(i int)
begin
declare tmp varchar(128);
set @x = 0;
repeat
select c1 into tmp from t3
where c1 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
set @x = @x + 1;
until @x >= i
end repeat;
end|
call bug11333(10)|
drop procedure bug11333|
drop table t3|
drop table t1,t2;
drop table t1,t2;
mysql-test/t/sp.test
View file @
f4ddcfee
...
@@ -3996,6 +3996,40 @@ truncate t4|
...
@@ -3996,6 +3996,40 @@ truncate t4|
drop
table
t3
,
t4
|
drop
table
t3
,
t4
|
drop
procedure
if
exists
bug12168
|
drop
procedure
if
exists
bug12168
|
#
# Bug #11333 "Stored Procedure: Memory blow up on repeated SELECT ... INTO
# query"
# One more memleak bug. Use the test to check memory consumption.
#
--
disable_warnings
drop
table
if
exists
t3
|
drop
procedure
if
exists
bug11333
|
--
enable_warnings
create
table
t3
(
c1
char
(
128
))
|
insert
into
t3
values
(
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
)
|
create
procedure
bug11333
(
i
int
)
begin
declare
tmp
varchar
(
128
);
set
@
x
=
0
;
repeat
select
c1
into
tmp
from
t3
where
c1
=
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
;
set
@
x
=
@
x
+
1
;
until
@
x
>=
i
end
repeat
;
end
|
call
bug11333
(
10
)
|
drop
procedure
bug11333
|
drop
table
t3
|
#
#
# BUG#NNNN: New bug synopsis
# BUG#NNNN: New bug synopsis
#
#
...
...
sql/item.cc
View file @
f4ddcfee
...
@@ -303,6 +303,7 @@ void *Item::operator new(size_t size, Item *reuse, uint *rsize)
...
@@ -303,6 +303,7 @@ void *Item::operator new(size_t size, Item *reuse, uint *rsize)
if
(
rsize
)
if
(
rsize
)
(
*
rsize
)
=
reuse
->
rsize
;
(
*
rsize
)
=
reuse
->
rsize
;
reuse
->
cleanup
();
reuse
->
cleanup
();
delete
reuse
;
TRASH
((
void
*
)
reuse
,
size
);
TRASH
((
void
*
)
reuse
,
size
);
return
(
void
*
)
reuse
;
return
(
void
*
)
reuse
;
}
}
...
...
sql/item.h
View file @
f4ddcfee
...
@@ -1299,6 +1299,15 @@ public:
...
@@ -1299,6 +1299,15 @@ public:
// it is constant => can be used without fix_fields (and frequently used)
// it is constant => can be used without fix_fields (and frequently used)
fixed
=
1
;
fixed
=
1
;
}
}
/* Just create an item and do not fill string representation */
Item_string
(
CHARSET_INFO
*
cs
,
Derivation
dv
=
DERIVATION_COERCIBLE
)
{
collation
.
set
(
cs
,
dv
);
max_length
=
0
;
set_name
(
NULL
,
0
,
cs
);
decimals
=
NOT_FIXED_DEC
;
fixed
=
1
;
}
Item_string
(
const
char
*
name_par
,
const
char
*
str
,
uint
length
,
Item_string
(
const
char
*
name_par
,
const
char
*
str
,
uint
length
,
CHARSET_INFO
*
cs
,
Derivation
dv
=
DERIVATION_COERCIBLE
)
CHARSET_INFO
*
cs
,
Derivation
dv
=
DERIVATION_COERCIBLE
)
{
{
...
@@ -1310,6 +1319,15 @@ public:
...
@@ -1310,6 +1319,15 @@ public:
// it is constant => can be used without fix_fields (and frequently used)
// it is constant => can be used without fix_fields (and frequently used)
fixed
=
1
;
fixed
=
1
;
}
}
/*
This is used in stored procedures to avoid memory leaks and
does a deep copy of its argument.
*/
void
set_str_with_copy
(
const
char
*
str_arg
,
uint
length_arg
)
{
str_value
.
copy
(
str_arg
,
length_arg
,
collation
.
collation
);
max_length
=
str_value
.
numchars
()
*
collation
.
collation
->
mbmaxlen
;
}
enum
Type
type
()
const
{
return
STRING_ITEM
;
}
enum
Type
type
()
const
{
return
STRING_ITEM
;
}
double
val_real
();
double
val_real
();
longlong
val_int
();
longlong
val_int
();
...
...
sql/sp_head.cc
View file @
f4ddcfee
...
@@ -245,10 +245,25 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
...
@@ -245,10 +245,25 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
DBUG_PRINT
(
"info"
,(
"STRING_RESULT: %*s"
,
DBUG_PRINT
(
"info"
,(
"STRING_RESULT: %*s"
,
s
->
length
(),
s
->
c_ptr_quick
()));
s
->
length
(),
s
->
c_ptr_quick
()));
CREATE_ON_CALLERS_ARENA
(
it
=
new
(
reuse
,
&
rsize
)
CREATE_ON_CALLERS_ARENA
(
it
=
new
(
reuse
,
&
rsize
)
Item_string
(
thd
->
strmake
(
s
->
ptr
(),
Item_string
(
it
->
collation
.
collation
),
s
->
length
()),
s
->
length
(),
it
->
collation
.
collation
),
use_callers_arena
,
&
backup_current_arena
);
use_callers_arena
,
&
backup_current_arena
);
/*
We have to use special constructor and allocate string
on system heap here. This is because usual Item_string
constructor would allocate memory in the callers arena.
This would lead to the memory leak in SP loops.
See Bug #11333 "Stored Procedure: Memory blow up on
repeated SELECT ... INTO query" for sample of such SP.
TODO: Usage of the system heap gives significant overhead,
however usual "reuse" mechanism does not work here, as
Item_string has no max size. That is, if we have a loop, which
has string variable with constantly increasing size, we would have
to allocate new pieces of memory again and again on each iteration.
In future we should probably reserve some area of memory for
not-very-large strings and reuse it. But for large strings
we would have to use system heap anyway.
*/
((
Item_string
*
)
it
)
->
set_str_with_copy
(
s
->
ptr
(),
s
->
length
());
break
;
break
;
}
}
case
ROW_RESULT
:
case
ROW_RESULT
:
...
...
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