summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <sanja@montyprogram.com>2014-03-12 12:34:16 +0200
committerunknown <sanja@montyprogram.com>2014-03-12 12:34:16 +0200
commitd8ea8a3d13d2a754a1e80d11619ba3347bb7ee5f (patch)
tree9193a054130181e04ebb970402de348f7a380a54
parent321ff25f3d419bc1a1fae2390450d1b4db30b64c (diff)
downloadmariadb-git-d8ea8a3d13d2a754a1e80d11619ba3347bb7ee5f.tar.gz
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.
-rw-r--r--mysql-test/r/view.result16
-rw-r--r--mysql-test/t/view.test19
-rw-r--r--sql/item.h2
3 files changed, 36 insertions, 1 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 8e5c082c6c1..1435b0c7a97 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -4790,6 +4790,22 @@ v1_field1
deallocate prepare my_stmt;
DROP VIEW v1,v2;
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.
# -----------------------------------------------------------------
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index d3a7e098ad8..5a2d90180ea 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -4720,6 +4720,25 @@ deallocate prepare my_stmt;
DROP VIEW v1,v2;
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 # -- End of 5.3 tests.
--echo # -----------------------------------------------------------------
diff --git a/sql/item.h b/sql/item.h
index 80f8ef966bb..e8619ca4f92 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -3551,7 +3551,7 @@ public:
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);
}