summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/commit_1innodb.result1
-rw-r--r--mysql-test/r/get_diagnostics.result6
-rw-r--r--mysql-test/r/signal.result17
-rw-r--r--mysql-test/r/signal_demo3.result33
-rw-r--r--mysql-test/r/sp-error.result2
-rw-r--r--mysql-test/r/sp.result1
-rw-r--r--mysql-test/r/warnings.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_slave_grp_exec.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_sp.result2
-rw-r--r--mysql-test/suite/rpl/t/rpl_slave_grp_exec.test1
-rw-r--r--mysql-test/t/get_diagnostics.test1
-rw-r--r--sql/share/errmsg-utf8.txt2
-rw-r--r--sql/sp_head.cc11
-rw-r--r--sql/sp_head.h1
-rw-r--r--sql/sql_parse.cc12
-rw-r--r--sql/sql_signal.cc14
16 files changed, 84 insertions, 22 deletions
diff --git a/mysql-test/r/commit_1innodb.result b/mysql-test/r/commit_1innodb.result
index 1adba7b4c4c..61274fa9049 100644
--- a/mysql-test/r/commit_1innodb.result
+++ b/mysql-test/r/commit_1innodb.result
@@ -230,6 +230,7 @@ insert into t2 (a) values (1023);
do (f2(23));
Warnings:
Error 1062 Duplicate entry '23' for key 'a'
+Note 4070 At line 4 in test.f2
select * from t2;
a
1023
diff --git a/mysql-test/r/get_diagnostics.result b/mysql-test/r/get_diagnostics.result
index fbe3a02ee88..abd2fdd4da9 100644
--- a/mysql-test/r/get_diagnostics.result
+++ b/mysql-test/r/get_diagnostics.result
@@ -587,6 +587,10 @@ DROP PROCEDURE p1;
# The same statement information item can be used multiple times.
+SHOW WARNINGS;
+Level Code Message
+Error 54321 MESSAGE_TEXT text
+Note 4070 At line 16 in test.p1
CREATE PROCEDURE p1()
BEGIN
DECLARE var INT;
@@ -595,7 +599,7 @@ SELECT var, @var;
END|
CALL p1();
var @var
-1 1
+2 2
DROP PROCEDURE p1;
# Setting TABLE_NAME is currently not implemented.
diff --git a/mysql-test/r/signal.result b/mysql-test/r/signal.result
index f05e357104d..4c2dda51a2f 100644
--- a/mysql-test/r/signal.result
+++ b/mysql-test/r/signal.result
@@ -1715,6 +1715,7 @@ show warnings $$
Level Code Message
Warning 1012 Raising a warning
Error 5555 RESIGNAL to not found
+Note 4070 At line 9 in test.test_resignal
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -1739,6 +1740,7 @@ show warnings $$
Level Code Message
Warning 1012 Raising a warning
Error 5555 RESIGNAL to error
+Note 4070 At line 9 in test.test_resignal
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -1787,6 +1789,7 @@ show warnings $$
Level Code Message
Error 1012 Raising a not found
Error 5555 RESIGNAL to not found
+Note 4070 At line 9 in test.test_resignal
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -1811,6 +1814,7 @@ show warnings $$
Level Code Message
Error 1012 Raising a not found
Error 5555 RESIGNAL to error
+Note 4070 At line 9 in test.test_resignal
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -1859,6 +1863,7 @@ show warnings $$
Level Code Message
Error 1012 Raising an error
Error 5555 RESIGNAL to not found
+Note 4070 At line 9 in test.test_resignal
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -1883,6 +1888,7 @@ show warnings $$
Level Code Message
Error 1012 Raising an error
Error 5555 RESIGNAL to error
+Note 4070 At line 9 in test.test_resignal
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -1925,6 +1931,7 @@ show warnings $$
Level Code Message
Warning 1264 Out of range value for column 'a' at row 1
Error 5555 RESIGNAL to a not found
+Note 4070 At line 8 in test.test_resignal
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -1946,6 +1953,7 @@ show warnings $$
Level Code Message
Warning 1264 Out of range value for column 'a' at row 1
Error 5555 RESIGNAL to an error
+Note 4070 At line 8 in test.test_resignal
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -1996,6 +2004,7 @@ show warnings $$
Level Code Message
Error 1329 No data - zero rows fetched, selected, or processed
Error 5555 RESIGNAL to a not found
+Note 4070 At line 10 in test.test_resignal
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -2021,6 +2030,7 @@ show warnings $$
Level Code Message
Error 1329 No data - zero rows fetched, selected, or processed
Error 5555 RESIGNAL to an error
+Note 4070 At line 10 in test.test_resignal
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -2063,6 +2073,7 @@ show warnings $$
Level Code Message
Error 1051 Unknown table 'test.no_such_table'
Error 5555 RESIGNAL to a not found
+Note 4070 At line 8 in test.test_resignal
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -2084,6 +2095,7 @@ show warnings $$
Level Code Message
Error 1051 Unknown table 'test.no_such_table'
Error 5555 RESIGNAL to an error
+Note 4070 At line 8 in test.test_resignal
drop procedure test_resignal $$
#
# More complex cases
@@ -2130,6 +2142,7 @@ ERROR 42000: Hi, I am a useless error message
show warnings $$
Level Code Message
Error 9999 Hi, I am a useless error message
+Note 4070 At line 7 in test.peter_p2
drop procedure peter_p1 $$
drop procedure peter_p2 $$
CREATE PROCEDURE peter_p1 ()
@@ -2185,13 +2198,16 @@ Level Code Message
Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL'
Error 1232 Variable 'sql_mode' can't be set to the value of 'NULL'
Error 9999 Variable 'sql_mode' can't be set to the value of 'NULL'
+Note 4070 At line 8 in test.peter_p1
ERROR 42000: Hi, I am a useless error message
show warnings $$
Level Code Message
Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL'
Error 1232 Variable 'sql_mode' can't be set to the value of 'NULL'
Error 9999 Variable 'sql_mode' can't be set to the value of 'NULL'
+Note 4070 At line 8 in test.peter_p1
Error 9999 Hi, I am a useless error message
+Note 4070 At line 10 in test.peter_p2
drop procedure peter_p1 $$
drop procedure peter_p2 $$
drop procedure if exists peter_p3 $$
@@ -2209,6 +2225,7 @@ show warnings $$
Level Code Message
Error 1 Original
Error 2 Original
+Note 4070 At line 4 in test.peter_p3
drop procedure peter_p3 $$
drop table t_warn;
drop table t_cursor;
diff --git a/mysql-test/r/signal_demo3.result b/mysql-test/r/signal_demo3.result
index cc7042269bb..122a2178035 100644
--- a/mysql-test/r/signal_demo3.result
+++ b/mysql-test/r/signal_demo3.result
@@ -79,14 +79,23 @@ show warnings;
Level Code Message
Error 1051 Unknown table 'demo.oops_it_is_not_here'
Error 1644 Oops in proc_9
+Note 4070 At line 4 in demo.proc_9
Error 1644 Oops in proc_8
+Note 4070 At line 4 in demo.proc_8
Error 1644 Oops in proc_7
+Note 4070 At line 4 in demo.proc_7
Error 1644 Oops in proc_6
+Note 4070 At line 4 in demo.proc_6
Error 1644 Oops in proc_5
+Note 4070 At line 4 in demo.proc_5
Error 1644 Oops in proc_4
+Note 4070 At line 4 in demo.proc_4
Error 1644 Oops in proc_3
+Note 4070 At line 4 in demo.proc_3
Error 1644 Oops in proc_2
+Note 4070 At line 4 in demo.proc_2
Error 1644 Oops in proc_1
+Note 4070 At line 4 in demo.proc_1
SET @@session.max_error_count = 5;
SELECT @@session.max_error_count;
@@session.max_error_count
@@ -95,11 +104,11 @@ call proc_1();
ERROR 45000: Oops in proc_1
show warnings;
Level Code Message
-Error 1644 Oops in proc_5
-Error 1644 Oops in proc_4
-Error 1644 Oops in proc_3
+Note 4070 At line 4 in demo.proc_3
Error 1644 Oops in proc_2
+Note 4070 At line 4 in demo.proc_2
Error 1644 Oops in proc_1
+Note 4070 At line 4 in demo.proc_1
SET @@session.max_error_count = 7;
SELECT @@session.max_error_count;
@@session.max_error_count
@@ -108,13 +117,13 @@ call proc_1();
ERROR 45000: Oops in proc_1
show warnings;
Level Code Message
-Error 1644 Oops in proc_7
-Error 1644 Oops in proc_6
-Error 1644 Oops in proc_5
-Error 1644 Oops in proc_4
+Note 4070 At line 4 in demo.proc_4
Error 1644 Oops in proc_3
+Note 4070 At line 4 in demo.proc_3
Error 1644 Oops in proc_2
+Note 4070 At line 4 in demo.proc_2
Error 1644 Oops in proc_1
+Note 4070 At line 4 in demo.proc_1
SET @@session.max_error_count = 9;
SELECT @@session.max_error_count;
@@session.max_error_count
@@ -123,15 +132,15 @@ call proc_1();
ERROR 45000: Oops in proc_1
show warnings;
Level Code Message
-Error 1644 Oops in proc_9
-Error 1644 Oops in proc_8
-Error 1644 Oops in proc_7
-Error 1644 Oops in proc_6
-Error 1644 Oops in proc_5
+Note 4070 At line 4 in demo.proc_5
Error 1644 Oops in proc_4
+Note 4070 At line 4 in demo.proc_4
Error 1644 Oops in proc_3
+Note 4070 At line 4 in demo.proc_3
Error 1644 Oops in proc_2
+Note 4070 At line 4 in demo.proc_2
Error 1644 Oops in proc_1
+Note 4070 At line 4 in demo.proc_1
drop database demo;
SET @@global.max_error_count = @start_global_value;
SELECT @@global.max_error_count;
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index aee3a614391..f8dd2737e8e 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -1990,6 +1990,8 @@ Warning 1264 Out of range value for column 'a' at row 1
Note 1292 Truncated incorrect INTEGER value: '222222 '
Warning 1264 Out of range value for column 'b' at row 1
Error 1048 Column 'c' cannot be null
+Note 4070 At line 6 in test.t1_bi
+Note 4070 At line 2 in test.p1
DROP TABLE t1;
DROP TABLE t2;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index a53ca16f283..641c756691e 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -7823,6 +7823,7 @@ ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
show warnings;
Level Code Message
Error 1062 Duplicate entry '2' for key 'PRIMARY'
+Note 4070 At line 5 in test.p1
select * from t1;
id
1
diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index 3f4f62dc935..5001f707f5a 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -353,6 +353,7 @@ ERROR 23000: Duplicate entry '11' for key 'a'
SHOW WARNINGS;
Level Code Message
+Note 4070 At line 4 in test.f1
Error 1062 Duplicate entry '11' for key 'a'
DROP TABLE t1;
diff --git a/mysql-test/suite/rpl/r/rpl_slave_grp_exec.result b/mysql-test/suite/rpl/r/rpl_slave_grp_exec.result
index 9a34844489f..60ad6dc6e4f 100644
--- a/mysql-test/suite/rpl/r/rpl_slave_grp_exec.result
+++ b/mysql-test/suite/rpl/r/rpl_slave_grp_exec.result
@@ -35,6 +35,7 @@ a b
1 ZZ
connection slave;
call mtr.add_suppression("Slave SQL.*Table .test.t3. doesn.t exist.* error.* 1146");
+call mtr.add_suppression("At line *");
include/wait_for_slave_sql_error.inc [errno=1146]
SHOW TABLES LIKE 't%';
Tables_in_test (t%)
diff --git a/mysql-test/suite/rpl/r/rpl_sp.result b/mysql-test/suite/rpl/r/rpl_sp.result
index 411a24278d5..3ea69a1e391 100644
--- a/mysql-test/suite/rpl/r/rpl_sp.result
+++ b/mysql-test/suite/rpl/r/rpl_sp.result
@@ -128,6 +128,7 @@ show warnings;
Level Code Message
Error 1062 Duplicate entry '20' for key 'a'
Warning 1196 Some non-transactional changed tables couldn't be rolled back
+Note 4070 At line 4 in mysqltest1.foo4
select * from t2;
a
20
@@ -290,6 +291,7 @@ end|
do fn1(100);
Warnings:
Error 1062 Duplicate entry '100' for key 'a'
+Note 4070 At line 3 in mysqltest1.fn1
Warning 1196 Some non-transactional changed tables couldn't be rolled back
select fn1(20);
ERROR 23000: Duplicate entry '20' for key 'a'
diff --git a/mysql-test/suite/rpl/t/rpl_slave_grp_exec.test b/mysql-test/suite/rpl/t/rpl_slave_grp_exec.test
index 426c3c831b0..928ad7e5e09 100644
--- a/mysql-test/suite/rpl/t/rpl_slave_grp_exec.test
+++ b/mysql-test/suite/rpl/t/rpl_slave_grp_exec.test
@@ -64,6 +64,7 @@ SELECT * FROM t3 ORDER BY a;
--connection slave
# 1146 = ER_NO_SUCH_TABLE
call mtr.add_suppression("Slave SQL.*Table .test.t3. doesn.t exist.* error.* 1146");
+call mtr.add_suppression("At line *");
--let $slave_sql_errno= 1146
--source include/wait_for_slave_sql_error.inc
SHOW TABLES LIKE 't%';
diff --git a/mysql-test/t/get_diagnostics.test b/mysql-test/t/get_diagnostics.test
index 0b0d8a77087..a30bad72136 100644
--- a/mysql-test/t/get_diagnostics.test
+++ b/mysql-test/t/get_diagnostics.test
@@ -631,6 +631,7 @@ DROP PROCEDURE p1;
--echo # The same statement information item can be used multiple times.
--echo
+SHOW WARNINGS;
DELIMITER |;
CREATE PROCEDURE p1()
BEGIN
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index f19d953fc52..1f282e6aee5 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -7488,3 +7488,5 @@ ER_UNKNOWN_VIEW 42S02
eng "Unknown VIEW: '%-.300s'"
ER_WRONG_INSERT_INTO_SEQUENCE
eng "Wrong INSERT into a SEQUENCE. One can only do single table INSERT into a squence object (like with mysqldump). If you want to change the SEQUENCE, use ALTER SEQUENCE instead."
+ER_SP_STACK_TRACE
+ eng "At line %u in %s"
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 80730a9b060..f8ad3c305a7 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1178,11 +1178,10 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
/* Discard the initial part of executing routines. */
thd->profiling.discard_current_query();
#endif
+ sp_instr *i;
DEBUG_SYNC(thd, "sp_head_execute_before_loop");
do
{
- sp_instr *i;
-
#if defined(ENABLED_PROFILING)
/*
Treat each "instr" of a routine as discrete unit that could be profiled.
@@ -1342,6 +1341,13 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
da->opt_clear_warning_info(thd->query_id);
da->copy_sql_conditions_from_wi(thd, &sp_wi);
da->remove_marked_sql_conditions();
+ if (i != NULL)
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
+ ER_SP_STACK_TRACE,
+ ER_THD(thd, ER_SP_STACK_TRACE),
+ i->m_lineno,
+ m_qname.str != NULL ? m_qname.str :
+ "anonymous block");
}
}
@@ -2770,6 +2776,7 @@ int sp_head::add_instr(sp_instr *instr)
entire stored procedure, as their life span is equal.
*/
instr->mem_root= &main_mem_root;
+ instr->m_lineno= m_thd->m_parser_state->m_lip.yylineno;
return insert_dynamic(&m_instr, (uchar*)&instr);
}
diff --git a/sql/sp_head.h b/sql/sp_head.h
index cfc2e6861d7..a96ef514429 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -888,6 +888,7 @@ public:
uint marked;
uint m_ip; ///< My index
sp_pcontext *m_ctx; ///< My parse context
+ uint m_lineno;
/// Should give each a name or type code for debugging purposes?
sp_instr(uint ip, sp_pcontext *ctx)
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 2d5689a85cd..42bf6a5b97c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -5790,9 +5790,15 @@ end_with_restore_list:
if (!(sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname,
&thd->sp_proc_cache, TRUE)))
{
- my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PROCEDURE",
- ErrConvDQName(lex->spname).ptr());
- goto error;
+ /*
+ sp_find_routine can have issued an ER_SP_RECURSION_LIMIT error.
+ Send message ER_SP_DOES_NOT_EXIST only if procedure is not found in
+ cache.
+ */
+ if (!sp_cache_lookup(&thd->sp_proc_cache, lex->spname))
+ my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PROCEDURE",
+ ErrConvDQName(lex->spname).ptr());
+ goto error;
}
else
{
diff --git a/sql/sql_signal.cc b/sql/sql_signal.cc
index 828149f3035..6a57b8fc9ce 100644
--- a/sql/sql_signal.cc
+++ b/sql/sql_signal.cc
@@ -434,13 +434,19 @@ bool Sql_cmd_resignal::execute(THD *thd)
/* Check if the old condition still exists. */
if (da->has_sql_condition(signaled->message, strlen(signaled->message)))
{
- /* Make room for the new RESIGNAL condition. */
- da->reserve_space(thd, 1);
+ /*
+ Make room for the new RESIGNAL condition and one for the stack trace
+ note.
+ */
+ da->reserve_space(thd, 2);
}
else
{
- /* Make room for old condition + the new RESIGNAL condition. */
- da->reserve_space(thd, 2);
+ /*
+ Make room for old condition + the new RESIGNAL condition + the stack
+ trace note.
+ */
+ da->reserve_space(thd, 3);
da->push_warning(thd, &signaled_err);
}