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
32691e6e
Commit
32691e6e
authored
Feb 02, 2006
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/usr/home/ram/work/5.0.b16511
parents
6400ef8b
1a9ed28b
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
306 additions
and
105 deletions
+306
-105
client/mysqltest.c
client/mysqltest.c
+73
-89
mysql-test/r/sp-error.result
mysql-test/r/sp-error.result
+29
-0
mysql-test/r/sp-security.result
mysql-test/r/sp-security.result
+23
-0
mysql-test/r/sp.result
mysql-test/r/sp.result
+19
-0
mysql-test/r/type_float.result
mysql-test/r/type_float.result
+2
-2
mysql-test/t/insert.test
mysql-test/t/insert.test
+0
-9
mysql-test/t/sp-error.test
mysql-test/t/sp-error.test
+60
-0
mysql-test/t/sp-security.test
mysql-test/t/sp-security.test
+38
-0
mysql-test/t/sp.test
mysql-test/t/sp.test
+31
-0
mysql-test/t/type_float.test
mysql-test/t/type_float.test
+0
-3
mysql-test/t/variables.test
mysql-test/t/variables.test
+0
-1
sql/sp_rcontext.cc
sql/sp_rcontext.cc
+31
-1
No files found.
client/mysqltest.c
View file @
32691e6e
...
...
@@ -3028,6 +3028,58 @@ static void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val)
}
/*
Append the result for one field to the dynamic string ds
*/
static
void
append_field
(
DYNAMIC_STRING
*
ds
,
uint
col_idx
,
MYSQL_FIELD
*
field
,
const
char
*
val
,
ulonglong
len
,
bool
is_null
)
{
char
buf
[
256
];
if
(
col_idx
<
max_replace_column
&&
replace_column
[
col_idx
])
{
val
=
replace_column
[
col_idx
];
len
=
strlen
(
val
);
}
else
if
(
is_null
)
{
val
=
"NULL"
;
len
=
4
;
}
#ifdef __WIN__
else
if
(
field
->
type
==
MYSQL_TYPE_DOUBLE
&&
field
->
decimals
>=
31
)
{
/* Convert 1.2e+018 to 1.2e+18 and 1.2e-018 to 1.2e-18 */
char
*
start
=
strchr
(
val
,
'e'
);
if
(
start
&&
strlen
(
start
)
>=
5
&&
(
start
[
1
]
==
'-'
||
start
[
1
]
==
'+'
)
&&
start
[
2
]
==
'0'
)
{
start
+=
2
;
/* Now points at first '0' */
/* Move all chars after the first '0' one step left */
memmove
(
start
,
start
+
1
,
strlen
(
start
));
len
--
;
}
}
#endif
if
(
!
display_result_vertically
)
{
if
(
col_idx
)
dynstr_append_mem
(
ds
,
"
\t
"
,
1
);
replace_dynstr_append_mem
(
ds
,
val
,
(
int
)
len
);
}
else
{
dynstr_append
(
ds
,
field
->
name
);
dynstr_append_mem
(
ds
,
"
\t
"
,
1
);
replace_dynstr_append_mem
(
ds
,
val
,
(
int
)
len
);
dynstr_append_mem
(
ds
,
"
\n
"
,
1
);
}
}
/*
Append all results to the dynamic string separated with '\t'
Values may be converted with 'replace_column'
...
...
@@ -3037,41 +3089,16 @@ static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res)
{
MYSQL_ROW
row
;
uint
num_fields
=
mysql_num_fields
(
res
);
MYSQL_FIELD
*
fields
=
!
display_result_vertically
?
0
:
mysql_fetch_fields
(
res
);
MYSQL_FIELD
*
fields
=
mysql_fetch_fields
(
res
);
ulong
*
lengths
;
while
((
row
=
mysql_fetch_row
(
res
)))
{
uint
i
;
lengths
=
mysql_fetch_lengths
(
res
);
for
(
i
=
0
;
i
<
num_fields
;
i
++
)
{
const
char
*
val
=
row
[
i
];
ulonglong
len
=
lengths
[
i
];
if
(
i
<
max_replace_column
&&
replace_column
[
i
])
{
val
=
replace_column
[
i
];
len
=
strlen
(
val
);
}
if
(
!
val
)
{
val
=
"NULL"
;
len
=
4
;
}
if
(
!
display_result_vertically
)
{
if
(
i
)
dynstr_append_mem
(
ds
,
"
\t
"
,
1
);
replace_dynstr_append_mem
(
ds
,
val
,
(
int
)
len
);
}
else
{
dynstr_append
(
ds
,
fields
[
i
].
name
);
dynstr_append_mem
(
ds
,
"
\t
"
,
1
);
replace_dynstr_append_mem
(
ds
,
val
,
(
int
)
len
);
dynstr_append_mem
(
ds
,
"
\n
"
,
1
);
}
}
append_field
(
ds
,
i
,
&
fields
[
i
],
(
const
char
*
)
row
[
i
],
lengths
[
i
],
!
row
[
i
]);
if
(
!
display_result_vertically
)
dynstr_append_mem
(
ds
,
"
\n
"
,
1
);
}
...
...
@@ -3085,13 +3112,12 @@ static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res)
*/
static
void
append_stmt_result
(
DYNAMIC_STRING
*
ds
,
MYSQL_STMT
*
stmt
,
MYSQL_FIELD
*
field
,
uint
num_fields
)
MYSQL_FIELD
*
fields
,
uint
num_fields
)
{
MYSQL_BIND
*
bind
;
my_bool
*
is_null
;
ulong
*
length
;
ulonglong
num_rows
;
uint
col_idx
,
row_idx
;
uint
i
;
/* Allocate array with bind structs, lengths and NULL flags */
bind
=
(
MYSQL_BIND
*
)
my_malloc
(
num_fields
*
sizeof
(
MYSQL_BIND
),
...
...
@@ -3101,71 +3127,29 @@ static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
is_null
=
(
my_bool
*
)
my_malloc
(
num_fields
*
sizeof
(
my_bool
),
MYF
(
MY_WME
|
MY_FAE
));
for
(
col_idx
=
0
;
col_idx
<
num_fields
;
col_idx
++
)
/* Allocate data for the result of each field */
for
(
i
=
0
;
i
<
num_fields
;
i
++
)
{
/* Allocate data for output */
uint
max_length
=
field
[
col_idx
].
max_length
+
1
;
char
*
str_data
=
(
char
*
)
my_malloc
(
max_length
,
MYF
(
MY_WME
|
MY_FAE
));
bind
[
col_idx
].
buffer_type
=
MYSQL_TYPE_STRING
;
bind
[
col_idx
].
buffer
=
(
char
*
)
str_data
;
bind
[
col_idx
].
buffer_length
=
max_length
;
bind
[
col_idx
].
is_null
=
&
is_null
[
col_idx
];
bind
[
col_idx
].
length
=
&
length
[
col_idx
];
uint
max_length
=
fields
[
i
].
max_length
+
1
;
bind
[
i
].
buffer_type
=
MYSQL_TYPE_STRING
;
bind
[
i
].
buffer
=
(
char
*
)
my_malloc
(
max_length
,
MYF
(
MY_WME
|
MY_FAE
));
bind
[
i
].
buffer_length
=
max_length
;
bind
[
i
].
is_null
=
&
is_null
[
i
];
bind
[
i
].
length
=
&
length
[
i
];
DBUG_PRINT
(
"bind"
,
(
"col[%d]: buffer_type: %d, buffer_length: %d"
,
col_idx
,
bind
[
col_idx
].
buffer_type
,
bind
[
col_idx
].
buffer_length
));
i
,
bind
[
i
].
buffer_type
,
bind
[
i
].
buffer_length
));
}
/* Fill in the data into the structures created above */
if
(
mysql_stmt_bind_result
(
stmt
,
bind
))
die
(
"mysql_stmt_bind_result failed: %d: %s"
,
mysql_stmt_errno
(
stmt
),
mysql_stmt_error
(
stmt
));
/* Read result from each row */
num_rows
=
mysql_stmt_num_rows
(
stmt
);
for
(
row_idx
=
0
;
row_idx
<
num_rows
;
row_idx
++
)
while
(
mysql_stmt_fetch
(
stmt
)
==
0
)
{
if
(
mysql_stmt_fetch
(
stmt
))
die
(
"mysql_stmt_fetch failed: %d %s"
,
mysql_stmt_errno
(
stmt
),
mysql_stmt_error
(
stmt
));
/* Read result from each column */
for
(
col_idx
=
0
;
col_idx
<
num_fields
;
col_idx
++
)
{
const
char
*
val
;
ulonglong
len
;
if
(
col_idx
<
max_replace_column
&&
replace_column
[
col_idx
])
{
val
=
replace_column
[
col_idx
];
len
=
strlen
(
val
);
}
else
if
(
*
bind
[
col_idx
].
is_null
)
{
val
=
"NULL"
;
len
=
4
;
}
else
{
val
=
(
const
char
*
)
bind
[
col_idx
].
buffer
;
len
=
*
bind
[
col_idx
].
length
;
}
if
(
!
display_result_vertically
)
{
if
(
col_idx
)
/* No tab before first col */
dynstr_append_mem
(
ds
,
"
\t
"
,
1
);
replace_dynstr_append_mem
(
ds
,
val
,
(
int
)
len
);
}
else
{
dynstr_append
(
ds
,
field
[
col_idx
].
name
);
dynstr_append_mem
(
ds
,
"
\t
"
,
1
);
replace_dynstr_append_mem
(
ds
,
val
,
(
int
)
len
);
dynstr_append_mem
(
ds
,
"
\n
"
,
1
);
}
}
for
(
i
=
0
;
i
<
num_fields
;
i
++
)
append_field
(
ds
,
i
,
&
fields
[
i
],
(
const
char
*
)
bind
[
i
].
buffer
,
*
bind
[
i
].
length
,
*
bind
[
i
].
is_null
);
if
(
!
display_result_vertically
)
dynstr_append_mem
(
ds
,
"
\n
"
,
1
);
}
...
...
@@ -3176,10 +3160,10 @@ static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
free_replace_column
();
for
(
col_idx
=
0
;
col_idx
<
num_fields
;
col_idx
++
)
for
(
i
=
0
;
i
<
num_fields
;
i
++
)
{
/* Free data for output */
my_free
((
gptr
)
bind
[
col_idx
].
buffer
,
MYF
(
MY_WME
|
MY_FAE
));
my_free
((
gptr
)
bind
[
i
].
buffer
,
MYF
(
MY_WME
|
MY_FAE
));
}
/* Free array with bind structs, lengths and NULL flags */
my_free
((
gptr
)
bind
,
MYF
(
MY_WME
|
MY_FAE
));
...
...
mysql-test/r/sp-error.result
View file @
32691e6e
...
...
@@ -1147,3 +1147,32 @@ show procedure status;
Db Name Type Definer Modified Created Security_type Comment
test bug15658 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
drop procedure ` bug15658`;
drop function if exists bug14270;
drop table if exists t1;
create table t1 (s1 int primary key);
create function bug14270() returns int
begin
load index into cache t1;
return 1;
end|
ERROR 0A000: Not allowed to return a result set from a function
create function bug14270() returns int
begin
cache index t1 key (`primary`) in keycache1;
return 1;
end|
ERROR 0A000: Not allowed to return a result set from a function
drop table t1;
drop procedure if exists bug15091;
create procedure bug15091()
begin
declare selectstr varchar(6000) default ' ';
declare conditionstr varchar(5000) default '';
set selectstr = concat(selectstr,
' and ',
c.operatorid,
'in (',conditionstr, ')');
end|
call bug15091();
ERROR 42S02: Unknown table 'c' in field list
drop procedure bug15091;
mysql-test/r/sp-security.result
View file @
32691e6e
...
...
@@ -291,3 +291,26 @@ drop user user1_bug14834@localhost;
drop user user2_bug14834@localhost;
drop user user3_bug14834@localhost;
drop database db_bug14834;
create database db_bug14533;
use db_bug14533;
create table t1 (id int);
create user user_bug14533@localhost identified by '';
create procedure bug14533_1()
sql security definer
desc db_bug14533.t1;
create procedure bug14533_2()
sql security definer
select * from db_bug14533.t1;
grant execute on procedure db_bug14533.bug14533_1 to user_bug14533@localhost;
grant execute on procedure db_bug14533.bug14533_2 to user_bug14533@localhost;
call db_bug14533.bug14533_1();
Field Type Null Key Default Extra
id int(11) YES NULL
call db_bug14533.bug14533_2();
id
desc db_bug14533.t1;
ERROR 42000: SELECT command denied to user 'user_bug14533'@'localhost' for table 't1'
select * from db_bug14533.t1;
ERROR 42000: SELECT command denied to user 'user_bug14533'@'localhost' for table 't1'
drop user user_bug14533@localhost;
drop database db_bug14533;
mysql-test/r/sp.result
View file @
32691e6e
...
...
@@ -4497,4 +4497,23 @@ drop procedure if exists bug15231_1|
drop procedure if exists bug15231_2|
drop procedure if exists bug15231_3|
drop procedure if exists bug15231_4|
drop procedure if exists bug15011|
create table t3 (c1 int primary key)|
insert into t3 values (1)|
create procedure bug15011()
deterministic
begin
declare continue handler for 1062
select 'Outer' as 'Handler';
begin
declare continue handler for 1062
select 'Inner' as 'Handler';
insert into t3 values (1);
end;
end|
call bug15011()|
Handler
Inner
drop procedure bug15011|
drop table t3|
drop table t1,t2;
mysql-test/r/type_float.result
View file @
32691e6e
...
...
@@ -31,14 +31,14 @@ select * from t1;
f1 f2
10 10
100000 100000
1.23457e+9 1234567890
1.23457e+
0
9 1234567890
1e+10 10000000000
1e+15 1e+15
1e+20 1e+20
3.40282e+38 1e+50
3.40282e+38 1e+150
-10 -10
1e-
5 1e-
5
1e-
05 1e-0
5
1e-10 1e-10
1e-15 1e-15
1e-20 1e-20
...
...
mysql-test/t/insert.test
View file @
32691e6e
...
...
@@ -99,27 +99,22 @@ create table t1(number int auto_increment primary key, original_value varchar(50
set
@
value
=
"aa"
;
insert
into
t1
values
(
null
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
);
--
replace_result
e
-
0
e
-
e
+
0
e
+
--
query_vertical
select
*
from
t1
where
number
=
last_insert_id
()
set
@
value
=
"1aa"
;
insert
into
t1
values
(
null
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
);
--
replace_result
e
-
0
e
-
e
+
0
e
+
--
query_vertical
select
*
from
t1
where
number
=
last_insert_id
()
set
@
value
=
"aa1"
;
insert
into
t1
values
(
null
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
);
--
replace_result
e
-
0
e
-
e
+
0
e
+
--
query_vertical
select
*
from
t1
where
number
=
last_insert_id
()
set
@
value
=
"1e+1111111111a"
;
insert
into
t1
values
(
null
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
);
--
replace_result
e
-
0
e
-
e
+
0
e
+
--
query_vertical
select
*
from
t1
where
number
=
last_insert_id
()
set
@
value
=
"-1e+1111111111a"
;
insert
into
t1
values
(
null
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
);
--
replace_result
e
-
0
e
-
e
+
0
e
+
--
query_vertical
select
*
from
t1
where
number
=
last_insert_id
()
--
error
1367
...
...
@@ -130,22 +125,18 @@ set @value= -1e+1111111111;
set
@
value
=
1
e
+
111
;
insert
into
t1
values
(
null
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
);
--
replace_result
e
-
0
e
-
e
+
0
e
+
--
query_vertical
select
*
from
t1
where
number
=
last_insert_id
()
set
@
value
=
-
1
e
+
111
;
insert
into
t1
values
(
null
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
);
--
replace_result
e
-
0
e
-
e
+
0
e
+
--
query_vertical
select
*
from
t1
where
number
=
last_insert_id
()
set
@
value
=
1
;
insert
into
t1
values
(
null
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
);
--
replace_result
e
-
0
e
-
e
+
0
e
+
--
query_vertical
select
*
from
t1
where
number
=
last_insert_id
()
set
@
value
=
-
1
;
insert
into
t1
values
(
null
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
,
@
value
);
--
replace_result
e
-
0
e
-
e
+
0
e
+
--
query_vertical
select
*
from
t1
where
number
=
last_insert_id
()
drop
table
t1
;
...
...
mysql-test/t/sp-error.test
View file @
32691e6e
...
...
@@ -1643,6 +1643,66 @@ show procedure status;
drop
procedure
` bug15658`
;
#
# BUG#14270: Stored procedures: crash if load index
#
--
disable_warnings
drop
function
if
exists
bug14270
;
drop
table
if
exists
t1
;
--
enable_warnings
create
table
t1
(
s1
int
primary
key
);
delimiter
|
;
--
error
ER_SP_NO_RETSET
create
function
bug14270
()
returns
int
begin
load
index
into
cache
t1
;
return
1
;
end
|
--
error
ER_SP_NO_RETSET
create
function
bug14270
()
returns
int
begin
cache
index
t1
key
(
`primary`
)
in
keycache1
;
return
1
;
end
|
delimiter
;
|
drop
table
t1
;
#
# BUG#15091: Sp Returns Unknown error in order clause....and
# there is no order by clause
#
--
disable_warnings
drop
procedure
if
exists
bug15091
;
--
enable_warnings
delimiter
|
;
create
procedure
bug15091
()
begin
declare
selectstr
varchar
(
6000
)
default
' '
;
declare
conditionstr
varchar
(
5000
)
default
''
;
set
selectstr
=
concat
(
selectstr
,
' and '
,
c
.
operatorid
,
'in ('
,
conditionstr
,
')'
);
end
|
delimiter
;
|
# The error message used to be:
# ERROR 1109 (42S02): Unknown table 'c' in order clause
# but is now rephrased to something less misleading:
# ERROR 1109 (42S02): Unknown table 'c' in field list
--
error
ER_UNKNOWN_TABLE
call
bug15091
();
drop
procedure
bug15091
;
#
# BUG#NNNN: New bug synopsis
#
...
...
mysql-test/t/sp-security.test
View file @
32691e6e
...
...
@@ -487,4 +487,42 @@ drop user user2_bug14834@localhost;
drop
user
user3_bug14834
@
localhost
;
drop
database
db_bug14834
;
#
# BUG#14533: 'desc tbl' in stored procedure causes error 1142
#
create
database
db_bug14533
;
use
db_bug14533
;
create
table
t1
(
id
int
);
create
user
user_bug14533
@
localhost
identified
by
''
;
create
procedure
bug14533_1
()
sql
security
definer
desc
db_bug14533
.
t1
;
create
procedure
bug14533_2
()
sql
security
definer
select
*
from
db_bug14533
.
t1
;
grant
execute
on
procedure
db_bug14533
.
bug14533_1
to
user_bug14533
@
localhost
;
grant
execute
on
procedure
db_bug14533
.
bug14533_2
to
user_bug14533
@
localhost
;
connect
(
user_bug14533
,
localhost
,
user_bug14533
,,
test
);
# These should work
call
db_bug14533
.
bug14533_1
();
call
db_bug14533
.
bug14533_2
();
# For reference, these should not work
--
error
ER_TABLEACCESS_DENIED_ERROR
desc
db_bug14533
.
t1
;
--
error
ER_TABLEACCESS_DENIED_ERROR
select
*
from
db_bug14533
.
t1
;
# Cleanup
connection
default
;
disconnect
user_bug14533
;
drop
user
user_bug14533
@
localhost
;
drop
database
db_bug14533
;
# End of 5.0 bugs.
mysql-test/t/sp.test
View file @
32691e6e
...
...
@@ -5283,6 +5283,37 @@ drop procedure if exists bug15231_3|
drop
procedure
if
exists
bug15231_4
|
#
# BUG#15011: error handler in nested block not activated
#
--
disable_warnings
drop
procedure
if
exists
bug15011
|
--
enable_warnings
create
table
t3
(
c1
int
primary
key
)
|
insert
into
t3
values
(
1
)
|
create
procedure
bug15011
()
deterministic
begin
declare
continue
handler
for
1062
select
'Outer'
as
'Handler'
;
begin
declare
continue
handler
for
1062
select
'Inner'
as
'Handler'
;
insert
into
t3
values
(
1
);
end
;
end
|
call
bug15011
()
|
drop
procedure
bug15011
|
drop
table
t3
|
#
# BUG#NNNN: New bug synopsis
#
...
...
mysql-test/t/type_float.test
View file @
32691e6e
...
...
@@ -6,9 +6,7 @@
drop
table
if
exists
t1
,
t2
;
--
enable_warnings
--
replace_result
e
-
0
e
-
e
+
0
e
+
SELECT
10
,
10.0
,
10.
,
.
1
e
+
2
,
100.0e-1
;
--
replace_result
e
-
00
e
-
0
SELECT
6
e
-
05
,
-
6
e
-
05
,
--
6
e
-
05
,
-
6
e
-
05
+
1.000000
;
SELECT
1
e1
,
1.e1
,
1.0e1
,
1
e
+
1
,
1.e+1
,
1.0e+1
,
1
e
-
1
,
1.e-1
,
1.0e-1
;
SELECT
0.001e+1
,
0.001e-1
,
-
0.001e+01
,
-
0.001e-01
;
...
...
@@ -21,7 +19,6 @@ create table t1 (f1 float(24),f2 float(52));
show
full
columns
from
t1
;
insert
into
t1
values
(
10
,
10
),(
1
e
+
5
,
1
e
+
5
),(
1234567890
,
1234567890
),(
1
e
+
10
,
1
e
+
10
),(
1
e
+
15
,
1
e
+
15
),(
1
e
+
20
,
1
e
+
20
),(
1
e
+
50
,
1
e
+
50
),(
1
e
+
150
,
1
e
+
150
);
insert
into
t1
values
(
-
10
,
-
10
),(
1
e
-
5
,
1
e
-
5
),(
1
e
-
10
,
1
e
-
10
),(
1
e
-
15
,
1
e
-
15
),(
1
e
-
20
,
1
e
-
20
),(
1
e
-
50
,
1
e
-
50
),(
1
e
-
150
,
1
e
-
150
);
--
replace_result
e
-
0
e
-
e
+
0
e
+
select
*
from
t1
;
drop
table
t1
;
...
...
mysql-test/t/variables.test
View file @
32691e6e
...
...
@@ -20,7 +20,6 @@ select @test, @`test`, @TEST, @`TEST`, @"teSt";
set
@
select
=
2
,
@
t5
=
1.23456
;
select
@
`select`
,
@
not_used
;
set
@
test_int
=
10
,
@
test_double
=
1
e
-
10
,
@
test_string
=
"abcdeghi"
,
@
test_string2
=
"abcdefghij"
,
@
select
=
NULL
;
--
replace_result
e
-
0
e
-
e
+
0
e
+
select
@
test_int
,
@
test_double
,
@
test_string
,
@
test_string2
,
@
select
;
set
@
test_int
=
"hello"
,
@
test_double
=
"hello"
,
@
test_string
=
"hello"
,
@
test_string2
=
"hello"
;
select
@
test_int
,
@
test_double
,
@
test_string
,
@
test_string2
;
...
...
sql/sp_rcontext.cc
View file @
32691e6e
...
...
@@ -164,6 +164,33 @@ sp_rcontext::set_return_value(THD *thd, Item *return_value_item)
#define IS_NOT_FOUND_CONDITION(S) ((S)[0] == '0' && (S)[1] == '2')
#define IS_EXCEPTION_CONDITION(S) ((S)[0] != '0' || (S)[1] > '2')
/*
Find a handler for the given errno.
This is called from all error message functions (e.g. push_warning,
net_send_error, et al) when a sp_rcontext is in effect. If a handler
is found, no error is sent, and the the SP execution loop will instead
invoke the found handler.
This might be called several times before we get back to the execution
loop, so m_hfound can be >= 0 if a handler has already been found.
(In which case we don't search again - the first found handler will
be used.)
Handlers are pushed on the stack m_handler, with the latest/innermost
one on the top; we then search for matching handlers from the top and
down.
We search through all the handlers, looking for the most specific one
(sql_errno more specific than sqlstate more specific than the rest).
Note that mysql error code handlers is a MySQL extension, not part of
the standard.
SYNOPSIS
sql_errno The error code
level Warning level
RETURN
1 if a handler was found, m_hfound is set to its index (>= 0)
0 if not found, m_hfound is -1
*/
bool
sp_rcontext
::
find_handler
(
uint
sql_errno
,
MYSQL_ERROR
::
enum_warning_level
level
)
...
...
@@ -174,11 +201,13 @@ sp_rcontext::find_handler(uint sql_errno,
const
char
*
sqlstate
=
mysql_errno_to_sqlstate
(
sql_errno
);
int
i
=
m_hcount
,
found
=
-
1
;
/* Search handlers from the latest (innermost) to the oldest (outermost) */
while
(
i
--
)
{
sp_cond_type_t
*
cond
=
m_handler
[
i
].
cond
;
int
j
=
m_ihsp
;
/* Check active handlers, to avoid invoking one recursively */
while
(
j
--
)
if
(
m_in_handler
[
j
]
==
m_handler
[
i
].
handler
)
break
;
...
...
@@ -188,7 +217,8 @@ sp_rcontext::find_handler(uint sql_errno,
switch
(
cond
->
type
)
{
case
sp_cond_type_t
:
:
number
:
if
(
sql_errno
==
cond
->
mysqlerr
)
if
(
sql_errno
==
cond
->
mysqlerr
&&
(
found
<
0
||
m_handler
[
found
].
cond
->
type
>
sp_cond_type_t
::
number
))
found
=
i
;
// Always the most specific
break
;
case
sp_cond_type_t
:
:
state
:
...
...
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