Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
-
None
Description
This script:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a INT);
|
INSERT INTO t1 VALUES (1);
|
UPDATE t1 SET t1.a='';
|
correctly reports 1 warning:
Rows matched: 1 Changed: 1 Warnings: 1
|
Looks correct so far.
Now I change the script slightly, to use a multi-UPDATE statement:
DROP TABLE IF EXISTS t1,t2;
|
CREATE TABLE t1 (a INT);
|
CREATE TABLE t2(a INT);
|
INSERT INTO t1 VALUES (1);
|
INSERT INTO t2 VALUES (1);
|
UPDATE t1,t2 SET t1.a='';
|
it reports no warnings:
Rows matched: 1 Changed: 1 Warnings: 0
|
A related problem:
DROP FUNCTION IF EXISTS f1;
|
DELIMITER //
|
CREATE FUNCTION f1 (a VARCHAR(20)) RETURNS INT
|
BEGIN
|
DECLARE d INT;
|
SET d= a;
|
SET d= a;
|
SET d= a; // Assign 3 times, to have multiple truncations on a bad string argument
|
RETURN d;
|
END;
|
//
|
DELIMITER ;
|
SELECT f1('123x');
|
|
|
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a INT);
|
INSERT INTO t1 VALUES (0);
|
UPDATE t1 SET a=f1('123x');
|
UPDATE t1, t1 t2 SET t1.a=f1('123x');
|
The above script returns:
MariaDB [test]> UPDATE t1 SET a=f1('123x');
|
Query OK, 1 row affected (0.03 sec)
|
Rows matched: 1 Changed: 1 Warnings: 0
|
|
|
MariaDB [test]> UPDATE t1, t1 t2 SET t1.a=f1('123x');
|
Query OK, 0 rows affected (0.04 sec)
|
Rows matched: 1 Changed: 0 Warnings: 3
|
The multi-table UPDATE incorrectly says "Warnings: 3" , that is it counted the truncations that happened inside SP. It should only count the number of truncations that happened in fields, which is 0.