Commit 86c70f3d authored by unknown's avatar unknown

Merge mysql.com:/home/tomash/src/mysql_ab/mysql-5.0

into  mysql.com:/home/tomash/src/mysql_ab/mysql-5.0-bug6951


mysql-test/r/trigger.result:
  Auto merged
mysql-test/t/trigger.test:
  Auto merged
sql/sp_head.cc:
  Auto merged
parents 10eac46a e334f82c
...@@ -998,3 +998,39 @@ SELECT * FROM t1 WHERE conn_id != trigger_conn_id; ...@@ -998,3 +998,39 @@ SELECT * FROM t1 WHERE conn_id != trigger_conn_id;
conn_id trigger_conn_id conn_id trigger_conn_id
DROP TRIGGER t1_bi; DROP TRIGGER t1_bi;
DROP TABLE t1; DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i1 INT);
SET @save_sql_mode=@@sql_mode;
SET SQL_MODE='';
CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
SET @x = 5/0;
SET SQL_MODE='traditional';
CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW
SET @x = 5/0;
SET @x=1;
INSERT INTO t1 VALUES (@x);
SELECT @x;
@x
NULL
SET @x=2;
UPDATE t1 SET i1 = @x;
ERROR 22012: Division by 0
SELECT @x;
@x
2
SET SQL_MODE='';
SET @x=3;
INSERT INTO t1 VALUES (@x);
SELECT @x;
@x
NULL
SET @x=4;
UPDATE t1 SET i1 = @x;
ERROR 22012: Division by 0
SELECT @x;
@x
4
SET @@sql_mode=@save_sql_mode;
DROP TRIGGER t1_ai;
DROP TRIGGER t1_au;
DROP TABLE t1;
...@@ -1165,4 +1165,52 @@ SELECT * FROM t1 WHERE conn_id != trigger_conn_id; ...@@ -1165,4 +1165,52 @@ SELECT * FROM t1 WHERE conn_id != trigger_conn_id;
DROP TRIGGER t1_bi; DROP TRIGGER t1_bi;
DROP TABLE t1; DROP TABLE t1;
#
# Bug#6951: Triggers/Traditional: SET @ result wrong
#
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (i1 INT);
SET @save_sql_mode=@@sql_mode;
SET SQL_MODE='';
CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
SET @x = 5/0;
SET SQL_MODE='traditional';
CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW
SET @x = 5/0;
SET @x=1;
INSERT INTO t1 VALUES (@x);
SELECT @x;
SET @x=2;
--error 1365
UPDATE t1 SET i1 = @x;
SELECT @x;
SET SQL_MODE='';
SET @x=3;
INSERT INTO t1 VALUES (@x);
SELECT @x;
SET @x=4;
--error 1365
UPDATE t1 SET i1 = @x;
SELECT @x;
SET @@sql_mode=@save_sql_mode;
DROP TRIGGER t1_ai;
DROP TRIGGER t1_au;
DROP TABLE t1;
# End of 5.0 tests # End of 5.0 tests
...@@ -935,6 +935,7 @@ sp_head::execute(THD *thd) ...@@ -935,6 +935,7 @@ sp_head::execute(THD *thd)
bool err_status= FALSE; bool err_status= FALSE;
uint ip= 0; uint ip= 0;
ulong save_sql_mode; ulong save_sql_mode;
bool save_abort_on_warning;
Query_arena *old_arena; Query_arena *old_arena;
/* per-instruction arena */ /* per-instruction arena */
MEM_ROOT execute_mem_root; MEM_ROOT execute_mem_root;
...@@ -995,6 +996,10 @@ sp_head::execute(THD *thd) ...@@ -995,6 +996,10 @@ sp_head::execute(THD *thd)
thd->derived_tables= 0; thd->derived_tables= 0;
save_sql_mode= thd->variables.sql_mode; save_sql_mode= thd->variables.sql_mode;
thd->variables.sql_mode= m_sql_mode; thd->variables.sql_mode= m_sql_mode;
save_abort_on_warning= thd->abort_on_warning;
thd->abort_on_warning=
(m_sql_mode & (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES));
/* /*
It is also more efficient to save/restore current thd->lex once when It is also more efficient to save/restore current thd->lex once when
do it in each instruction do it in each instruction
...@@ -1127,6 +1132,7 @@ sp_head::execute(THD *thd) ...@@ -1127,6 +1132,7 @@ sp_head::execute(THD *thd)
DBUG_ASSERT(!thd->derived_tables); DBUG_ASSERT(!thd->derived_tables);
thd->derived_tables= old_derived_tables; thd->derived_tables= old_derived_tables;
thd->variables.sql_mode= save_sql_mode; thd->variables.sql_mode= save_sql_mode;
thd->abort_on_warning= save_abort_on_warning;
thd->stmt_arena= old_arena; thd->stmt_arena= old_arena;
state= EXECUTED; state= EXECUTED;
......
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