Commit d7e3120d authored by halfspawn's avatar halfspawn Committed by Alexander Barkov

SP stack trace

parent 8b68263a
......@@ -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
......
......@@ -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.
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
......@@ -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%)
......
......@@ -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'
......
......@@ -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%';
......
......@@ -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
......
......@@ -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"
......@@ -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);
}
......
......@@ -888,6 +888,7 @@ class sp_instr :public Query_arena, public Sql_alloc
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)
......
......@@ -5790,9 +5790,15 @@ mysql_execute_command(THD *thd)
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
{
......
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment