Bug #74246 | SET: Semantic behavior different for regular execution and function | ||
---|---|---|---|
Submitted: | 7 Oct 2014 8:04 | Modified: | 7 Oct 2014 9:10 |
Reporter: | Roy Lyseng | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Options | Severity: | S3 (Non-critical) |
Version: | 5.7, 5.6.22, 5.7.6 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[7 Oct 2014 8:04]
Roy Lyseng
[7 Oct 2014 9:10]
MySQL Verification Team
Hello Roy, Thank you for the bug report and test case. Observed that the SET behavior is different for regular execution and function. Thanks, Umesh
[7 Oct 2014 9:10]
MySQL Verification Team
// 5.6.22 mysql> use test Database changed mysql> mysql> SET @a= NULL; Query OK, 0 rows affected (0.00 sec) mysql> SELECT @a:= 1, @a:= @a+1; +--------+-----------+ | @a:= 1 | @a:= @a+1 | +--------+-----------+ | 1 | 2 | +--------+-----------+ 1 row in set (0.00 sec) mysql> SELECT @a; +------+ | @a | +------+ | 2 | +------+ 1 row in set (0.00 sec) mysql> mysql> SET @a= NULL; Query OK, 0 rows affected (0.00 sec) mysql> DO @a:= 1, @a:= @a+1; Query OK, 0 rows affected (0.00 sec) mysql> SELECT @a; +------+ | @a | +------+ | 2 | +------+ 1 row in set (0.01 sec) mysql> mysql> SET @a= NULL; Query OK, 0 rows affected (0.00 sec) mysql> SET @a= 1, @a= @a+1; Query OK, 0 rows affected (0.00 sec) mysql> SELECT @a; +------+ | @a | +------+ | NULL | +------+ 1 row in set (0.00 sec) mysql> delimiter // mysql> CREATE FUNCTION f() RETURNS INTEGER -> DETERMINISTIC -> BEGIN -> SET @a= 1, @a= @a+1; -> -> RETURN @a; -> END// Query OK, 0 rows affected (0.00 sec) mysql> delimiter ; mysql> mysql> SELECT f(); +------+ | f() | +------+ | 2 | +------+ 1 row in set (0.00 sec) // 5.7.6 mysql> SET @a= NULL; Query OK, 0 rows affected (0.00 sec) mysql> SELECT @a:= 1, @a:= @a+1; +--------+-----------+ | @a:= 1 | @a:= @a+1 | +--------+-----------+ | 1 | 2 | +--------+-----------+ 1 row in set (0.00 sec) mysql> SELECT @a; +------+ | @a | +------+ | 2 | +------+ 1 row in set (0.00 sec) mysql> SET @a= NULL; Query OK, 0 rows affected (0.00 sec) mysql> DO @a:= 1, @a:= @a+1; Query OK, 0 rows affected (0.00 sec) mysql> SELECT @a; +------+ | @a | +------+ | 2 | +------+ 1 row in set (0.00 sec) mysql> SET @a= NULL; Query OK, 0 rows affected (0.00 sec) mysql> SET @a= 1, @a= @a+1; Query OK, 0 rows affected (0.00 sec) mysql> SELECT @a -> ; +------+ | @a | +------+ | NULL | +------+ 1 row in set (0.00 sec) mysql> mysql> delimiter // mysql> CREATE FUNCTION f() RETURNS INTEGER -> DETERMINISTIC -> BEGIN -> SET @a= 1, @a= @a+1; -> -> RETURN @a; -> END// Query OK, 0 rows affected (0.00 sec) mysql> delimiter ; mysql> mysql> SELECT f(); +------+ | f() | +------+ | 2 | +------+ 1 row in set (0.00 sec)