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
e8634f80
Commit
e8634f80
authored
Oct 03, 2003
by
pem@mysql.telia.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check that a FUNCTION contains RETURN and that we actually get a return value.
parent
dbf45cbc
Changes
30
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
112 additions
and
3 deletions
+112
-3
include/mysqld_error.h
include/mysqld_error.h
+3
-1
mysql-test/r/sp-error.result
mysql-test/r/sp-error.result
+17
-0
mysql-test/t/sp-error.test
mysql-test/t/sp-error.test
+23
-0
sql/share/czech/errmsg.txt
sql/share/czech/errmsg.txt
+2
-0
sql/share/danish/errmsg.txt
sql/share/danish/errmsg.txt
+2
-0
sql/share/dutch/errmsg.txt
sql/share/dutch/errmsg.txt
+2
-0
sql/share/english/errmsg.txt
sql/share/english/errmsg.txt
+2
-0
sql/share/estonian/errmsg.txt
sql/share/estonian/errmsg.txt
+2
-0
sql/share/french/errmsg.txt
sql/share/french/errmsg.txt
+2
-0
sql/share/german/errmsg.txt
sql/share/german/errmsg.txt
+2
-0
sql/share/greek/errmsg.txt
sql/share/greek/errmsg.txt
+2
-0
sql/share/hungarian/errmsg.txt
sql/share/hungarian/errmsg.txt
+2
-0
sql/share/italian/errmsg.txt
sql/share/italian/errmsg.txt
+2
-0
sql/share/japanese/errmsg.txt
sql/share/japanese/errmsg.txt
+2
-0
sql/share/korean/errmsg.txt
sql/share/korean/errmsg.txt
+2
-0
sql/share/norwegian-ny/errmsg.txt
sql/share/norwegian-ny/errmsg.txt
+2
-0
sql/share/norwegian/errmsg.txt
sql/share/norwegian/errmsg.txt
+2
-0
sql/share/polish/errmsg.txt
sql/share/polish/errmsg.txt
+2
-0
sql/share/portuguese/errmsg.txt
sql/share/portuguese/errmsg.txt
+2
-0
sql/share/romanian/errmsg.txt
sql/share/romanian/errmsg.txt
+2
-0
sql/share/russian/errmsg.txt
sql/share/russian/errmsg.txt
+2
-0
sql/share/serbian/errmsg.txt
sql/share/serbian/errmsg.txt
+2
-0
sql/share/slovak/errmsg.txt
sql/share/slovak/errmsg.txt
+2
-0
sql/share/spanish/errmsg.txt
sql/share/spanish/errmsg.txt
+2
-0
sql/share/swedish/errmsg.txt
sql/share/swedish/errmsg.txt
+2
-0
sql/share/ukrainian/errmsg.txt
sql/share/ukrainian/errmsg.txt
+2
-0
sql/sp_head.cc
sql/sp_head.cc
+14
-2
sql/sp_head.h
sql/sp_head.h
+1
-0
sql/sql_parse.cc
sql/sql_parse.cc
+7
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-0
No files found.
include/mysqld_error.h
View file @
e8634f80
...
...
@@ -312,4 +312,6 @@
#define ER_QUERY_INTERRUPTED 1293
#define ER_SP_WRONG_NO_OF_ARGS 1294
#define ER_SP_COND_MISMATCH 1295
#define ER_ERROR_MESSAGES 296
#define ER_SP_NORETURN 1296
#define ER_SP_NORETURNEND 1297
#define ER_ERROR_MESSAGES 298
mysql-test/r/sp-error.result
View file @
e8634f80
...
...
@@ -121,3 +121,20 @@ set res = 1;
end if;
end;
ERROR HY000: Undefined CONDITION: bar
create function f(val int) returns int
begin
declare x int;
set x = val+3;
end;
ERROR HY000: No RETURN found in FUNCTION f
create function f(val int) returns int
begin
declare x int;
set x = val+3;
if x < 4 then
return x;
end if;
end;
select f(10);
ERROR HY000: FUNCTION f ended without RETURN
drop function f;
mysql-test/t/sp-error.test
View file @
e8634f80
...
...
@@ -171,4 +171,27 @@ begin
end
if
;
end
|
--
error
1296
create
function
f
(
val
int
)
returns
int
begin
declare
x
int
;
set
x
=
val
+
3
;
end
|
create
function
f
(
val
int
)
returns
int
begin
declare
x
int
;
set
x
=
val
+
3
;
if
x
<
4
then
return
x
;
end
if
;
end
|
--
error
1297
select
f
(
10
)
|
drop
function
f
|
delimiter
;
|
sql/share/czech/errmsg.txt
View file @
e8634f80
...
...
@@ -308,3 +308,5 @@ character-set=latin2
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/danish/errmsg.txt
View file @
e8634f80
...
...
@@ -302,3 +302,5 @@ character-set=latin1
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/dutch/errmsg.txt
View file @
e8634f80
...
...
@@ -310,3 +310,5 @@ character-set=latin1
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/english/errmsg.txt
View file @
e8634f80
...
...
@@ -299,3 +299,5 @@ character-set=latin1
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/estonian/errmsg.txt
View file @
e8634f80
...
...
@@ -304,3 +304,5 @@ character-set=latin7
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/french/errmsg.txt
View file @
e8634f80
...
...
@@ -299,3 +299,5 @@ character-set=latin1
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/german/errmsg.txt
View file @
e8634f80
...
...
@@ -308,3 +308,5 @@ character-set=latin1
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/greek/errmsg.txt
View file @
e8634f80
...
...
@@ -299,3 +299,5 @@ character-set=greek
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/hungarian/errmsg.txt
View file @
e8634f80
...
...
@@ -301,3 +301,5 @@ character-set=latin2
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/italian/errmsg.txt
View file @
e8634f80
...
...
@@ -299,3 +299,5 @@ character-set=latin1
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/japanese/errmsg.txt
View file @
e8634f80
...
...
@@ -301,3 +301,5 @@ character-set=ujis
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/korean/errmsg.txt
View file @
e8634f80
...
...
@@ -299,3 +299,5 @@ character-set=euckr
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/norwegian-ny/errmsg.txt
View file @
e8634f80
...
...
@@ -301,3 +301,5 @@ character-set=latin1
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/norwegian/errmsg.txt
View file @
e8634f80
...
...
@@ -301,3 +301,5 @@ character-set=latin1
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/polish/errmsg.txt
View file @
e8634f80
...
...
@@ -303,3 +303,5 @@ character-set=latin2
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/portuguese/errmsg.txt
View file @
e8634f80
...
...
@@ -300,3 +300,5 @@ character-set=latin1
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/romanian/errmsg.txt
View file @
e8634f80
...
...
@@ -303,3 +303,5 @@ character-set=latin2
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/russian/errmsg.txt
View file @
e8634f80
...
...
@@ -301,3 +301,5 @@ character-set=koi8r
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/serbian/errmsg.txt
View file @
e8634f80
...
...
@@ -294,3 +294,5 @@ character-set=cp1250
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/slovak/errmsg.txt
View file @
e8634f80
...
...
@@ -307,3 +307,5 @@ character-set=latin2
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/spanish/errmsg.txt
View file @
e8634f80
...
...
@@ -301,3 +301,5 @@ character-set=latin1
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/swedish/errmsg.txt
View file @
e8634f80
...
...
@@ -299,3 +299,5 @@ character-set=latin1
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/share/ukrainian/errmsg.txt
View file @
e8634f80
...
...
@@ -304,3 +304,5 @@ character-set=koi8u
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
"Undefined CONDITION: %s"
"No RETURN found in FUNCTION %s"
"FUNCTION %s ended without RETURN"
sql/sp_head.cc
View file @
e8634f80
...
...
@@ -120,7 +120,8 @@ sp_head::operator delete(void *ptr, size_t size)
}
sp_head
::
sp_head
()
:
Sql_alloc
(),
m_simple_case
(
FALSE
),
m_multi_results
(
FALSE
),
m_free_list
(
NULL
)
:
Sql_alloc
(),
m_has_return
(
FALSE
),
m_simple_case
(
FALSE
),
m_multi_results
(
FALSE
),
m_free_list
(
NULL
)
{
DBUG_ENTER
(
"sp_head::sp_head"
);
...
...
@@ -321,7 +322,18 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
ret
=
execute
(
thd
);
if
(
ret
==
0
)
*
resp
=
nctx
->
get_result
();
{
Item
*
it
=
nctx
->
get_result
();
if
(
it
)
*
resp
=
it
;
else
{
my_printf_error
(
ER_SP_NORETURNEND
,
ER
(
ER_SP_NORETURNEND
),
MYF
(
0
),
m_name
.
str
);
ret
=
-
1
;
}
}
thd
->
spcont
=
octx
;
DBUG_RETURN
(
ret
);
...
...
sql/sp_head.h
View file @
e8634f80
...
...
@@ -47,6 +47,7 @@ class sp_head : public Sql_alloc
int
m_type
;
// TYPE_ENUM_FUNCTION or TYPE_ENUM_PROCEDURE
enum
enum_field_types
m_returns
;
// For FUNCTIONs only
my_bool
m_has_return
;
// For FUNCTIONs only
my_bool
m_simple_case
;
// TRUE if parsing simple case, FALSE otherwise
my_bool
m_multi_results
;
// TRUE if a procedure with SELECT(s)
uint
m_old_cmq
;
// Old CLIENT_MULTI_QUERIES value
...
...
sql/sql_parse.cc
View file @
e8634f80
...
...
@@ -3226,6 +3226,13 @@ mysql_execute_command(THD *thd)
}
}
#endif
if
(
lex
->
sphead
->
m_type
==
TYPE_ENUM_FUNCTION
&&
!
lex
->
sphead
->
m_has_return
)
{
net_printf
(
thd
,
ER_SP_NORETURN
,
name
);
goto
error
;
}
res
=
lex
->
sphead
->
create
(
thd
);
switch
(
res
)
...
...
sql/sql_yacc.yy
View file @
e8634f80
...
...
@@ -1424,6 +1424,7 @@ sp_proc_stmt:
$2, lex->sphead->m_returns);
lex->sphead->add_instr(i);
lex->sphead->m_has_return= TRUE;
}
}
| IF sp_if END IF {}
...
...
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