Commit d8ea8a3d authored by unknown's avatar unknown

MDEV-5717: Server crash with insert statement containing DEFAULT into view

Item_default_value::arg can be NULL so walk() should take it into consideration.
parent 321ff25f
...@@ -4790,6 +4790,22 @@ v1_field1 ...@@ -4790,6 +4790,22 @@ v1_field1
deallocate prepare my_stmt; deallocate prepare my_stmt;
DROP VIEW v1,v2; DROP VIEW v1,v2;
DROP TABLE t1,t2,t3,t4; DROP TABLE t1,t2,t3,t4;
#
#MDEV-5717: Server crash with insert statement containing DEFAULT into
#view
#
CREATE TABLE t1 (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`test` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
);
CREATE VIEW v1 AS (select t1.id AS id, t1.test AS test from t1);
INSERT INTO v1 SET test = DEFAULT;
select * from v1;
id test
1 0
drop view v1;
drop table t1;
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# -- End of 5.3 tests. # -- End of 5.3 tests.
# ----------------------------------------------------------------- # -----------------------------------------------------------------
......
...@@ -4720,6 +4720,25 @@ deallocate prepare my_stmt; ...@@ -4720,6 +4720,25 @@ deallocate prepare my_stmt;
DROP VIEW v1,v2; DROP VIEW v1,v2;
DROP TABLE t1,t2,t3,t4; DROP TABLE t1,t2,t3,t4;
--echo #
--echo #MDEV-5717: Server crash with insert statement containing DEFAULT into
--echo #view
--echo #
CREATE TABLE t1 (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`test` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
);
CREATE VIEW v1 AS (select t1.id AS id, t1.test AS test from t1);
INSERT INTO v1 SET test = DEFAULT;
select * from v1;
drop view v1;
drop table t1;
--echo # ----------------------------------------------------------------- --echo # -----------------------------------------------------------------
--echo # -- End of 5.3 tests. --echo # -- End of 5.3 tests.
--echo # ----------------------------------------------------------------- --echo # -----------------------------------------------------------------
......
...@@ -3551,7 +3551,7 @@ class Item_default_value : public Item_field ...@@ -3551,7 +3551,7 @@ class Item_default_value : public Item_field
bool walk(Item_processor processor, bool walk_subquery, uchar *args) bool walk(Item_processor processor, bool walk_subquery, uchar *args)
{ {
return arg->walk(processor, walk_subquery, args) || return (arg && arg->walk(processor, walk_subquery, args)) ||
(this->*processor)(args); (this->*processor)(args);
} }
......
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