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
728000b2
Commit
728000b2
authored
Sep 10, 2004
by
pem@mysql.comhem.se
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed BUG#4941: Stored procedure crash fetching null value into variable.
parent
4cb65274
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
13 deletions
+55
-13
mysql-test/r/sp.result
mysql-test/r/sp.result
+16
-0
mysql-test/t/sp.test
mysql-test/t/sp.test
+22
-0
sql/protocol_cursor.cc
sql/protocol_cursor.cc
+2
-1
sql/sp_rcontext.cc
sql/sp_rcontext.cc
+15
-12
No files found.
mysql-test/r/sp.result
View file @
728000b2
...
@@ -1833,6 +1833,22 @@ NULL
...
@@ -1833,6 +1833,22 @@ NULL
Warnings:
Warnings:
Warning 1311 Referring to uninitialized variable v
Warning 1311 Referring to uninitialized variable v
drop function bug4487|
drop function bug4487|
drop procedure if exists bug4941|
create procedure bug4941(out x int)
begin
declare c cursor for select i from t2 limit 1;
open c;
fetch c into x;
close c;
end|
insert into t2 values (null, null, null)|
set @x = 42|
call bug4941(@x)|
select @x|
@x
NULL
delete from t1|
drop procedure bug4941|
drop table if exists fac|
drop table if exists fac|
create table fac (n int unsigned not null primary key, f bigint unsigned)|
create table fac (n int unsigned not null primary key, f bigint unsigned)|
create procedure ifac(n int unsigned)
create procedure ifac(n int unsigned)
...
...
mysql-test/t/sp.test
View file @
728000b2
...
@@ -2000,6 +2000,28 @@ select bug4487()|
...
@@ -2000,6 +2000,28 @@ select bug4487()|
drop
function
bug4487
|
drop
function
bug4487
|
#
# BUG#4941: Stored procedure crash fetching null value into variable.
#
--
disable_warnings
drop
procedure
if
exists
bug4941
|
--
enable_warnings
create
procedure
bug4941
(
out
x
int
)
begin
declare
c
cursor
for
select
i
from
t2
limit
1
;
open
c
;
fetch
c
into
x
;
close
c
;
end
|
insert
into
t2
values
(
null
,
null
,
null
)
|
set
@
x
=
42
|
call
bug4941
(
@
x
)
|
select
@
x
|
delete
from
t1
|
drop
procedure
bug4941
|
#
#
# Some "real" examples
# Some "real" examples
#
#
...
...
sql/protocol_cursor.cc
View file @
728000b2
...
@@ -112,7 +112,8 @@ bool Protocol_cursor::write()
...
@@ -112,7 +112,8 @@ bool Protocol_cursor::write()
for
(;
cur_field
<
fields_end
;
++
cur_field
,
++
data_tmp
)
for
(;
cur_field
<
fields_end
;
++
cur_field
,
++
data_tmp
)
{
{
if
((
len
=
net_field_length
((
uchar
**
)
&
cp
))
==
0
)
if
((
len
=
net_field_length
((
uchar
**
)
&
cp
))
==
0
||
len
==
NULL_LENGTH
)
{
{
*
data_tmp
=
0
;
*
data_tmp
=
0
;
}
}
...
...
sql/sp_rcontext.cc
View file @
728000b2
...
@@ -230,21 +230,24 @@ sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars)
...
@@ -230,21 +230,24 @@ sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars)
return
-
1
;
return
-
1
;
}
}
s
=
row
[
fldcount
];
s
=
row
[
fldcount
];
switch
(
sp_map_result_type
(
pv
->
type
))
if
(
!
s
)
{
it
=
new
Item_null
();
case
INT_RESULT
:
else
it
=
new
Item_int
(
s
);
switch
(
sp_map_result_type
(
pv
->
type
))
break
;
case
REAL_RESULT
:
it
=
new
Item_real
(
s
,
strlen
(
s
));
break
;
default:
{
{
uint
len
=
strlen
(
s
);
case
INT_RESULT
:
it
=
new
Item_
string
(
thd
->
strmake
(
s
,
len
),
len
,
thd
->
db_charset
);
it
=
new
Item_
int
(
s
);
break
;
break
;
case
REAL_RESULT
:
it
=
new
Item_real
(
s
,
strlen
(
s
));
break
;
default:
{
uint
len
=
strlen
(
s
);
it
=
new
Item_string
(
thd
->
strmake
(
s
,
len
),
len
,
thd
->
db_charset
);
break
;
}
}
}
}
thd
->
spcont
->
set_item
(
pv
->
offset
,
it
);
thd
->
spcont
->
set_item
(
pv
->
offset
,
it
);
}
}
if
(
fldcount
<
m_prot
->
get_field_count
())
if
(
fldcount
<
m_prot
->
get_field_count
())
...
...
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