=== modified file 'mysql-test/r/type_timestamp.result'
--- mysql-test/r/type_timestamp.result	2012-10-17 12:43:56 +0000
+++ mysql-test/r/type_timestamp.result	2015-01-15 11:21:14 +0000
@@ -645,3 +645,115 @@
 1
 DROP TABLE t1;
 End of 5.5 tests
+#
+# MDEV-7254: Assigned expression is evaluated twice when updating column TIMESTAMP NOT NULL
+#
+CREATE TABLE t1(value TIMESTAMP NOT NULL);
+set @a:=0;
+set @b:=0;
+create function f1 () returns timestamp
+begin
+set @a = @a + 1;
+return now();
+end//
+create function f2 () returns timestamp
+begin
+set @b = @b + 1;
+return NULL;
+end//
+INSERT t1 SET value=now();
+update t1 set value = NULL;
+update t1 set value = f1();
+# expected 1
+select @a;
+@a
+1
+select sleep(2);
+sleep(2)
+0
+update t1 set value = (1 = f2());
+Warnings:
+Warning	1292	Incorrect datetime value: '1'
+# expected 1
+select @b;
+@b
+1
+drop table t1;
+set @a:=0;
+set @b:=0;
+CREATE TABLE t1(value TIMESTAMP NULL);
+INSERT t1 SET value=now();
+update t1 set value = NULL;
+update t1 set value = f1();
+# expected 1
+select @a;
+@a
+1
+select sleep(2);
+sleep(2)
+0
+update t1 set value = (1 = f2());
+Warnings:
+Warning	1292	Incorrect datetime value: '1'
+# expected 1
+select @b;
+@b
+1
+drop table t1;
+set @a:=0;
+set @b:=0;
+CREATE TABLE t1(value TIMESTAMP NOT NULL);
+INSERT t1 VALUES (f1());
+#expected 1
+select @a;
+@a
+1
+drop table t1;
+set @a:=0;
+set @b:=0;
+CREATE TABLE t1(value TIMESTAMP NULL);
+INSERT t1 VALUES (f1());
+# expected 1
+select @a;
+@a
+1
+drop table t1;
+set @a:=0;
+set @b:=0;
+CREATE TABLE t1(value TIMESTAMP NOT NULL);
+INSERT t1 VALUES (f2());
+#expected 1
+select @b;
+@b
+1
+drop table t1;
+set @a:=0;
+set @b:=0;
+CREATE TABLE t1(value TIMESTAMP NULL);
+INSERT t1 VALUES (f2());
+# expected 1
+select @b;
+@b
+1
+drop table t1;
+create table foo(value TIMESTAMP NOT NULL);
+insert foo set value=now();
+set @old:=null, @new:=null;
+update foo set value=@new:=greatest(now() + interval 2 second, @old:=value);
+# expected 2 second difference
+select timediff(@new,@old);
+timediff(@new,@old)
+00:00:02
+drop table foo;
+create table foo(value TIMESTAMP NULL);
+insert foo set value=now();
+set @old:=null, @new:=null;
+update foo set value=@new:=greatest(now() + interval 2 second, @old:=value);
+# expected 2 second difference
+select timediff(@new,@old);
+timediff(@new,@old)
+00:00:02
+drop table foo;
+drop function f1;
+drop function f2;
+End of 10.0 tests

=== modified file 'mysql-test/t/type_timestamp.test'
--- mysql-test/t/type_timestamp.test	2012-10-17 12:43:56 +0000
+++ mysql-test/t/type_timestamp.test	2015-01-15 11:21:14 +0000
@@ -446,3 +446,92 @@
 DROP TABLE t1;
 
 --echo End of 5.5 tests
+
+--echo #
+--echo # MDEV-7254: Assigned expression is evaluated twice when updating column TIMESTAMP NOT NULL
+--echo #
+
+CREATE TABLE t1(value TIMESTAMP NOT NULL);
+set @a:=0;
+set @b:=0;
+delimiter //;
+create function f1 () returns timestamp
+begin
+  set @a = @a + 1;
+  return now();
+end//
+create function f2 () returns timestamp
+begin
+  set @b = @b + 1;
+  return NULL;
+end//
+delimiter ;//
+INSERT t1 SET value=now();
+update t1 set value = NULL;
+update t1 set value = f1();
+--echo # expected 1
+select @a;
+select sleep(2);
+update t1 set value = (1 = f2());
+--echo # expected 1
+select @b;
+drop table t1;
+set @a:=0;
+set @b:=0;
+CREATE TABLE t1(value TIMESTAMP NULL);
+INSERT t1 SET value=now();
+update t1 set value = NULL;
+update t1 set value = f1();
+--echo # expected 1
+select @a;
+select sleep(2);
+update t1 set value = (1 = f2());
+--echo # expected 1
+select @b;
+drop table t1;
+set @a:=0;
+set @b:=0;
+CREATE TABLE t1(value TIMESTAMP NOT NULL);
+INSERT t1 VALUES (f1());
+--echo #expected 1
+select @a;
+drop table t1;
+set @a:=0;
+set @b:=0;
+CREATE TABLE t1(value TIMESTAMP NULL);
+INSERT t1 VALUES (f1());
+--echo # expected 1
+select @a;
+drop table t1;
+set @a:=0;
+set @b:=0;
+CREATE TABLE t1(value TIMESTAMP NOT NULL);
+INSERT t1 VALUES (f2());
+--echo #expected 1
+select @b;
+drop table t1;
+set @a:=0;
+set @b:=0;
+CREATE TABLE t1(value TIMESTAMP NULL);
+INSERT t1 VALUES (f2());
+--echo # expected 1
+select @b;
+drop table t1;
+create table foo(value TIMESTAMP NOT NULL);
+insert foo set value=now();
+set @old:=null, @new:=null;
+update foo set value=@new:=greatest(now() + interval 2 second, @old:=value);
+--echo # expected 2 second difference
+select timediff(@new,@old);
+drop table foo;
+create table foo(value TIMESTAMP NULL);
+insert foo set value=now();
+set @old:=null, @new:=null;
+update foo set value=@new:=greatest(now() + interval 2 second, @old:=value);
+--echo # expected 2 second difference
+select timediff(@new,@old);
+drop table foo;
+drop function f1;
+drop function f2;
+
+--echo End of 10.0 tests

=== modified file 'sql/field.cc'
--- sql/field.cc	2014-10-20 12:42:00 +0000
+++ sql/field.cc	2015-01-15 11:21:14 +0000
@@ -4899,7 +4899,7 @@
 {
   if (((value->type() == Item::DEFAULT_VALUE_ITEM &&
         !((Item_default_value*)value)->arg) ||
-       (!maybe_null() && value->is_null())))
+       (!maybe_null() && value->null_value)))
     return;
   set_has_explicit_value();
 }

